mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 910974 - Patch 1: Dispatch events when remote device queries current play status, r=echou, sr=mrbkap
This commit is contained in:
parent
c5c1f4d7b6
commit
ab94506215
@ -773,6 +773,7 @@ GK_ATOM(onremoteheld, "onremoteheld")
|
||||
GK_ATOM(onremoteresumed, "onremoteresumed")
|
||||
GK_ATOM(onretrieving, "onretrieving")
|
||||
GK_ATOM(onRequest, "onRequest")
|
||||
GK_ATOM(onrequestmediaplaystatus, "onrequestmediaplaystatus")
|
||||
GK_ATOM(onreset, "onreset")
|
||||
GK_ATOM(onresuming, "onresuming")
|
||||
GK_ATOM(onMozBeforeResize, "onMozBeforeResize")
|
||||
|
@ -346,6 +346,15 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
|
||||
e->InitBluetoothStatusChangedEvent(aData.name(), false, false,
|
||||
address, status);
|
||||
DispatchTrustedEvent(event);
|
||||
} else if (aData.name().EqualsLiteral(REQUEST_MEDIA_PLAYSTATUS_ID)) {
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv = NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
rv = event->InitEvent(aData.name(), false, false);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
DispatchTrustedEvent(event);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
nsCString warningMsg;
|
||||
|
@ -144,6 +144,7 @@ public:
|
||||
IMPL_EVENT_HANDLER(a2dpstatuschanged);
|
||||
IMPL_EVENT_HANDLER(hfpstatuschanged);
|
||||
IMPL_EVENT_HANDLER(pairedstatuschanged);
|
||||
IMPL_EVENT_HANDLER(requestmediaplaystatus);
|
||||
IMPL_EVENT_HANDLER(scostatuschanged);
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
|
@ -62,18 +62,24 @@ extern bool gBluetoothDebugFlag;
|
||||
|
||||
/**
|
||||
* When the connection status of a Bluetooth profile is changed, we'll
|
||||
* distribute one of the following events.
|
||||
* dispatch one of the following events.
|
||||
*/
|
||||
#define A2DP_STATUS_CHANGED_ID "a2dpstatuschanged"
|
||||
#define HFP_STATUS_CHANGED_ID "hfpstatuschanged"
|
||||
#define SCO_STATUS_CHANGED_ID "scostatuschanged"
|
||||
|
||||
/**
|
||||
* When the pair status of a Bluetooth device is changed, we'll distribute an
|
||||
* When the pair status of a Bluetooth device is changed, we'll dispatch an
|
||||
* event.
|
||||
*/
|
||||
#define PAIRED_STATUS_CHANGED_ID "pairedstatuschanged"
|
||||
|
||||
/**
|
||||
* When receiving a query about current play status from remote device, we'll
|
||||
* dispatch an event.
|
||||
*/
|
||||
#define REQUEST_MEDIA_PLAYSTATUS_ID "requestmediaplaystatus"
|
||||
|
||||
// Bluetooth address format: xx:xx:xx:xx:xx:xx (or xx_xx_xx_xx_xx_xx)
|
||||
#define BLUETOOTH_ADDRESS_LENGTH 17
|
||||
#define BLUETOOTH_ADDRESS_NONE "00:00:00:00:00:00"
|
||||
|
@ -1298,10 +1298,10 @@ private:
|
||||
nsString mAdapterPath;
|
||||
};
|
||||
|
||||
class SendPlayStatusTask : public nsRunnable
|
||||
class RequestPlayStatusTask : public nsRunnable
|
||||
{
|
||||
public:
|
||||
SendPlayStatusTask()
|
||||
RequestPlayStatusTask()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
}
|
||||
@ -1310,15 +1310,14 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE(a2dp, NS_ERROR_FAILURE);
|
||||
BluetoothSignal signal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
|
||||
NS_LITERAL_STRING(KEY_ADAPTER),
|
||||
InfallibleTArray<BluetoothNamedValue>());
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
bs->UpdatePlayStatus(a2dp->GetDuration(),
|
||||
a2dp->GetPosition(),
|
||||
a2dp->GetPlayStatus());
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
@ -1533,7 +1532,7 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData)
|
||||
sSinkProperties,
|
||||
ArrayLength(sSinkProperties));
|
||||
} else if (dbus_message_is_signal(aMsg, DBUS_CTL_IFACE, "GetPlayStatus")) {
|
||||
NS_DispatchToMainThread(new SendPlayStatusTask());
|
||||
NS_DispatchToMainThread(new RequestPlayStatusTask());
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
} else if (dbus_message_is_signal(aMsg, DBUS_CTL_IFACE, "PropertyChanged")) {
|
||||
ParsePropertyChange(aMsg,
|
||||
|
@ -67,6 +67,10 @@ interface BluetoothAdapter : EventTarget {
|
||||
[SetterThrows]
|
||||
attribute EventHandler onscostatuschanged;
|
||||
|
||||
// Fired when remote devices query current media play status
|
||||
[SetterThrows]
|
||||
attribute EventHandler onrequestmediaplaystatus;
|
||||
|
||||
[Creator, Throws]
|
||||
DOMRequest setName(DOMString name);
|
||||
[Creator, Throws]
|
||||
|
Loading…
Reference in New Issue
Block a user