зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1026454 - Fire PropertyChanged when discovery state changes, r=echou
This commit is contained in:
Родитель
2ff03c0179
Коммит
5ba7d7443a
|
@ -166,8 +166,7 @@ BluetoothAdapter::BluetoothAdapter(nsPIDOMWindow* aWindow,
|
|||
, BluetoothPropertyContainer(BluetoothObjectType::TYPE_ADAPTER)
|
||||
, mJsUuids(nullptr)
|
||||
, mJsDeviceAddresses(nullptr)
|
||||
// TODO: Change to Disabled after Bug 1006309 landed
|
||||
, mState(BluetoothAdapterState::Enabled)
|
||||
, mState(BluetoothAdapterState::Disabled)
|
||||
, mDiscoverable(false)
|
||||
, mDiscovering(false)
|
||||
, mPairable(false)
|
||||
|
|
|
@ -68,7 +68,8 @@ extern bool gBluetoothDebugFlag;
|
|||
* and append it to the array.
|
||||
*/
|
||||
#define BT_APPEND_NAMED_VALUE(array, name, value) \
|
||||
array.AppendElement(BluetoothNamedValue(NS_LITERAL_STRING(name), value))
|
||||
array.AppendElement(BluetoothNamedValue(NS_LITERAL_STRING(name), \
|
||||
BluetoothValue(value)))
|
||||
|
||||
/**
|
||||
* Ensure success of system message broadcast with void return.
|
||||
|
|
|
@ -147,27 +147,28 @@ public:
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
/*
|
||||
* Cleanup static adapter properties and notify adapter to clean them
|
||||
*
|
||||
* TODO: clean up and notify Discovering also
|
||||
*/
|
||||
// Return error if BluetoothService is unavailable
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
||||
|
||||
// Cleanup static adapter properties and notify adapter.
|
||||
sAdapterBdAddress.Truncate();
|
||||
sAdapterBdName.Truncate();
|
||||
sAdapterDiscoverable = false;
|
||||
|
||||
InfallibleTArray<BluetoothNamedValue> props;
|
||||
BT_APPEND_NAMED_VALUE(props, "Name", sAdapterBdName);
|
||||
BT_APPEND_NAMED_VALUE(props, "Address", sAdapterBdAddress);
|
||||
BT_APPEND_NAMED_VALUE(props, "Discoverable",
|
||||
BluetoothValue(sAdapterDiscoverable));
|
||||
BluetoothValue value(props);
|
||||
if (sAdapterDiscoverable) {
|
||||
sAdapterDiscoverable = false;
|
||||
BT_APPEND_NAMED_VALUE(props, "Discoverable", false);
|
||||
}
|
||||
if (sAdapterDiscovering) {
|
||||
sAdapterDiscovering = false;
|
||||
BT_APPEND_NAMED_VALUE(props, "Discovering", false);
|
||||
}
|
||||
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
|
||||
NS_LITERAL_STRING(KEY_ADAPTER), value);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
||||
|
||||
NS_LITERAL_STRING(KEY_ADAPTER), props);
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF.
|
||||
|
@ -408,7 +409,7 @@ AdapterPropertiesCallback(bt_status_t aStatus, int aNumProperties,
|
|||
propertyValue = sAdapterBondedAddressArray;
|
||||
BT_APPEND_NAMED_VALUE(props, "Devices", propertyValue);
|
||||
} else if (p.type == BT_PROPERTY_UUIDS) {
|
||||
//FIXME: This will be implemented in the later patchset
|
||||
// FIXME: Later patchset will implement this.
|
||||
continue;
|
||||
} else {
|
||||
BT_LOGD("Unhandled adapter property type: %d", p.type);
|
||||
|
@ -577,6 +578,19 @@ public:
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Return error if BluetoothService is unavailable
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
||||
|
||||
// Fire PropertyChanged of Discovering
|
||||
InfallibleTArray<BluetoothNamedValue> props;
|
||||
BT_APPEND_NAMED_VALUE(props, "Discovering", sAdapterDiscovering);
|
||||
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
|
||||
NS_LITERAL_STRING(KEY_ADAPTER), props);
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reply that Promise is resolved
|
||||
if (!sChangeDiscoveryRunnableArray.IsEmpty()) {
|
||||
BluetoothValue values(true);
|
||||
DispatchBluetoothReply(sChangeDiscoveryRunnableArray[0],
|
||||
|
@ -949,17 +963,15 @@ BluetoothServiceBluedroid::GetAdaptersInternal(
|
|||
BluetoothValue properties = InfallibleTArray<BluetoothNamedValue>();
|
||||
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"State", BluetoothValue(sAdapterEnabled));
|
||||
"State", sAdapterEnabled);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Address", sAdapterBdAddress);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Name", sAdapterBdName);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Discoverable",
|
||||
BluetoothValue(sAdapterDiscoverable));
|
||||
"Discoverable", sAdapterDiscoverable);
|
||||
BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Discovering",
|
||||
BluetoothValue(sAdapterDiscovering));
|
||||
"Discovering", sAdapterDiscovering);
|
||||
|
||||
BT_APPEND_NAMED_VALUE(adaptersProperties.get_ArrayOfBluetoothNamedValue(),
|
||||
"Adapter", properties);
|
||||
|
|
|
@ -200,7 +200,7 @@ IsValidDtmf(const char aChar) {
|
|||
(aChar >= 'A' && aChar <= 'D');
|
||||
}
|
||||
|
||||
class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback
|
||||
class BluetoothHfpManager::GetVolumeTask MOZ_FINAL : public nsISettingsServiceCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
|
Загрузка…
Ссылка в новой задаче