mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1061481 - Patch 3/3: Implementation of BluetoothDevice.type attribute, f=tzimmermann, r=echou
This commit is contained in:
parent
4b708f03f6
commit
629ae7c730
@ -82,9 +82,6 @@ BluetoothClassOfDevice::Update(const uint32_t aValue)
|
||||
mMajorServiceClass = GET_MAJOR_SERVICE_CLASS(aValue);
|
||||
mMajorDeviceClass = GET_MAJOR_DEVICE_CLASS(aValue);
|
||||
mMinorDeviceClass = GET_MINOR_DEVICE_CLASS(aValue);
|
||||
|
||||
BT_API2_LOGR("aValue %x => majorService %x majorDevice %x minorDevice %x",
|
||||
aValue, mMajorServiceClass, mMajorDeviceClass, mMinorDeviceClass);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -16,6 +16,16 @@ extern bool gBluetoothDebugFlag;
|
||||
|
||||
#define SWITCH_BT_DEBUG(V) (gBluetoothDebugFlag = V)
|
||||
|
||||
#if MOZ_IS_GCC && MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
|
||||
/* use designated array initializers if supported */
|
||||
#define CONVERT(in_, out_) \
|
||||
[in_] = out_
|
||||
#else
|
||||
/* otherwise init array element by position */
|
||||
#define CONVERT(in_, out_) \
|
||||
out_
|
||||
#endif
|
||||
|
||||
#undef BT_LOG
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
@ -200,10 +210,10 @@ enum BluetoothBondState {
|
||||
BOND_STATE_BONDED
|
||||
};
|
||||
|
||||
enum BluetoothDeviceType {
|
||||
DEVICE_TYPE_BREDR,
|
||||
DEVICE_TYPE_BLE,
|
||||
DEVICE_TYPE_DUAL
|
||||
enum BluetoothTypeOfDevice {
|
||||
TYPE_OF_DEVICE_BREDR,
|
||||
TYPE_OF_DEVICE_BLE,
|
||||
TYPE_OF_DEVICE_DUAL
|
||||
};
|
||||
|
||||
enum BluetoothPropertyType {
|
||||
@ -276,8 +286,8 @@ struct BluetoothProperty {
|
||||
/* PROPERTY_RSSI_VALUE */
|
||||
int32_t mInt32;
|
||||
|
||||
/* PROPERTY_DEVICE_TYPE */
|
||||
BluetoothDeviceType mDeviceType;
|
||||
/* PROPERTY_TYPE_OF_DEVICE */
|
||||
BluetoothTypeOfDevice mTypeOfDevice;
|
||||
|
||||
/* PROPERTY_SERVICE_RECORD */
|
||||
BluetoothServiceRecord mServiceRecord;
|
||||
|
@ -75,6 +75,7 @@ BluetoothDevice::BluetoothDevice(nsPIDOMWindow* aWindow,
|
||||
const BluetoothValue& aValue)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mPaired(false)
|
||||
, mType(BluetoothDeviceType::Unknown)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
@ -110,6 +111,22 @@ BluetoothDevice::DisconnectFromOwner()
|
||||
bs->UnregisterBluetoothSignalHandler(mAddress, this);
|
||||
}
|
||||
|
||||
BluetoothDeviceType
|
||||
BluetoothDevice::ConvertUint32ToDeviceType(const uint32_t aValue)
|
||||
{
|
||||
static const BluetoothDeviceType sDeviceType[] = {
|
||||
CONVERT(TYPE_OF_DEVICE_BREDR, BluetoothDeviceType::Classic),
|
||||
CONVERT(TYPE_OF_DEVICE_BLE, BluetoothDeviceType::Le),
|
||||
CONVERT(TYPE_OF_DEVICE_DUAL, BluetoothDeviceType::Dual),
|
||||
};
|
||||
|
||||
BluetoothTypeOfDevice type = static_cast<BluetoothTypeOfDevice>(aValue);
|
||||
if (type >= MOZ_ARRAY_LENGTH(sDeviceType)) {
|
||||
return BluetoothDeviceType::Unknown;
|
||||
}
|
||||
return sDeviceType[type];
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
|
||||
{
|
||||
@ -129,6 +146,8 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
|
||||
// directly.
|
||||
mUuids = value.get_ArrayOfnsString();
|
||||
BluetoothDeviceBinding::ClearCachedUuidsValue(this);
|
||||
} else if (name.EqualsLiteral("Type")) {
|
||||
mType = ConvertUint32ToDeviceType(value.get_uint32_t());
|
||||
} else {
|
||||
BT_WARNING("Not handling device property: %s",
|
||||
NS_ConvertUTF16toUTF8(name).get());
|
||||
|
@ -64,6 +64,11 @@ public:
|
||||
aUuids = mUuids;
|
||||
}
|
||||
|
||||
BluetoothDeviceType Type() const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Event Handlers
|
||||
***************************************************************************/
|
||||
@ -122,6 +127,13 @@ private:
|
||||
*/
|
||||
void DispatchAttributeEvent(const nsTArray<nsString>& aTypes);
|
||||
|
||||
/**
|
||||
* Convert uint32_t to BluetoothDeviceType.
|
||||
*
|
||||
* @param aValue [in] uint32_t to convert
|
||||
*/
|
||||
BluetoothDeviceType ConvertUint32ToDeviceType(const uint32_t aValue);
|
||||
|
||||
/**
|
||||
* Convert string to BluetoothDeviceAttribute.
|
||||
*
|
||||
@ -166,6 +178,11 @@ private:
|
||||
* Cached UUID list of services which this device provides.
|
||||
*/
|
||||
nsTArray<nsString> mUuids;
|
||||
|
||||
/**
|
||||
* Type of this device. Can be unknown/classic/le/dual.
|
||||
*/
|
||||
BluetoothDeviceType mType;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -13,16 +13,6 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#if MOZ_IS_GCC && MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
|
||||
/* use designated array initializers if supported */
|
||||
#define CONVERT(in_, out_) \
|
||||
[in_] = out_
|
||||
#else
|
||||
/* otherwise init array element by position */
|
||||
#define CONVERT(in_, out_) \
|
||||
out_
|
||||
#endif
|
||||
|
||||
#define MAX_UUID_SIZE 16
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
@ -423,18 +413,18 @@ Convert(bt_acl_state_t aIn, bool& aOut)
|
||||
}
|
||||
|
||||
static nsresult
|
||||
Convert(bt_device_type_t aIn, BluetoothDeviceType& aOut)
|
||||
Convert(bt_device_type_t aIn, BluetoothTypeOfDevice& aOut)
|
||||
{
|
||||
static const BluetoothDeviceType sDeviceType[] = {
|
||||
CONVERT(0, static_cast<BluetoothDeviceType>(0)), // invalid, required by gcc
|
||||
CONVERT(BT_DEVICE_DEVTYPE_BREDR, DEVICE_TYPE_BREDR),
|
||||
CONVERT(BT_DEVICE_DEVTYPE_BLE, DEVICE_TYPE_BLE),
|
||||
CONVERT(BT_DEVICE_DEVTYPE_DUAL, DEVICE_TYPE_DUAL)
|
||||
static const BluetoothTypeOfDevice sTypeOfDevice[] = {
|
||||
CONVERT(0, static_cast<BluetoothTypeOfDevice>(0)), // invalid, required by gcc
|
||||
CONVERT(BT_DEVICE_DEVTYPE_BREDR, TYPE_OF_DEVICE_BREDR),
|
||||
CONVERT(BT_DEVICE_DEVTYPE_BLE, TYPE_OF_DEVICE_BLE),
|
||||
CONVERT(BT_DEVICE_DEVTYPE_DUAL, TYPE_OF_DEVICE_DUAL)
|
||||
};
|
||||
if (!aIn || aIn >= MOZ_ARRAY_LENGTH(sDeviceType)) {
|
||||
if (!aIn || aIn >= MOZ_ARRAY_LENGTH(sTypeOfDevice)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aOut = sDeviceType[aIn];
|
||||
aOut = sTypeOfDevice[aIn];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1045,7 +1035,7 @@ Convert(const bt_property_t& aIn, BluetoothProperty& aOut)
|
||||
break;
|
||||
case PROPERTY_TYPE_OF_DEVICE:
|
||||
rv = Convert(*static_cast<bt_device_type_t*>(aIn.val),
|
||||
aOut.mDeviceType);
|
||||
aOut.mTypeOfDevice);
|
||||
break;
|
||||
case PROPERTY_SERVICE_RECORD:
|
||||
rv = Convert(*static_cast<bt_service_record_t*>(aIn.val),
|
||||
|
@ -1363,6 +1363,10 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
|
||||
}
|
||||
BT_APPEND_NAMED_VALUE(propertiesArray, "UUIDs", uuids);
|
||||
|
||||
} else if (p.mType == PROPERTY_TYPE_OF_DEVICE) {
|
||||
BT_APPEND_NAMED_VALUE(propertiesArray, "Type",
|
||||
static_cast<uint32_t>(p.mTypeOfDevice));
|
||||
|
||||
} else {
|
||||
BT_LOGD("Other non-handled device properties. Type: %d", p.mType);
|
||||
}
|
||||
@ -1456,6 +1460,10 @@ BluetoothServiceBluedroid::DeviceFoundNotification(
|
||||
}
|
||||
BT_APPEND_NAMED_VALUE(propertiesArray, "UUIDs", uuids);
|
||||
|
||||
} else if (p.mType == PROPERTY_TYPE_OF_DEVICE) {
|
||||
BT_APPEND_NAMED_VALUE(propertiesArray, "Type",
|
||||
static_cast<uint32_t>(p.mTypeOfDevice));
|
||||
|
||||
} else {
|
||||
BT_LOGD("Not handled remote device property: %d", p.mType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user