Bug 915207 - Failed to get connected devices of A2DP, r=echou

This commit is contained in:
Gina Yeh 2013-09-12 17:45:33 +02:00
Родитель 40a4bb4ccb
Коммит 6dbf6f8afc
3 изменённых файлов: 47 добавлений и 24 удалений

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

@ -6,16 +6,21 @@
#include "BluetoothUuid.h"
#include "BluetoothA2dpManager.h"
#include "BluetoothHfpManager.h"
#include "BluetoothHidManager.h"
#include "BluetoothOppManager.h"
USING_BLUETOOTH_NAMESPACE
void
BluetoothUuidHelper::GetString(BluetoothServiceClass aServiceClassUuid,
BluetoothUuidHelper::GetString(BluetoothServiceClass aServiceClass,
nsAString& aRetUuidStr)
{
aRetUuidStr.Truncate();
aRetUuidStr.AppendLiteral("0000");
aRetUuidStr.AppendInt(aServiceClassUuid, 16);
aRetUuidStr.AppendInt(aServiceClass, 16);
aRetUuidStr.AppendLiteral("-0000-1000-8000-00805F9B34FB");
}
@ -41,10 +46,10 @@ BluetoothUuidHelper::GetBluetoothServiceClass(const nsAString& aUuidStr)
}
BluetoothServiceClass
BluetoothUuidHelper::GetBluetoothServiceClass(uint16_t aProfileId)
BluetoothUuidHelper::GetBluetoothServiceClass(uint16_t aServiceUuid)
{
BluetoothServiceClass retValue = BluetoothServiceClass::UNKNOWN;
switch (aProfileId) {
switch (aServiceUuid) {
case BluetoothServiceClass::A2DP:
case BluetoothServiceClass::HANDSFREE:
case BluetoothServiceClass::HANDSFREE_AG:
@ -52,7 +57,32 @@ BluetoothUuidHelper::GetBluetoothServiceClass(uint16_t aProfileId)
case BluetoothServiceClass::HEADSET_AG:
case BluetoothServiceClass::HID:
case BluetoothServiceClass::OBJECT_PUSH:
retValue = (BluetoothServiceClass)aProfileId;
retValue = (BluetoothServiceClass)aServiceUuid;
}
return retValue;
}
BluetoothProfileManagerBase*
BluetoothUuidHelper::GetBluetoothProfileManager(uint16_t aServiceUuid)
{
BluetoothProfileManagerBase* profile;
BluetoothServiceClass serviceClass = GetBluetoothServiceClass(aServiceUuid);
switch (serviceClass) {
case BluetoothServiceClass::HANDSFREE:
case BluetoothServiceClass::HEADSET:
profile = BluetoothHfpManager::Get();
break;
case BluetoothServiceClass::HID:
profile = BluetoothHidManager::Get();
break;
case BluetoothServiceClass::A2DP:
profile = BluetoothA2dpManager::Get();
break;
case BluetoothServiceClass::OBJECT_PUSH:
profile = BluetoothOppManager::Get();
break;
default:
profile = nullptr;
}
return profile;
}

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

@ -11,6 +11,8 @@
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothProfileManagerBase;
/*
* Service classes and Profile Identifiers
*
@ -55,7 +57,10 @@ public:
GetBluetoothServiceClass(const nsAString& aUuidStr);
static BluetoothServiceClass
GetBluetoothServiceClass(uint16_t aProfileId);
GetBluetoothServiceClass(uint16_t aServiceUuid);
static BluetoothProfileManagerBase*
GetBluetoothProfileManager(uint16_t aServiceUuid);
};
// TODO/qdot: Move these back into gonk and make the service handler deal with

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

@ -2205,15 +2205,9 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(uint16_t aServiceUuid
}
nsTArray<nsString> deviceAddresses;
BluetoothProfileManagerBase* profile;
if (aServiceUuid == BluetoothServiceClass::HANDSFREE ||
aServiceUuid == BluetoothServiceClass::HEADSET) {
profile = BluetoothHfpManager::Get();
} else if (aServiceUuid == BluetoothServiceClass::HID) {
profile = BluetoothHidManager::Get();
} else if (aServiceUuid == BluetoothServiceClass::OBJECT_PUSH) {
profile = BluetoothOppManager::Get();
} else {
BluetoothProfileManagerBase* profile =
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
if (!profile) {
DispatchBluetoothReply(aRunnable, values,
NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE));
return NS_OK;
@ -2680,15 +2674,9 @@ BluetoothDBusService::IsConnected(const uint16_t aServiceUuid)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothProfileManagerBase* profile;
if (aServiceUuid == BluetoothServiceClass::HANDSFREE ||
aServiceUuid == BluetoothServiceClass::HEADSET) {
profile = BluetoothHfpManager::Get();
} else if (aServiceUuid == BluetoothServiceClass::HID) {
profile = BluetoothHidManager::Get();
} else if (aServiceUuid == BluetoothServiceClass::OBJECT_PUSH) {
profile = BluetoothOppManager::Get();
} else {
BluetoothProfileManagerBase* profile =
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
if (!profile) {
NS_WARNING(ERR_UNKNOWN_PROFILE);
return false;
}