зеркало из https://github.com/mozilla/gecko-dev.git
merge b2g-inbound to mozilla-central
This commit is contained in:
Коммит
3639d20cf4
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"revision": "7412c36923b59f6e4d7076de5be7e6ded6ddc586",
|
||||
"revision": "444fa63091ea8641d08681f921631f8b7ddc0d88",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -315,11 +315,13 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
|
|||
DispatchTrustedEvent(event);
|
||||
} else if (aData.name().EqualsLiteral("PropertyChanged")) {
|
||||
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
|
||||
|
||||
const InfallibleTArray<BluetoothNamedValue>& arr =
|
||||
v.get_ArrayOfBluetoothNamedValue();
|
||||
|
||||
MOZ_ASSERT(arr.Length() == 1);
|
||||
SetPropertyByValue(arr[0]);
|
||||
for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) {
|
||||
SetPropertyByValue(arr[i]);
|
||||
}
|
||||
} else if (aData.name().EqualsLiteral(DISCOVERY_STATE_CHANGED_ID)) {
|
||||
MOZ_ASSERT(v.type() == BluetoothValue::Tbool);
|
||||
bool isDiscovering = v.get_bool();
|
||||
|
|
|
@ -181,14 +181,14 @@ BluetoothDevice::Notify(const BluetoothSignal& aData)
|
|||
|
||||
BluetoothValue v = aData.value();
|
||||
if (aData.name().EqualsLiteral("PropertyChanged")) {
|
||||
NS_ASSERTION(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue,
|
||||
"PropertyChanged: Invalid value type");
|
||||
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
|
||||
|
||||
const InfallibleTArray<BluetoothNamedValue>& arr =
|
||||
v.get_ArrayOfBluetoothNamedValue();
|
||||
|
||||
NS_ASSERTION(arr.Length() == 1,
|
||||
"Got more than one property in a change message!");
|
||||
SetPropertyByValue(arr[0]);
|
||||
for (uint32_t i = 0, propCount = arr.Length(); i < propCount; ++i) {
|
||||
SetPropertyByValue(arr[i]);
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
nsCString warningMsg;
|
||||
|
|
|
@ -289,19 +289,18 @@ AdapterStateChangeCallback(bt_state_t aStatus)
|
|||
}
|
||||
|
||||
/**
|
||||
* AdapterPropertiesChangeCallback will be called after enable() but before
|
||||
* AdapterStateChangeCallback sIsBtEnabled get updated.
|
||||
* At that moment, both BluetoothManager/BluetoothAdapter does not register
|
||||
* observer yet.
|
||||
* AdapterPropertiesCallback will be called after enable() but before
|
||||
* AdapterStateChangeCallback sIsBtEnabled get updated. At that moment, both
|
||||
* BluetoothManager/BluetoothAdapter does not register observer yet.
|
||||
*/
|
||||
static void
|
||||
AdapterPropertiesChangeCallback(bt_status_t aStatus, int aNumProperties,
|
||||
bt_property_t *aProperties)
|
||||
AdapterPropertiesCallback(bt_status_t aStatus, int aNumProperties,
|
||||
bt_property_t *aProperties)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
BluetoothValue propertyValue;
|
||||
InfallibleTArray<BluetoothNamedValue> propertiesArray;
|
||||
InfallibleTArray<BluetoothNamedValue> props;
|
||||
|
||||
for (int i = 0; i < aNumProperties; i++) {
|
||||
bt_property_t p = aProperties[i];
|
||||
|
@ -309,14 +308,14 @@ AdapterPropertiesChangeCallback(bt_status_t aStatus, int aNumProperties,
|
|||
if (p.type == BT_PROPERTY_BDADDR) {
|
||||
BdAddressTypeToString((bt_bdaddr_t*)p.val, sAdapterBdAddress);
|
||||
propertyValue = sAdapterBdAddress;
|
||||
propertiesArray.AppendElement(
|
||||
props.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("Address"), propertyValue));
|
||||
} else if (p.type == BT_PROPERTY_BDNAME) {
|
||||
// Construct nsCString here because Bd name returned from bluedroid
|
||||
// is missing a null terminated character after SetProperty.
|
||||
propertyValue = sAdapterBdName = NS_ConvertUTF8toUTF16(
|
||||
nsCString((char*)p.val, p.len));
|
||||
propertiesArray.AppendElement(
|
||||
props.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("Name"), propertyValue));
|
||||
} else if (p.type == BT_PROPERTY_ADAPTER_SCAN_MODE) {
|
||||
bt_scan_mode_t newMode = *(bt_scan_mode_t*)p.val;
|
||||
|
@ -327,11 +326,11 @@ AdapterPropertiesChangeCallback(bt_status_t aStatus, int aNumProperties,
|
|||
propertyValue = sAdapterDiscoverable = false;
|
||||
}
|
||||
|
||||
propertiesArray.AppendElement(
|
||||
props.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("Discoverable"), propertyValue));
|
||||
} else if (p.type == BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT) {
|
||||
propertyValue = sAdapterDiscoverableTimeout = *(uint32_t*)p.val;
|
||||
propertiesArray.AppendElement(
|
||||
props.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("DiscoverableTimeout"),
|
||||
propertyValue));
|
||||
} else if (p.type == BT_PROPERTY_ADAPTER_BONDED_DEVICES) {
|
||||
|
@ -352,45 +351,44 @@ AdapterPropertiesChangeCallback(bt_status_t aStatus, int aNumProperties,
|
|||
}
|
||||
|
||||
propertyValue = sAdapterBondedAddressArray;
|
||||
propertiesArray.AppendElement(
|
||||
props.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("Devices"), propertyValue));
|
||||
} else if (p.type == BT_PROPERTY_UUIDS) {
|
||||
//FIXME: This will be implemented in the later patchset
|
||||
return;
|
||||
continue;
|
||||
} else {
|
||||
BT_LOGD("Unhandled adapter property type: %d", p.type);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
BluetoothValue value(propertiesArray);
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
|
||||
NS_LITERAL_STRING(KEY_ADAPTER), value);
|
||||
nsRefPtr<DistributeBluetoothSignalTask>
|
||||
t = new DistributeBluetoothSignalTask(signal);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(t))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
NS_ENSURE_TRUE_VOID(props.Length() > 0);
|
||||
|
||||
// bluedroid BTU task was stored in the task queue, see GKI_send_msg
|
||||
if (!sSetPropertyRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sSetPropertyRunnableArray[0], BluetoothValue(true),
|
||||
EmptyString());
|
||||
sSetPropertyRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
BluetoothValue value(props);
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
|
||||
NS_LITERAL_STRING(KEY_ADAPTER), value);
|
||||
nsRefPtr<DistributeBluetoothSignalTask>
|
||||
t = new DistributeBluetoothSignalTask(signal);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(t))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
|
||||
// bluedroid BTU task was stored in the task queue, see GKI_send_msg
|
||||
if (!sSetPropertyRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sSetPropertyRunnableArray[0], BluetoothValue(true),
|
||||
EmptyString());
|
||||
sSetPropertyRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoteDevicePropertiesChangeCallback will be called, as the
|
||||
* following conditions:
|
||||
/**
|
||||
* RemoteDevicePropertiesCallback will be called, as the following conditions:
|
||||
* 1. When BT is turning on, bluedroid automatically execute this callback
|
||||
* 2. When get_remote_device_properties()
|
||||
*/
|
||||
static void
|
||||
RemoteDevicePropertiesChangeCallback(bt_status_t aStatus,
|
||||
bt_bdaddr_t *aBdAddress,
|
||||
int aNumProperties,
|
||||
bt_property_t *aProperties)
|
||||
RemoteDevicePropertiesCallback(bt_status_t aStatus, bt_bdaddr_t *aBdAddress,
|
||||
int aNumProperties, bt_property_t *aProperties)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
|
@ -429,6 +427,15 @@ RemoteDevicePropertiesChangeCallback(bt_status_t aStatus,
|
|||
}
|
||||
}
|
||||
|
||||
// Update to registered BluetoothDevice objects
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
|
||||
remoteDeviceBdAddress, props);
|
||||
nsRefPtr<DistributeBluetoothSignalTask>
|
||||
t = new DistributeBluetoothSignalTask(signal);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(t))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
|
||||
// Use address as the index
|
||||
sRemoteDevicesPack.AppendElement(
|
||||
BluetoothNamedValue(remoteDeviceBdAddress, props));
|
||||
|
@ -653,8 +660,8 @@ bt_callbacks_t sBluetoothCallbacks =
|
|||
{
|
||||
sizeof(sBluetoothCallbacks),
|
||||
AdapterStateChangeCallback,
|
||||
AdapterPropertiesChangeCallback,
|
||||
RemoteDevicePropertiesChangeCallback,
|
||||
AdapterPropertiesCallback,
|
||||
RemoteDevicePropertiesCallback,
|
||||
DeviceFoundCallback,
|
||||
DiscoveryStateChangedCallback,
|
||||
PinRequestCallback,
|
||||
|
|
Загрузка…
Ссылка в новой задаче