mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1164498: Remove |DispatchBluetoothReply| from |BluetoothServiceBluedroid|, r=btian
This patch replaces |DispatchBluetoothReply| in |BluetoothServiceBluedroid| by corresponding calls to |DispatchReplySuccess| or |DispatchReplyError|.
This commit is contained in:
parent
b4f2a0e204
commit
316101c3d0
@ -45,8 +45,6 @@
|
||||
#include "nsDataHashtable.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
|
||||
#define ENSURE_BLUETOOTH_IS_READY(runnable, result) \
|
||||
do { \
|
||||
if (!sBtInterface || !IsEnabled()) { \
|
||||
@ -65,6 +63,8 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
|
||||
#define ENSURE_GATT_MGR_IS_READY_VOID(gatt, runnable) \
|
||||
do { \
|
||||
if (!gatt) { \
|
||||
@ -594,24 +594,6 @@ BluetoothServiceBluedroid::GattClientWriteDescriptorValueInternal(
|
||||
}
|
||||
#else
|
||||
|
||||
#define ENSURE_BLUETOOTH_IS_READY(runnable, result) \
|
||||
do { \
|
||||
if (!sBtInterface || !IsEnabled()) { \
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth is not ready"); \
|
||||
DispatchBluetoothReply(runnable, BluetoothValue(), errorStr); \
|
||||
return result; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ENSURE_BLUETOOTH_IS_READY_VOID(runnable) \
|
||||
do { \
|
||||
if (!sBtInterface || !IsEnabled()) { \
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Bluetooth is not ready"); \
|
||||
DispatchBluetoothReply(runnable, BluetoothValue(), errorStr); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
// Audio: Major service class = 0x100 (Bit 21 is set)
|
||||
#define SET_AUDIO_BIT(cod) (cod |= 0x200000)
|
||||
// Rendering: Major service class = 0x20 (Bit 18 is set)
|
||||
@ -936,8 +918,7 @@ ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable,
|
||||
replyError.AppendLiteral(":BT_STATUS_FAIL");
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aBluetoothReplyRunnable, BluetoothValue(true),
|
||||
replyError);
|
||||
DispatchReplyError(aBluetoothReplyRunnable, replyError);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1057,7 +1038,7 @@ BluetoothServiceBluedroid::GetDefaultAdapterPathInternal(
|
||||
BT_APPEND_NAMED_VALUE(v.get_ArrayOfBluetoothNamedValue(),
|
||||
"Devices", sAdapterBondedAddressArray);
|
||||
|
||||
DispatchBluetoothReply(aRunnable, v, EmptyString());
|
||||
DispatchReplySuccess(aRunnable, v);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1098,8 +1079,7 @@ public:
|
||||
/* dispatch result after final pending operation */
|
||||
if (--sRequestedDeviceCountArray[0] == 0) {
|
||||
if (!sGetDeviceRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sGetDeviceRunnableArray[0],
|
||||
sRemoteDevicesPack, EmptyString());
|
||||
DispatchReplySuccess(sGetDeviceRunnableArray[0], sRemoteDevicesPack);
|
||||
sGetDeviceRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
|
||||
@ -1147,8 +1127,7 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
||||
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
|
||||
if (!profile) {
|
||||
InfallibleTArray<BluetoothNamedValue> emptyArr;
|
||||
DispatchBluetoothReply(aRunnable, emptyArr,
|
||||
NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE));
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1162,7 +1141,7 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
||||
int requestedDeviceCount = deviceAddresses.Length();
|
||||
if (requestedDeviceCount == 0) {
|
||||
InfallibleTArray<BluetoothNamedValue> emptyArr;
|
||||
DispatchBluetoothReply(aRunnable, emptyArr, EmptyString());
|
||||
DispatchReplySuccess(aRunnable, emptyArr);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
@ -1196,8 +1175,7 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
||||
#else
|
||||
int requestedDeviceCount = aDeviceAddress.Length();
|
||||
if (requestedDeviceCount == 0) {
|
||||
InfallibleTArray<BluetoothNamedValue> emptyArr;
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(emptyArr), EmptyString());
|
||||
DispatchReplySuccess(aRunnable, InfallibleTArray<BluetoothNamedValue>());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1233,7 +1211,7 @@ public:
|
||||
void StartDiscovery() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
DispatchBluetoothReply(mRunnable, true, EmptyString());
|
||||
DispatchReplySuccess(mRunnable);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
@ -1282,7 +1260,7 @@ public:
|
||||
void CancelDiscovery() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
DispatchBluetoothReply(mRunnable, true, EmptyString());
|
||||
DispatchReplySuccess(mRunnable);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
@ -1552,7 +1530,7 @@ public:
|
||||
|
||||
void PinReply() override
|
||||
{
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
DispatchReplySuccess(mRunnable);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
@ -1652,7 +1630,7 @@ public:
|
||||
|
||||
void SspReply() override
|
||||
{
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
DispatchReplySuccess(mRunnable);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
@ -1785,10 +1763,10 @@ BluetoothServiceBluedroid::IsConnected(const uint16_t aServiceUuid,
|
||||
BluetoothProfileManagerBase* profile =
|
||||
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
|
||||
if (profile) {
|
||||
DispatchBluetoothReply(aRunnable, profile->IsConnected(), EmptyString());
|
||||
DispatchReplySuccess(aRunnable, profile->IsConnected());
|
||||
} else {
|
||||
BT_WARNING("Can't find profile manager with uuid: %x", aServiceUuid);
|
||||
DispatchBluetoothReply(aRunnable, false, EmptyString());
|
||||
DispatchReplySuccess(aRunnable, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1806,7 +1784,6 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
|
||||
@ -1814,15 +1791,6 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
|
||||
errorStr.AssignLiteral("Calling SendFile() failed");
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1837,7 +1805,6 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
|
||||
@ -1845,15 +1812,6 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
|
||||
errorStr.AssignLiteral("Calling SendFile() failed");
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1867,7 +1825,6 @@ BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->StopSendingFile()) {
|
||||
@ -1876,15 +1833,6 @@ BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->StopSendingFile()) {
|
||||
errorStr.AssignLiteral("Calling StopSendingFile() failed");
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1899,7 +1847,6 @@ BluetoothServiceBluedroid::ConfirmReceivingFile(
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->ConfirmReceivingFile(aConfirm)) {
|
||||
@ -1909,15 +1856,6 @@ BluetoothServiceBluedroid::ConfirmReceivingFile(
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->ConfirmReceivingFile(aConfirm)) {
|
||||
errorStr.AssignLiteral("Calling ConfirmReceivingFile() failed");
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1925,7 +1863,6 @@ BluetoothServiceBluedroid::ConnectSco(BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
if (!hfp || !hfp->ConnectSco()) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("ConnectSco failed"));
|
||||
@ -1933,16 +1870,6 @@ BluetoothServiceBluedroid::ConnectSco(BluetoothReplyRunnable* aRunnable)
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
if (!hfp || !hfp->ConnectSco()) {
|
||||
NS_NAMED_LITERAL_STRING(replyError, "Calling ConnectSco() failed");
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1950,7 +1877,6 @@ BluetoothServiceBluedroid::DisconnectSco(BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
if (!hfp || !hfp->DisconnectSco()) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("DisconnectSco failed"));
|
||||
@ -1958,16 +1884,6 @@ BluetoothServiceBluedroid::DisconnectSco(BluetoothReplyRunnable* aRunnable)
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
if (!hfp || !hfp->DisconnectSco()) {
|
||||
NS_NAMED_LITERAL_STRING(replyError, "Calling DisconnectSco() failed");
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1975,7 +1891,6 @@ BluetoothServiceBluedroid::IsScoConnected(BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
if (!hfp) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("IsScoConnected failed"));
|
||||
@ -1983,16 +1898,6 @@ BluetoothServiceBluedroid::IsScoConnected(BluetoothReplyRunnable* aRunnable)
|
||||
}
|
||||
|
||||
DispatchReplySuccess(aRunnable, BluetoothValue(hfp->IsScoConnected()));
|
||||
#else
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
if (!hfp) {
|
||||
NS_NAMED_LITERAL_STRING(replyError, "Fail to get BluetoothHfpManager");
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchBluetoothReply(aRunnable, hfp->IsScoConnected(), EmptyString());
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -2009,11 +1914,7 @@ BluetoothServiceBluedroid::SendMetaData(const nsAString& aTitle,
|
||||
a2dp->UpdateMetaData(aTitle, aArtist, aAlbum, aMediaNumber,
|
||||
aTotalMediaCount, aDuration);
|
||||
}
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -2028,11 +1929,7 @@ BluetoothServiceBluedroid::SendPlayStatus(
|
||||
PlayStatusStringToControlPlayStatus(aPlayStatus);
|
||||
a2dp->UpdatePlayStatus(aDuration, aPosition, playStatus);
|
||||
}
|
||||
#ifdef MOZ_B2G_BT_API_V2
|
||||
DispatchReplySuccess(aRunnable);
|
||||
#else
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -2491,8 +2388,7 @@ BluetoothServiceBluedroid::AdapterPropertiesNotification(
|
||||
|
||||
// Send reply for SetProperty
|
||||
if (!sSetPropertyRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sSetPropertyRunnableArray[0],
|
||||
BluetoothValue(true), EmptyString());
|
||||
DispatchReplySuccess(sSetPropertyRunnableArray[0]);
|
||||
sSetPropertyRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
#endif
|
||||
@ -2699,8 +2595,7 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
|
||||
|
||||
if (--sRequestedDeviceCountArray[0] == 0) {
|
||||
if (!sGetDeviceRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sGetDeviceRunnableArray[0],
|
||||
sRemoteDevicesPack, EmptyString());
|
||||
DispatchReplySuccess(sGetDeviceRunnableArray[0], sRemoteDevicesPack);
|
||||
sGetDeviceRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
|
||||
@ -3066,13 +2961,11 @@ BluetoothServiceBluedroid::BondStateChangedNotification(
|
||||
BluetoothValue(propertiesChangeArray)));
|
||||
|
||||
if (bonded && !sBondingRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sBondingRunnableArray[0],
|
||||
BluetoothValue(true), EmptyString());
|
||||
DispatchReplySuccess(sBondingRunnableArray[0]);
|
||||
|
||||
sBondingRunnableArray.RemoveElementAt(0);
|
||||
} else if (!bonded && !sUnbondingRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sUnbondingRunnableArray[0],
|
||||
BluetoothValue(true), EmptyString());
|
||||
DispatchReplySuccess(sUnbondingRunnableArray[0]);
|
||||
|
||||
sUnbondingRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
@ -3098,9 +2991,8 @@ BluetoothServiceBluedroid::BondStateChangedNotification(
|
||||
BluetoothValue(propertiesArray)));
|
||||
|
||||
if (!sBondingRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sBondingRunnableArray[0],
|
||||
BluetoothValue(true),
|
||||
NS_LITERAL_STRING("Authentication failure"));
|
||||
DispatchReplyError(sBondingRunnableArray[0],
|
||||
NS_LITERAL_STRING("Authentication failure"));
|
||||
sBondingRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
break;
|
||||
@ -3109,9 +3001,8 @@ BluetoothServiceBluedroid::BondStateChangedNotification(
|
||||
BT_WARNING("Got an unhandled status of BondStateChangedCallback!");
|
||||
// Dispatch a reply to unblock the waiting status of pairing.
|
||||
if (!sBondingRunnableArray.IsEmpty()) {
|
||||
DispatchBluetoothReply(sBondingRunnableArray[0],
|
||||
BluetoothValue(true),
|
||||
NS_LITERAL_STRING("Internal failure"));
|
||||
DispatchReplyError(sBondingRunnableArray[0],
|
||||
NS_LITERAL_STRING("Internal failure"));
|
||||
sBondingRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user