mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1204497: Interpret AVRCP remote features as bitmask, r=shuang
The current IPC parsing code is incorrect. AVRCP remote features are specified as bitmask, but the current IPC code treats them as values. This patch fixes this.
This commit is contained in:
parent
8bdf56f23b
commit
48a8903713
@ -497,7 +497,7 @@ public:
|
||||
/* Read feature */
|
||||
rv = UnpackPDU(
|
||||
pdu,
|
||||
UnpackConversion<BluetoothAvrcpRemoteFeature, unsigned long>(aArg2));
|
||||
UnpackConversion<BluetoothAvrcpRemoteFeatureBits, unsigned long>(aArg2));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -202,24 +202,26 @@ Convert(uint8_t aIn, BluetoothAvrcpPlayerAttribute& aOut)
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothAvrcpRemoteFeature& aOut)
|
||||
Convert(uint8_t aIn, BluetoothAvrcpRemoteFeatureBits& aOut)
|
||||
{
|
||||
static const BluetoothAvrcpRemoteFeature sAvrcpRemoteFeature[] = {
|
||||
[0x00] = AVRCP_REMOTE_FEATURE_NONE,
|
||||
[0x01] = AVRCP_REMOTE_FEATURE_METADATA,
|
||||
[0x02] = AVRCP_REMOTE_FEATURE_ABSOLUTE_VOLUME,
|
||||
[0x03] = AVRCP_REMOTE_FEATURE_BROWSE
|
||||
static const uint8_t sAvrcpRemoteFeatureBits[] = {
|
||||
[0] = AVRCP_REMOTE_FEATURE_METADATA,
|
||||
[1] = AVRCP_REMOTE_FEATURE_ABSOLUTE_VOLUME,
|
||||
[2] = AVRCP_REMOTE_FEATURE_BROWSE
|
||||
};
|
||||
uint8_t bits = 0;
|
||||
size_t i;
|
||||
for (i = 0; i < MOZ_ARRAY_LENGTH(sAvrcpRemoteFeatureBits); ++i, aIn >>= 1) {
|
||||
if (aIn & 0x01) {
|
||||
bits |= sAvrcpRemoteFeatureBits[i];
|
||||
}
|
||||
}
|
||||
if (MOZ_HAL_IPC_CONVERT_WARN_IF(
|
||||
!aIn, uint8_t, BluetoothAvrcpRemoteFeature) ||
|
||||
MOZ_HAL_IPC_CONVERT_WARN_IF(
|
||||
aIn >= MOZ_ARRAY_LENGTH(sAvrcpRemoteFeature), uint8_t,
|
||||
BluetoothAvrcpRemoteFeature)) {
|
||||
// silences compiler warning
|
||||
aOut = static_cast<BluetoothAvrcpRemoteFeature>(0);
|
||||
aIn << i, 'uint8_t', BluetoothAvrcpRemoteFeatureBits)) {
|
||||
aOut = AVRCP_REMOTE_FEATURE_NONE; // silences compiler warning
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aOut = sAvrcpRemoteFeature[aIn];
|
||||
aOut = static_cast<BluetoothAvrcpRemoteFeatureBits>(bits);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -685,7 +687,7 @@ Convert(BluetoothAvrcpPlayerAttribute aIn, uint8_t& aOut)
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothAvrcpRemoteFeature aIn, unsigned long& aOut)
|
||||
Convert(BluetoothAvrcpRemoteFeatureBits aIn, unsigned long& aOut)
|
||||
{
|
||||
if (MOZ_HAL_IPC_CONVERT_WARN_IF(
|
||||
aIn < std::numeric_limits<unsigned long>::min(),
|
||||
@ -1498,10 +1500,10 @@ UnpackPDU(DaemonSocketPDU& aPDU, BluetoothAvrcpPlayerSettings& aOut)
|
||||
}
|
||||
|
||||
nsresult
|
||||
UnpackPDU(DaemonSocketPDU& aPDU, BluetoothAvrcpRemoteFeature& aOut)
|
||||
UnpackPDU(DaemonSocketPDU& aPDU, BluetoothAvrcpRemoteFeatureBits& aOut)
|
||||
{
|
||||
return UnpackPDU(
|
||||
aPDU, UnpackConversion<uint8_t, BluetoothAvrcpRemoteFeature>(aOut));
|
||||
aPDU, UnpackConversion<uint8_t, BluetoothAvrcpRemoteFeatureBits>(aOut));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -157,7 +157,7 @@ nsresult
|
||||
Convert(uint8_t aIn, BluetoothAvrcpPlayerAttribute& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothAvrcpRemoteFeature& aOut);
|
||||
Convert(uint8_t aIn, BluetoothAvrcpRemoteFeatureBits& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothHandsfreeAudioState& aOut);
|
||||
@ -229,7 +229,7 @@ nsresult
|
||||
Convert(BluetoothAvrcpPlayerAttribute aIn, uint8_t& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothAvrcpRemoteFeature aIn, unsigned long& aOut);
|
||||
Convert(BluetoothAvrcpRemoteFeatureBits aIn, unsigned long& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothAvrcpStatus aIn, uint8_t& aOut);
|
||||
@ -443,7 +443,7 @@ nsresult
|
||||
UnpackPDU(DaemonSocketPDU& aPDU, BluetoothAvrcpPlayerSettings& aOut);
|
||||
|
||||
nsresult
|
||||
UnpackPDU(DaemonSocketPDU& aPDU, BluetoothAvrcpRemoteFeature& aOut);
|
||||
UnpackPDU(DaemonSocketPDU& aPDU, BluetoothAvrcpRemoteFeatureBits& aOut);
|
||||
|
||||
nsresult
|
||||
UnpackPDU(DaemonSocketPDU& aPDU, BluetoothBondState& aOut);
|
||||
|
@ -574,11 +574,11 @@ enum BluetoothAvrcpNotification {
|
||||
AVRCP_NTF_CHANGED
|
||||
};
|
||||
|
||||
enum BluetoothAvrcpRemoteFeature {
|
||||
enum BluetoothAvrcpRemoteFeatureBits {
|
||||
AVRCP_REMOTE_FEATURE_NONE,
|
||||
AVRCP_REMOTE_FEATURE_METADATA,
|
||||
AVRCP_REMOTE_FEATURE_ABSOLUTE_VOLUME,
|
||||
AVRCP_REMOTE_FEATURE_BROWSE
|
||||
AVRCP_REMOTE_FEATURE_METADATA = 0x01,
|
||||
AVRCP_REMOTE_FEATURE_ABSOLUTE_VOLUME = 0x02,
|
||||
AVRCP_REMOTE_FEATURE_BROWSE = 0x04
|
||||
};
|
||||
|
||||
struct BluetoothAvrcpElementAttribute {
|
||||
|
Loading…
Reference in New Issue
Block a user