mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1057337: Integrate helper runnables into A2DP and AVRCP notifications, r=shuang
The helper runnables where necessary to perform certain operations on the main thread after having received a callback from Bluedroid. The new notification methods already run on the main thread, so the helper runnables can be replaced by direct calls.
This commit is contained in:
parent
c047d2359d
commit
e94c49cdb6
@ -1352,9 +1352,8 @@ BluetoothA2dpManager::ConnectionStateNotification(BluetoothA2dpConnectionState a
|
||||
InfallibleTArray<BluetoothNamedValue> props;
|
||||
BT_APPEND_NAMED_VALUE(props, "State", a2dpState);
|
||||
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("AudioSink"),
|
||||
nsString(aBdAddr), props);
|
||||
NS_DispatchToMainThread(new SinkPropertyChangedHandler(signal));
|
||||
HandleSinkPropertyChanged(BluetoothSignal(NS_LITERAL_STRING("AudioSink"),
|
||||
nsString(aBdAddr), props));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1378,9 +1377,8 @@ BluetoothA2dpManager::AudioStateNotification(BluetoothA2dpAudioState aState,
|
||||
InfallibleTArray<BluetoothNamedValue> props;
|
||||
BT_APPEND_NAMED_VALUE(props, "State", a2dpState);
|
||||
|
||||
BluetoothSignal signal(NS_LITERAL_STRING("AudioSink"),
|
||||
nsString(aBdAddr), props);
|
||||
NS_DispatchToMainThread(new SinkPropertyChangedHandler(signal));
|
||||
HandleSinkPropertyChanged(BluetoothSignal(NS_LITERAL_STRING("AudioSink"),
|
||||
nsString(aBdAddr), props));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1392,7 +1390,15 @@ BluetoothA2dpManager::GetPlayStatusNotification()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_DispatchToMainThread(new RequestPlayStatusTask());
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
return;
|
||||
}
|
||||
|
||||
bs->DistributeSignal(
|
||||
BluetoothSignal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
|
||||
NS_LITERAL_STRING(KEY_ADAPTER),
|
||||
InfallibleTArray<BluetoothNamedValue>()));
|
||||
}
|
||||
|
||||
/* Player application settings is optional for AVRCP 1.3. B2G
|
||||
@ -1463,7 +1469,20 @@ BluetoothA2dpManager::GetElementAttrNotification(
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_DispatchToMainThread(new UpdateElementAttrsTask(aNumAttrs, aAttrs));
|
||||
nsAutoArrayPtr<BluetoothAvrcpElementAttribute> attrs(
|
||||
new BluetoothAvrcpElementAttribute[aNumAttrs]);
|
||||
|
||||
for (uint8_t i = 0; i < aNumAttrs; ++i) {
|
||||
attrs[i].mId = aAttrs[i];
|
||||
ConvertAttributeString(
|
||||
static_cast<BluetoothAvrcpMediaAttribute>(attrs[i].mId),
|
||||
attrs[i].mValue);
|
||||
}
|
||||
|
||||
#if ANDROID_VERSION >= 18
|
||||
MOZ_ASSERT(sBtAvrcpInterface);
|
||||
sBtAvrcpInterface->GetElementAttrRsp(aNumAttrs, attrs, nullptr);
|
||||
#endif // ANDROID_VERSION >= 18
|
||||
}
|
||||
|
||||
void
|
||||
@ -1472,7 +1491,14 @@ BluetoothA2dpManager::RegisterNotificationNotification(
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_DispatchToMainThread(new UpdateRegisterNotificationTask(aEvent, aParam));
|
||||
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
|
||||
if (!a2dp) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if ANDROID_VERSION >= 18
|
||||
a2dp->UpdateRegisterNotification(aEvent, aParam);
|
||||
#endif // ANDROID_VERSION >= 18
|
||||
}
|
||||
|
||||
/* This method is used to get CT features from the Feature Bit Mask. If
|
||||
@ -1531,7 +1557,8 @@ BluetoothA2dpManager::PassthroughCmdNotification(int aId, int aKeyState)
|
||||
return;
|
||||
}
|
||||
|
||||
NS_DispatchToMainThread(new UpdatePassthroughCmdTask(name));
|
||||
NS_NAMED_LITERAL_STRING(type, "media-button");
|
||||
BroadcastSystemMessage(type, BluetoothValue(name));
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(BluetoothA2dpManager, nsIObserver)
|
||||
|
Loading…
Reference in New Issue
Block a user