Backed out changeset a471c7c73409 (bug 1036234) for build bustage on A CLOSED TREE

This commit is contained in:
Nigel Babu 2014-08-12 09:00:08 +05:30
parent 54c0424a9f
commit da90530683
6 changed files with 16 additions and 132 deletions

View File

@ -706,8 +706,6 @@ GK_ATOM(ondeleted, "ondeleted")
GK_ATOM(ondeliverysuccess, "ondeliverysuccess") GK_ATOM(ondeliverysuccess, "ondeliverysuccess")
GK_ATOM(ondeliveryerror, "ondeliveryerror") GK_ATOM(ondeliveryerror, "ondeliveryerror")
GK_ATOM(ondevicefound, "ondevicefound") GK_ATOM(ondevicefound, "ondevicefound")
GK_ATOM(ondevicepaired, "ondevicepaired")
GK_ATOM(ondeviceunpaired, "ondeviceunpaired")
GK_ATOM(ondialing, "ondialing") GK_ATOM(ondialing, "ondialing")
GK_ATOM(ondisabled, "ondisabled") GK_ATOM(ondisabled, "ondisabled")
GK_ATOM(ondischargingtimechange, "ondischargingtimechange") GK_ATOM(ondischargingtimechange, "ondischargingtimechange")
@ -801,6 +799,7 @@ GK_ATOM(onoverflowchanged, "onoverflowchanged")
GK_ATOM(onpagehide, "onpagehide") GK_ATOM(onpagehide, "onpagehide")
GK_ATOM(onpageshow, "onpageshow") GK_ATOM(onpageshow, "onpageshow")
GK_ATOM(onpaint, "onpaint") GK_ATOM(onpaint, "onpaint")
GK_ATOM(onpairedstatuschanged, "onpairedstatuschanged")
GK_ATOM(onpairingconfirmationreq, "onpairingconfirmationreq") GK_ATOM(onpairingconfirmationreq, "onpairingconfirmationreq")
GK_ATOM(onpairingconsentreq, "onpairingconsentreq") GK_ATOM(onpairingconsentreq, "onpairingconsentreq")
GK_ATOM(onpaste, "onpaste") GK_ATOM(onpaste, "onpaste")

View File

@ -299,7 +299,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
BT_APPEND_NAMED_VALUE(props, "Address", pairedDeviceAddresses[i]); BT_APPEND_NAMED_VALUE(props, "Address", pairedDeviceAddresses[i]);
BT_APPEND_NAMED_VALUE(props, "Paired", true); BT_APPEND_NAMED_VALUE(props, "Paired", true);
// Create paired device with 'address' and 'paired' attributes // Create paired device with address and paired attributes
nsRefPtr<BluetoothDevice> pairedDevice = nsRefPtr<BluetoothDevice> pairedDevice =
BluetoothDevice::Create(GetOwner(), BluetoothValue(props)); BluetoothDevice::Create(GetOwner(), BluetoothValue(props));
@ -351,11 +351,8 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
} }
} else if (aData.name().EqualsLiteral("PairingRequest")) { } else if (aData.name().EqualsLiteral("PairingRequest")) {
HandlePairingRequest(v); HandlePairingRequest(v);
} else if (aData.name().EqualsLiteral(DEVICE_PAIRED_ID)) { } else if (aData.name().EqualsLiteral(PAIRED_STATUS_CHANGED_ID) ||
HandleDevicePaired(aData.value()); aData.name().EqualsLiteral(HFP_STATUS_CHANGED_ID) ||
} else if (aData.name().EqualsLiteral(DEVICE_UNPAIRED_ID)) {
HandleDeviceUnpaired(aData.value());
} else if (aData.name().EqualsLiteral(HFP_STATUS_CHANGED_ID) ||
aData.name().EqualsLiteral(SCO_STATUS_CHANGED_ID) || aData.name().EqualsLiteral(SCO_STATUS_CHANGED_ID) ||
aData.name().EqualsLiteral(A2DP_STATUS_CHANGED_ID)) { aData.name().EqualsLiteral(A2DP_STATUS_CHANGED_ID)) {
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue); MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
@ -701,7 +698,7 @@ BluetoothAdapter::EnableDisable(bool aEnable, ErrorResult& aRv)
promise, promise,
methodName); methodName);
if (NS_FAILED(bs->EnableDisable(aEnable, result))) { if(NS_FAILED(bs->EnableDisable(aEnable, result))) {
// Restore mState and notify applications of adapter state change // Restore mState and notify applications of adapter state change
mState = aEnable ? BluetoothAdapterState::Disabled mState = aEnable ? BluetoothAdapterState::Disabled
: BluetoothAdapterState::Enabled; : BluetoothAdapterState::Enabled;
@ -895,79 +892,6 @@ BluetoothAdapter::DispatchAttributeEvent(const nsTArray<nsString>& aTypes)
DispatchTrustedEvent(event); DispatchTrustedEvent(event);
} }
void
BluetoothAdapter::HandleDevicePaired(const BluetoothValue& aValue)
{
MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
if (mState != BluetoothAdapterState::Enabled) {
BT_WARNING("HandleDevicePaired() is called when adapter isn't enabled.");
return;
}
// Create paired device with 'address' and 'paired' attributes
nsRefPtr<BluetoothDevice> pairedDevice =
BluetoothDevice::Create(GetOwner(), aValue);
size_t index = mDevices.IndexOf(pairedDevice,
0, /* aStart */
BluetoothDeviceComparator());
if (index != mDevices.NoIndex) {
pairedDevice = mDevices[index];
} else {
mDevices.AppendElement(pairedDevice);
}
// Notify application of paired device
BluetoothDeviceEventInit init;
init.mDevice = pairedDevice.
DispatchDeviceEvent(NS_LITERAL_STRING("devicepaired"), init);
}
void
BluetoothAdapter::HandleDeviceUnpaired(const BluetoothValue& aValue)
{
MOZ_ASSERT(aValue.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
if (mState != BluetoothAdapterState::Enabled) {
BT_WARNING("HandleDeviceUnpaired() is called when adapter isn't enabled.");
return;
}
// Create unpaired device with 'address' and 'paired' attributes
nsRefPtr<BluetoothDevice> unpairedDevice =
BluetoothDevice::Create(GetOwner(), aValue);
size_t index = mDevices.IndexOf(unpairedDevice,
0, /* aStart */
BluetoothDeviceComparator());
nsString deviceAddress;
if (index != mDevices.NoIndex) {
mDevices[index]->GetAddress(deviceAddress);
mDevices.RemoveElementAt(index);
} else {
unpairedDevice->GetAddress(deviceAddress);
}
// Notify application of unpaired device
BluetoothDeviceEventInit init;
init.mAddress = deviceAddress;
DispatchDeviceEvent(NS_LITERAL_STRING("deviceunpaired"), init);
}
void
BluetoothAdapter::DispatchDeviceEvent(const nsAString& aType,
const BluetoothDeviceEventInit& aInit)
{
BT_API2_LOGR("aType (%s)", NS_ConvertUTF16toUTF8(aType).get());
nsRefPtr<BluetoothDeviceEvent> event =
BluetoothDeviceEvent::Constructor(this, aType, aInit);
DispatchTrustedEvent(event);
}
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>
BluetoothAdapter::Connect(BluetoothDevice& aDevice, BluetoothAdapter::Connect(BluetoothDevice& aDevice,
const Optional<short unsigned int>& aServiceUuid, const Optional<short unsigned int>& aServiceUuid,

View File

@ -10,7 +10,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/BluetoothAdapter2Binding.h" #include "mozilla/dom/BluetoothAdapter2Binding.h"
#include "mozilla/dom/BluetoothDeviceEvent.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "BluetoothCommon.h" #include "BluetoothCommon.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -150,11 +149,10 @@ public:
IMPL_EVENT_HANDLER(a2dpstatuschanged); IMPL_EVENT_HANDLER(a2dpstatuschanged);
IMPL_EVENT_HANDLER(hfpstatuschanged); IMPL_EVENT_HANDLER(hfpstatuschanged);
IMPL_EVENT_HANDLER(pairedstatuschanged);
IMPL_EVENT_HANDLER(requestmediaplaystatus); IMPL_EVENT_HANDLER(requestmediaplaystatus);
IMPL_EVENT_HANDLER(scostatuschanged); IMPL_EVENT_HANDLER(scostatuschanged);
IMPL_EVENT_HANDLER(attributechanged); IMPL_EVENT_HANDLER(attributechanged);
IMPL_EVENT_HANDLER(devicepaired);
IMPL_EVENT_HANDLER(deviceunpaired);
nsPIDOMWindow* GetParentObject() const nsPIDOMWindow* GetParentObject() const
{ {
@ -184,36 +182,6 @@ private:
void HandleDeviceFound(const BluetoothValue& aValue); void HandleDeviceFound(const BluetoothValue& aValue);
void HandlePairingRequest(const BluetoothValue& aValue); void HandlePairingRequest(const BluetoothValue& aValue);
/**
* Handle DEVICE_PAIRED_ID bluetooth signal.
*
* @param aValue [in] Properties array of the paired device.
* The array should contain two properties:
* - nsString 'Address'
* - bool 'Paired'
*/
void HandleDevicePaired(const BluetoothValue& aValue);
/**
* Handle DEVICE_UNPAIRED_ID bluetooth signal.
*
* @param aValue [in] Properties array of the unpaired device.
* The array should contain two properties:
* - nsString 'Address'
* - bool 'Paired'
*/
void HandleDeviceUnpaired(const BluetoothValue& aValue);
/**
* Fire BluetoothDeviceEvent to trigger
* ondeviceparied/ondeviceunpaired event handler.
*
* @param aType [in] Event type to fire
* @param aInit [in] Event initialization value
*/
void DispatchDeviceEvent(const nsAString& aType,
const BluetoothDeviceEventInit& aInit);
/** /**
* mDevices holds references of all created device objects. * mDevices holds references of all created device objects.
* It is an empty array when the adapter state is disabled. * It is an empty array when the adapter state is disabled.

View File

@ -158,11 +158,10 @@ extern bool gBluetoothDebugFlag;
#define PAIRING_REQ_TYPE_CONSENT "pairingconsentreq" #define PAIRING_REQ_TYPE_CONSENT "pairingconsentreq"
/** /**
* When a remote device gets paired / unpaired with local bluetooth adapter, * When the pair status of a Bluetooth device is changed, we'll dispatch an
* we'll dispatch an event. * event.
*/ */
#define DEVICE_PAIRED_ID "devicepaired" #define PAIRED_STATUS_CHANGED_ID "pairedstatuschanged"
#define DEVICE_UNPAIRED_ID "deviceunpaired"
/** /**
* When receiving a query about current play status from remote device, we'll * When receiving a query about current play status from remote device, we'll

View File

@ -762,14 +762,11 @@ BondStateChangedCallback(bt_status_t aStatus, bt_bdaddr_t* aRemoteBdAddress,
props.Clear(); props.Clear();
// Append signal properties and notify adapter. // Update bonding status to BluetoothAdapter
BT_APPEND_NAMED_VALUE(props, "Address", remoteBdAddress); BT_APPEND_NAMED_VALUE(props, "address", remoteBdAddress);
BT_APPEND_NAMED_VALUE(props, "Paired", bonded); BT_APPEND_NAMED_VALUE(props, "status", bonded);
nsString signalName = bonded ? NS_LITERAL_STRING(DEVICE_PAIRED_ID) BluetoothSignal adapterSignal(NS_LITERAL_STRING(PAIRED_STATUS_CHANGED_ID),
: NS_LITERAL_STRING(DEVICE_UNPAIRED_ID);
BluetoothSignal adapterSignal(signalName,
NS_LITERAL_STRING(KEY_ADAPTER), NS_LITERAL_STRING(KEY_ADAPTER),
BluetoothValue(props)); BluetoothValue(props));
NS_DispatchToMainThread(new DistributeBluetoothSignalTask(adapterSignal)); NS_DispatchToMainThread(new DistributeBluetoothSignalTask(adapterSignal));

View File

@ -61,6 +61,9 @@ interface BluetoothAdapter : EventTarget {
[AvailableIn=CertifiedApps] [AvailableIn=CertifiedApps]
readonly attribute BluetoothPairingListener pairingReqs; readonly attribute BluetoothPairingListener pairingReqs;
// Fired when pairing process is completed
attribute EventHandler onpairedstatuschanged;
// Fired when a2dp connection status changed // Fired when a2dp connection status changed
attribute EventHandler ona2dpstatuschanged; attribute EventHandler ona2dpstatuschanged;
@ -76,12 +79,6 @@ interface BluetoothAdapter : EventTarget {
// Fired when attributes of BluetoothAdapter changed // Fired when attributes of BluetoothAdapter changed
attribute EventHandler onattributechanged; attribute EventHandler onattributechanged;
// Fired when a remote device gets paired with the adapter.
attribute EventHandler ondevicepaired;
// Fired when a remote device gets unpaired from the adapter.
attribute EventHandler ondeviceunpaired;
/** /**
* Enable/Disable a local bluetooth adapter by asynchronus methods and return * Enable/Disable a local bluetooth adapter by asynchronus methods and return
* its result through a Promise. * its result through a Promise.