Bug 808879 - Patch 1: Expose connection status for system app, r=qdot, sr=mrbkap

This commit is contained in:
Gina Yeh 2012-11-07 10:12:41 -08:00
parent 5a334278ca
commit 8ef660a117
9 changed files with 51 additions and 3 deletions

View File

@ -519,7 +519,7 @@ Services.obs.addObserver(function onWebappsReady(subject, topic, data) {
Services.obs.addObserver(function onBluetoothVolumeChange(subject, topic, data) {
shell.sendChromeEvent({
type: "volumeset",
type: "bluetooth-volumeset",
value: data
});
}, 'bluetooth-volume-change', false);

View File

@ -25,7 +25,7 @@
#include <unistd.h> /* usleep() */
#define MOZSETTINGS_CHANGED_ID "mozsettings-changed"
#define AUDIO_VOLUME_MASTER "audio.volume.master"
#define AUDIO_VOLUME_MASTER "audio.volume.bt_sco"
#define HANDSFREE_UUID mozilla::dom::bluetooth::BluetoothServiceUuidStr::Handsfree
#define HEADSET_UUID mozilla::dom::bluetooth::BluetoothServiceUuidStr::Headset

View File

@ -266,6 +266,19 @@ BluetoothManager::Notify(const BluetoothSignal& aData)
}
}
NS_IMETHODIMP
BluetoothManager::IsConnected(uint16_t aProfileId, bool* aConnected)
{
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
NS_WARNING("BluetoothService not available!");
return NS_ERROR_FAILURE;
}
*aConnected = bs->IsConnected(aProfileId);
return NS_OK;
}
NS_IMPL_EVENT_HANDLER(BluetoothManager, enabled)
NS_IMPL_EVENT_HANDLER(BluetoothManager, disabled)
NS_IMPL_EVENT_HANDLER(BluetoothManager, adapteradded)

View File

@ -273,6 +273,9 @@ public:
virtual void
Disconnect(uint16_t aProfileId, BluetoothReplyRunnable* aRunnable) = 0;
virtual bool
IsConnected(uint16_t aProfileId) = 0;
virtual void
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,

View File

@ -391,3 +391,10 @@ BluetoothServiceChildProcess::StopInternal()
MOZ_NOT_REACHED("This should never be called!");
return NS_ERROR_FAILURE;
}
bool
BluetoothServiceChildProcess::IsConnected(uint16_t aProfileId)
{
MOZ_NOT_REACHED("This should never be called!");
return false;
}

View File

@ -139,6 +139,9 @@ public:
Disconnect(const uint16_t aProfileId,
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
virtual bool
IsConnected(uint16_t aProfileId) MOZ_OVERRIDE;
virtual void
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,

View File

@ -2387,6 +2387,23 @@ BluetoothDBusService::Disconnect(const uint16_t aProfileId,
DispatchBluetoothReply(aRunnable, v, replyError);
}
bool
BluetoothDBusService::IsConnected(const uint16_t aProfileId)
{
NS_ASSERTION(NS_IsMainThread(), "Must be called from main thread!");
if (aProfileId == (uint16_t)(BluetoothServiceUuid::Handsfree >> 32)
|| aProfileId == (uint16_t)(BluetoothServiceUuid::Headset >> 32)) {
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
return hfp->GetConnectionStatus() == SocketConnectionStatus::SOCKET_CONNECTED;
} else if (aProfileId == (uint16_t)(BluetoothServiceUuid::ObjectPush >> 32)) {
BluetoothOppManager* opp = BluetoothOppManager::Get();
return opp->GetConnectionStatus() == SocketConnectionStatus::SOCKET_CONNECTED;
}
return false;
}
class ConnectBluetoothSocketRunnable : public nsRunnable
{
public:

View File

@ -139,6 +139,9 @@ public:
const uint16_t aProfileId,
BluetoothReplyRunnable* aRunnable);
virtual bool
IsConnected(uint16_t aProfileId);
virtual void
Disconnect(const uint16_t aProfileId, BluetoothReplyRunnable* aRunnable);

View File

@ -9,13 +9,15 @@
interface nsIDOMDOMRequest;
interface nsIDOMBluetoothAdapter;
[scriptable, builtinclass, uuid(d27ec867-949f-4585-b718-d2352e420ec6)]
[scriptable, builtinclass, uuid(3300693f-ae91-4a3f-b887-bf502c6a97ee)]
interface nsIDOMBluetoothManager : nsIDOMEventTarget
{
readonly attribute bool enabled;
nsIDOMDOMRequest getDefaultAdapter();
bool isConnected(in unsigned short aProfile);
[implicit_jscontext] attribute jsval onenabled;
[implicit_jscontext] attribute jsval ondisabled;
[implicit_jscontext] attribute jsval onadapteradded;