Bug 1154136 - Update Bluetooth connection state when BT stack updates device properties. r=shuang

This commit is contained in:
Jamin Liu 2015-04-14 18:46:23 +08:00
Родитель 81562a5b65
Коммит 86a4f50475
3 изменённых файлов: 45 добавлений и 0 удалений

Просмотреть файл

@ -1976,6 +1976,43 @@ BluetoothServiceBluedroid::UuidToServiceClassInt(const BluetoothUuid& mUuid)
memcpy(&shortUuid, mUuid.mUuid + 2, sizeof(uint16_t));
return ntohs(shortUuid);
}
bool
BluetoothServiceBluedroid::IsConnected(const nsAString& aRemoteBdAddr)
{
MOZ_ASSERT(NS_IsMainThread());
nsString connectedAddress;
// Check whether HFP/HSP are connected.
BluetoothProfileManagerBase* profile;
profile = BluetoothHfpManager::Get();
if (profile && profile->IsConnected()) {
profile->GetAddress(connectedAddress);
if (aRemoteBdAddr.Equals(connectedAddress)) {
return true;
}
}
// Check whether OPP is connected.
profile = BluetoothOppManager::Get();
if (profile->IsConnected()) {
profile->GetAddress(connectedAddress);
if (aRemoteBdAddr.Equals(connectedAddress)) {
return true;
}
}
// Check whether A2DP is connected.
profile = BluetoothA2dpManager::Get();
if (profile->IsConnected()) {
profile->GetAddress(connectedAddress);
if (aRemoteBdAddr.Equals(connectedAddress)) {
return true;
}
}
return false;
}
#endif
//
@ -2485,6 +2522,10 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
}
}
// BlueDroid wouldn't notify the status of connection, therefore, query the
// connection state and append to properties array
BT_APPEND_NAMED_VALUE(props, "Connected", IsConnected(aBdAddr));
if (sRequestedDeviceCountArray.IsEmpty()) {
// This is possible because the callback would be called after turning
// Bluetooth on.

Просмотреть файл

@ -505,6 +505,8 @@ protected:
const nsAString& aPlayStatus);
uint16_t UuidToServiceClassInt(const BluetoothUuid& mUuid);
static bool IsConnected(const nsAString& aRemoteBdAddr);
};
END_BLUETOOTH_NAMESPACE

Просмотреть файл

@ -50,6 +50,8 @@ BluetoothDevice::BluetoothDevice(nsPIDOMWindow* aWindow,
, mJsUuids(nullptr)
, mJsServices(nullptr)
, mAdapterPath(aAdapterPath)
, mConnected(false)
, mPaired(false)
, mIsRooted(false)
{
MOZ_ASSERT(aWindow);