Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1141899 - If Bluetooth CoD of remote device is unclear, add commo…
Browse files Browse the repository at this point in the history
…n profile managers to profile list. r=shuang
  • Loading branch information
JaminLiu committed Apr 2, 2015
1 parent fe61724 commit 01d7d59
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dom/bluetooth/BluetoothProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ BluetoothProfileController::SetupProfiles(bool aAssignServiceClass)
bool isRemoteControl = IS_REMOTE_CONTROL(mTarget.cod);
bool isKeyboard = IS_KEYBOARD(mTarget.cod);
bool isPointingDevice = IS_POINTING_DEVICE(mTarget.cod);
bool isInvalid = IS_INVALID_COD(mTarget.cod);

// The value of CoD is invalid. Since the device didn't declare its class of
// device properly, we assume the device may support all of these profiles.
if (isInvalid) {
AddProfile(BluetoothHfpManager::Get());
AddProfile(BluetoothA2dpManager::Get());
AddProfile(BluetoothHidManager::Get());
return;
}

NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral);

Expand Down
11 changes: 11 additions & 0 deletions dom/bluetooth/BluetoothProfileController.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ BEGIN_BLUETOOTH_NAMESPACE
// Pointing device: sub-field of minor device class (Bit 7)
#define IS_POINTING_DEVICE(cod) ((GET_MINOR_DEVICE_CLASS(cod) & 0x20) >> 5)

/**
* Check whether the value of CoD is invalid. (i.e. Bit 31 ~ Bit 24 != 0x0)
*
* According to Bluetooth core spec v4.1. Vol 2, Sec. 7.3, the data length of
* CoD (class of device) is 3 bytes. The two least significant bits are used to
* indicate 'format type'. The following 22 bits are used to indicate category
* of service class and device type. The remaining 8 bits (Bit 31 ~ Bit 24)
* should be unassigned bits, since BlueDroid uses uint32_t to store CoD.
*/
#define IS_INVALID_COD(cod) (cod >> 24)

class BluetoothProfileManagerBase;
class BluetoothReplyRunnable;
typedef void (*BluetoothProfileControllerCallback)();
Expand Down
10 changes: 10 additions & 0 deletions dom/bluetooth2/BluetoothProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ BluetoothProfileController::SetupProfiles(bool aAssignServiceClass)
bool isRemoteControl = IS_REMOTE_CONTROL(mTarget.cod);
bool isKeyboard = IS_KEYBOARD(mTarget.cod);
bool isPointingDevice = IS_POINTING_DEVICE(mTarget.cod);
bool isInvalid = IS_INVALID_COD(mTarget.cod);

// The value of CoD is invalid. Since the device didn't declare its class of
// device properly, we assume the device may support all of these profiles.
if (isInvalid) {
AddProfile(BluetoothHfpManager::Get());
AddProfile(BluetoothA2dpManager::Get());
AddProfile(BluetoothHidManager::Get());
return;
}

NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral);

Expand Down
11 changes: 11 additions & 0 deletions dom/bluetooth2/BluetoothProfileController.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ BEGIN_BLUETOOTH_NAMESPACE
// Pointing device: sub-field of minor device class (Bit 7)
#define IS_POINTING_DEVICE(cod) ((GET_MINOR_DEVICE_CLASS(cod) & 0x20) >> 5)

/**
* Check whether the value of CoD is invalid. (i.e. Bit 31 ~ Bit 24 != 0x0)
*
* According to Bluetooth core spec v4.1. Vol 2, Sec. 7.3, the data length of
* CoD (class of device) is 3 bytes. The two least significant bits are used to
* indicate 'format type'. The following 22 bits are used to indicate category
* of service class and device type. The remaining 8 bits (Bit 31 ~ Bit 24)
* should be unassigned bits, since BlueDroid uses uint32_t to store CoD.
*/
#define IS_INVALID_COD(cod) (cod >> 24)

class BluetoothProfileManagerBase;
class BluetoothReplyRunnable;
typedef void (*BluetoothProfileControllerCallback)();
Expand Down

0 comments on commit 01d7d59

Please sign in to comment.