Bug 1065999: Ignore unknown Bluetooth properties, r=shuang

This patch is a workaround for unknown Bluetooth properties. Instead of
failing completely, we simply ignore them.
This commit is contained in:
Thomas Zimmermann 2014-09-29 11:41:02 +02:00
parent a65ec99420
commit 9a53faf52f
8 changed files with 27 additions and 2 deletions

View File

@ -159,6 +159,7 @@ enum BluetoothDeviceType {
};
enum BluetoothPropertyType {
PROPERTY_UNKNOWN,
PROPERTY_BDNAME,
PROPERTY_BDADDR,
PROPERTY_UUIDS,

View File

@ -224,6 +224,9 @@ Convert(const bt_property_t& aIn, BluetoothProperty& aOut)
/* value conversion */
switch (aOut.mType) {
case PROPERTY_UNKNOWN:
/* Bug 1065999: working around unknown properties */
break;
case PROPERTY_BDNAME:
/* fall through */
case PROPERTY_REMOTE_FRIENDLY_NAME:

View File

@ -207,7 +207,9 @@ Convert(bt_property_type_t aIn, BluetoothPropertyType& aOut)
return NS_OK;
}
if (!aIn || aIn >= MOZ_ARRAY_LENGTH(sPropertyType)) {
return NS_ERROR_ILLEGAL_VALUE;
/* Bug 1065999: working around unknown properties */
aOut = PROPERTY_UNKNOWN;
return NS_OK;
}
aOut = sPropertyType[aIn];
return NS_OK;

View File

@ -1323,6 +1323,9 @@ BluetoothServiceBluedroid::AdapterPropertiesNotification(
} else if (p.mType == PROPERTY_UUIDS) {
//FIXME: This will be implemented in the later patchset
continue;
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
continue;
} else {
BT_LOGD("Unhandled adapter property type: %d", p.mType);
continue;
@ -1415,6 +1418,8 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
BT_APPEND_NAMED_VALUE(props, "Icon", NS_LITERAL_STRING("audio-card"));
}
BT_APPEND_NAMED_VALUE(props, "UUIDS", uuidsArray);
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
} else {
BT_LOGD("Other non-handled device properties. Type: %d", p.mType);
}
@ -1475,6 +1480,8 @@ BluetoothServiceBluedroid::DeviceFoundNotification(
ClassToIcon(cod, icon);
propertyValue = icon;
BT_APPEND_NAMED_VALUE(propertiesArray, "Icon", propertyValue);
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
} else {
BT_LOGD("Not handled remote device property: %d", p.mType);
}

View File

@ -223,6 +223,7 @@ enum BluetoothTypeOfDevice {
};
enum BluetoothPropertyType {
PROPERTY_UNKNOWN,
PROPERTY_BDNAME,
PROPERTY_BDADDR,
PROPERTY_UUIDS,

View File

@ -342,6 +342,9 @@ Convert(const bt_property_t& aIn, BluetoothProperty& aOut)
/* value conversion */
switch (aOut.mType) {
case PROPERTY_UNKNOWN:
/* Bug 1065999: working around unknown properties */
break;
case PROPERTY_BDNAME:
/* fall through */
case PROPERTY_REMOTE_FRIENDLY_NAME:

View File

@ -205,7 +205,9 @@ Convert(bt_property_type_t aIn, BluetoothPropertyType& aOut)
return NS_OK;
}
if (!aIn || aIn >= MOZ_ARRAY_LENGTH(sPropertyType)) {
return NS_ERROR_ILLEGAL_VALUE;
/* Bug 1065999: working around unknown properties */
aOut = PROPERTY_UNKNOWN;
return NS_OK;
}
aOut = sPropertyType[aIn];
return NS_OK;

View File

@ -1303,6 +1303,8 @@ BluetoothServiceBluedroid::AdapterPropertiesNotification(
BT_APPEND_NAMED_VALUE(propertiesArray, "PairedDevices", pairedDeviceAddresses);
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
} else {
BT_LOGD("Unhandled adapter property type: %d", p.mType);
continue;
@ -1370,6 +1372,8 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
BT_APPEND_NAMED_VALUE(propertiesArray, "Type",
static_cast<uint32_t>(p.mTypeOfDevice));
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
} else {
BT_LOGD("Other non-handled device properties. Type: %d", p.mType);
}
@ -1467,6 +1471,8 @@ BluetoothServiceBluedroid::DeviceFoundNotification(
BT_APPEND_NAMED_VALUE(propertiesArray, "Type",
static_cast<uint32_t>(p.mTypeOfDevice));
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
} else {
BT_LOGD("Not handled remote device property: %d", p.mType);
}