mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1220121: Convert IPDL of Bluetooth Core API to |BluetoothAddress|, r=brsun
This commit is contained in:
parent
a95391e5e2
commit
6c9fb95dba
@ -1028,7 +1028,8 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -1044,17 +1045,10 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
||||
mGetDeviceRequests.AppendElement(request);
|
||||
|
||||
for (uint8_t i = 0; i < aDeviceAddress.Length(); i++) {
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress[i], address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Retrieve all properties of devices
|
||||
sBtInterface->GetRemoteDeviceProperties(address,
|
||||
new GetRemoteDevicePropertiesResultHandler(mGetDeviceRequests, address));
|
||||
sBtInterface->GetRemoteDeviceProperties(aDeviceAddress[i],
|
||||
new GetRemoteDevicePropertiesResultHandler(mGetDeviceRequests,
|
||||
aDeviceAddress[i]));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1100,7 +1094,7 @@ BluetoothServiceBluedroid::StartDiscoveryInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::FetchUuidsInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -1114,15 +1108,8 @@ BluetoothServiceBluedroid::FetchUuidsInternal(
|
||||
StopDiscoveryInternal(aRunnable);
|
||||
}
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mFetchUuidsRunnables.AppendElement(aRunnable);
|
||||
sBtInterface->GetRemoteServices(address,
|
||||
sBtInterface->GetRemoteServices(aDeviceAddress,
|
||||
new DispatchReplyErrorResultHandler(mFetchUuidsRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
@ -1358,22 +1345,15 @@ BluetoothServiceBluedroid::UpdateSdpRecords(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
||||
const nsAString& aDeviceAddress, int aTimeout,
|
||||
const BluetoothAddress& aDeviceAddress, int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mCreateBondRunnables.AppendElement(aRunnable);
|
||||
sBtInterface->CreateBond(address, TRANSPORT_AUTO,
|
||||
sBtInterface->CreateBond(aDeviceAddress, TRANSPORT_AUTO,
|
||||
new DispatchReplyErrorResultHandler(mCreateBondRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
@ -1381,21 +1361,14 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::RemoveDeviceInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mRemoveBondRunnables.AppendElement(aRunnable);
|
||||
sBtInterface->RemoveBond(address,
|
||||
sBtInterface->RemoveBond(aDeviceAddress,
|
||||
new DispatchReplyErrorResultHandler(mRemoveBondRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
@ -1425,34 +1398,27 @@ private:
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::PinReplyInternal(
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothPinCode pinCode;
|
||||
rv = StringToPinCode(aPinCode, pinCode);
|
||||
auto rv = StringToPinCode(aPinCode, pinCode);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->PinReply(address, aAccept, pinCode,
|
||||
sBtInterface->PinReply(aDeviceAddress, aAccept, pinCode,
|
||||
new PinReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
const BluetoothAddress& aDeviceAddress, const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
@ -1460,7 +1426,7 @@ BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPasskeyInternal(
|
||||
const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
@ -1490,27 +1456,20 @@ private:
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SspReplyInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->SspReply(address, aVariant, aAccept, 0 /* passkey */,
|
||||
sBtInterface->SspReply(aDeviceAddress, aVariant, aAccept, 0 /* passkey */,
|
||||
new SspReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress, bool aConfirm,
|
||||
const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
@ -1533,22 +1492,15 @@ BluetoothServiceBluedroid::NextBluetoothProfileController()
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConnectDisconnect(
|
||||
bool aConnect, const nsAString& aDeviceAddress,
|
||||
bool aConnect, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
uint16_t aServiceUuid, uint32_t aCod)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothProfileController* controller =
|
||||
new BluetoothProfileController(aConnect, address, aRunnable,
|
||||
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
@ -1564,7 +1516,7 @@ BluetoothServiceBluedroid::ConnectDisconnect(
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothServiceBluedroid::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
@ -1574,7 +1526,7 @@ BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::Disconnect(
|
||||
const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
ConnectDisconnect(false, aDeviceAddress, aRunnable, aServiceUuid);
|
||||
|
@ -50,11 +50,12 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
|
||||
@ -75,48 +76,48 @@ public:
|
||||
BluetoothProfileManagerBase* aManager);
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
@ -489,7 +490,7 @@ protected:
|
||||
const nsAString& aPlayStatus);
|
||||
|
||||
static void ConnectDisconnect(bool aConnect,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
uint16_t aServiceUuid, uint32_t aCod = 0);
|
||||
static void NextBluetoothProfileController();
|
||||
|
@ -2703,7 +2703,7 @@ class BluetoothArrayOfDevicePropertiesReplyHandler : public DBusReplyHandler
|
||||
{
|
||||
public:
|
||||
BluetoothArrayOfDevicePropertiesReplyHandler(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
const FilterFunc aFilterFunc, BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddresses(aDeviceAddresses)
|
||||
, mProcessedDeviceAddresses(0)
|
||||
@ -2772,8 +2772,11 @@ public:
|
||||
}
|
||||
|
||||
if (mFilterFunc(deviceProperties)) {
|
||||
nsString deviceAddressStr;
|
||||
AddressToString(mDeviceAddresses[i], deviceAddressStr);
|
||||
|
||||
mValues.get_ArrayOfBluetoothNamedValue().AppendElement(
|
||||
BluetoothNamedValue(mDeviceAddresses[i], deviceProperties));
|
||||
BluetoothNamedValue(deviceAddressStr, deviceProperties));
|
||||
}
|
||||
|
||||
ProcessRemainingDeviceAddresses();
|
||||
@ -2822,7 +2825,7 @@ protected:
|
||||
|
||||
private:
|
||||
nsString mObjectPath;
|
||||
const nsTArray<nsString> mDeviceAddresses;
|
||||
const nsTArray<BluetoothAddress> mDeviceAddresses;
|
||||
nsTArray<nsString>::size_type mProcessedDeviceAddresses;
|
||||
const FilterFunc mFilterFunc;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
@ -2868,7 +2871,8 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTArray<nsString> deviceAddresses;
|
||||
nsTArray<BluetoothAddress> deviceAddresses;
|
||||
|
||||
BluetoothProfileManagerBase* profile =
|
||||
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
|
||||
if (!profile) {
|
||||
@ -2880,11 +2884,7 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
||||
if (profile->IsConnected()) {
|
||||
BluetoothAddress address;
|
||||
profile->GetAddress(address);
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(address, addressStr);
|
||||
|
||||
deviceAddresses.AppendElement(addressStr);
|
||||
deviceAddresses.AppendElement(address);
|
||||
}
|
||||
|
||||
BluetoothArrayOfDevicePropertiesReplyHandler* handler =
|
||||
@ -2899,8 +2899,8 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -2921,7 +2921,7 @@ BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
return NS_OK;
|
||||
@ -3092,14 +3092,14 @@ BluetoothDBusService::SetProperty(BluetoothObjectType aType,
|
||||
class CreatePairedDeviceInternalTask : public Task
|
||||
{
|
||||
public:
|
||||
CreatePairedDeviceInternalTask(const nsACString& aDeviceAddress,
|
||||
CreatePairedDeviceInternalTask(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mTimeout(aTimeout)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
@ -3109,7 +3109,11 @@ public:
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
MOZ_ASSERT(!sAdapterPath.IsEmpty());
|
||||
|
||||
const char *deviceAddress = mDeviceAddress.get();
|
||||
nsString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
auto utf8DeviceAddressStr = NS_ConvertUTF16toUTF8(deviceAddressStr);
|
||||
|
||||
const char *deviceAddress = utf8DeviceAddressStr.get();
|
||||
const char *deviceAgentPath = KEY_REMOTE_AGENT;
|
||||
const char *capabilities = B2G_AGENT_CAPABILITIES;
|
||||
|
||||
@ -3145,20 +3149,20 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const nsCString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
int mTimeout;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::CreatePairedDeviceInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new CreatePairedDeviceInternalTask(
|
||||
NS_ConvertUTF16toUTF8(aDeviceAddress),
|
||||
aTimeout, aRunnable);
|
||||
Task* task = new CreatePairedDeviceInternalTask(aDeviceAddress,
|
||||
aTimeout,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
@ -3221,8 +3225,9 @@ private:
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::RemoveDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -3232,14 +3237,7 @@ BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(deviceAddress, aRunnable);
|
||||
Task* task = new RemoveDeviceTask(aDeviceAddress, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
@ -3310,7 +3308,7 @@ private:
|
||||
|
||||
void
|
||||
BluetoothDBusService::PinReplyInternal(
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
@ -3318,25 +3316,18 @@ BluetoothDBusService::PinReplyInternal(
|
||||
|
||||
void
|
||||
BluetoothDBusService::SspReplyInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPinCodeTask(deviceAddress,
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aPinCode),
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
@ -3406,17 +3397,12 @@ private:
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::SetPasskeyInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPasskeyTask(deviceAddress,
|
||||
Task* task = new SetPasskeyTask(aDeviceAddress,
|
||||
aPasskey,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
@ -3424,19 +3410,13 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(deviceAddress,
|
||||
Task* task = new SetPairingConfirmationTask(aDeviceAddress,
|
||||
aConfirm,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
@ -3457,22 +3437,15 @@ NextBluetoothProfileController()
|
||||
}
|
||||
|
||||
static void
|
||||
ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
|
||||
ConnectDisconnect(bool aConnect, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
uint16_t aServiceUuid, uint32_t aCod = 0)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothProfileController* controller =
|
||||
new BluetoothProfileController(aConnect, deviceAddress, aRunnable,
|
||||
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
@ -3488,7 +3461,7 @@ ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
@ -3497,7 +3470,7 @@ BluetoothDBusService::Connect(const nsAString& aDeviceAddress,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::Disconnect(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::Disconnect(const BluetoothAddress& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
@ -3542,16 +3515,13 @@ BluetoothDBusService::ToggleCalls(BluetoothReplyRunnable* aRunnable)
|
||||
class OnUpdateSdpRecordsRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OnUpdateSdpRecordsRunnable(const nsAString& aObjectPath,
|
||||
OnUpdateSdpRecordsRunnable(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
: mManager(aManager)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mManager(aManager)
|
||||
{
|
||||
MOZ_ASSERT(!aObjectPath.IsEmpty());
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
const nsString deviceAddressStr = GetAddressFromObjectPath(aObjectPath);
|
||||
|
||||
StringToAddress(deviceAddressStr, mDeviceAddress);
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mManager);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -3758,7 +3728,7 @@ public:
|
||||
// I choose to use raw pointer here because this is going to be passed as an
|
||||
// argument into SendWithReply() at once.
|
||||
OnUpdateSdpRecordsRunnable* callbackRunnable =
|
||||
new OnUpdateSdpRecordsRunnable(objectPath, mBluetoothProfileManager);
|
||||
new OnUpdateSdpRecordsRunnable(mDeviceAddress, mBluetoothProfileManager);
|
||||
|
||||
sDBusConnection->SendWithReply(DiscoverServicesCallback,
|
||||
(void*)callbackRunnable, -1,
|
||||
|
@ -59,11 +59,12 @@ public:
|
||||
uint16_t aServiceUuid, BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -87,46 +88,48 @@ public:
|
||||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -149,8 +149,9 @@ public:
|
||||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Returns the properties of connected devices regarding to specific profile,
|
||||
@ -169,7 +170,7 @@ public:
|
||||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
@ -213,12 +214,12 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
@ -241,13 +242,13 @@ public:
|
||||
BluetoothProfileManagerBase* aManager) = 0;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
@ -256,7 +257,7 @@ public:
|
||||
* Legacy method used by bluez only to reply pincode request.
|
||||
*/
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
@ -264,22 +265,24 @@ public:
|
||||
* Legacy method used by bluez only to reply passkey entry request.
|
||||
*/
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Legacy method used by bluez only to reply pairing confirmation request.
|
||||
*/
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress, uint32_t aCod, uint16_t aServiceUuid,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
|
@ -405,13 +405,24 @@ BluetoothAdapter::GetPairedDeviceProperties(
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
nsTArray<BluetoothAddress> deviceAddresses;
|
||||
deviceAddresses.SetLength(aDeviceAddresses.Length());
|
||||
|
||||
for (size_t i = 0; i < deviceAddresses.Length(); ++i) {
|
||||
auto rv = StringToAddress(aDeviceAddresses[i], deviceAddresses[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("GetPairedDeviceProperties failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<BluetoothVoidReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(nullptr);
|
||||
|
||||
nsresult rv =
|
||||
bs->GetPairedDevicePropertiesInternal(aDeviceAddresses, results);
|
||||
auto rv = bs->GetPairedDevicePropertiesInternal(deviceAddresses, results);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("GetPairedDeviceProperties failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -851,11 +862,13 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
|
||||
|
||||
/**
|
||||
* Ensure
|
||||
* - device address is not empty,
|
||||
* - device address is valid,
|
||||
* - adapter is already enabled, and
|
||||
* - BluetoothService is available.
|
||||
*/
|
||||
BT_ENSURE_TRUE_REJECT(!aDeviceAddress.IsEmpty(),
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(aDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
BT_ENSURE_TRUE_REJECT(mState == BluetoothAdapterState::Enabled,
|
||||
@ -867,10 +880,10 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
|
||||
nsresult rv;
|
||||
if (aPair) {
|
||||
rv = bs->CreatePairedDeviceInternal(
|
||||
aDeviceAddress, kCreatePairedDeviceTimeout,
|
||||
deviceAddress, kCreatePairedDeviceTimeout,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else {
|
||||
rv = bs->RemoveDeviceInternal(aDeviceAddress,
|
||||
rv = bs->RemoveDeviceInternal(deviceAddress,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
}
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv), promise, NS_ERROR_DOM_OPERATION_ERR);
|
||||
@ -1660,6 +1673,12 @@ BluetoothAdapter::Connect(BluetoothDevice& aDevice,
|
||||
|
||||
nsAutoString address;
|
||||
aDevice.GetAddress(address);
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(address, deviceAddress))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t deviceClass = aDevice.Cod()->ToUint32();
|
||||
uint16_t serviceUuid = 0;
|
||||
if (aServiceUuid.WasPassed()) {
|
||||
@ -1671,7 +1690,7 @@ BluetoothAdapter::Connect(BluetoothDevice& aDevice,
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->Connect(address, deviceClass, serviceUuid, results);
|
||||
bs->Connect(deviceAddress, deviceClass, serviceUuid, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
@ -1693,6 +1712,12 @@ BluetoothAdapter::Disconnect(BluetoothDevice& aDevice,
|
||||
|
||||
nsAutoString address;
|
||||
aDevice.GetAddress(address);
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(address, deviceAddress))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint16_t serviceUuid = 0;
|
||||
if (aServiceUuid.WasPassed()) {
|
||||
serviceUuid = aServiceUuid.Value();
|
||||
@ -1703,7 +1728,7 @@ BluetoothAdapter::Disconnect(BluetoothDevice& aDevice,
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->Disconnect(address, serviceUuid, results);
|
||||
bs->Disconnect(deviceAddress, serviceUuid, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -187,10 +187,13 @@ BluetoothDevice::FetchUuids(ErrorResult& aRv)
|
||||
// Ensure BluetoothService is available
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(
|
||||
bs->FetchUuidsInternal(mAddress, new FetchUuidsTask(promise, this))),
|
||||
bs->FetchUuidsInternal(address, new FetchUuidsTask(promise, this))),
|
||||
promise, NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
return promise.forget();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "BluetoothPairingHandle.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothUtils.h"
|
||||
|
||||
#include "mozilla/dom/BluetoothPairingHandleBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
@ -79,10 +80,16 @@ BluetoothPairingHandle::SetPinCode(const nsAString& aPinCode, ErrorResult& aRv)
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->PinReplyInternal(mDeviceAddress, true /* accept */, aPinCode,
|
||||
bs->PinReplyInternal(deviceAddress, true /* accept */, aPinCode,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
@ -108,12 +115,18 @@ BluetoothPairingHandle::Accept(ErrorResult& aRv)
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothSspVariant variant;
|
||||
BT_ENSURE_TRUE_REJECT(GetSspVariant(variant),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->SspReplyInternal(mDeviceAddress, variant, true /* aAccept */,
|
||||
bs->SspReplyInternal(deviceAddress, variant, true /* aAccept */,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
@ -131,11 +144,17 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv)
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
if (mType.EqualsLiteral(PAIRING_REQ_TYPE_ENTERPINCODE)) { // Pin request
|
||||
bs->PinReplyInternal(mDeviceAddress, false /* aAccept */, EmptyString(),
|
||||
bs->PinReplyInternal(deviceAddress, false /* aAccept */, EmptyString(),
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else { // Ssp request
|
||||
BluetoothSspVariant variant;
|
||||
@ -143,7 +162,7 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv)
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->SspReplyInternal(mDeviceAddress, variant, false /* aAccept */,
|
||||
bs->SspReplyInternal(deviceAddress, variant, false /* aAccept */,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TSetPinCodeRequest);
|
||||
|
||||
mService->SetPinCodeInternal(aRequest.path(),
|
||||
mService->SetPinCodeInternal(aRequest.address(),
|
||||
aRequest.pincode(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
@ -612,7 +612,7 @@ BluetoothRequestParent::DoRequest(const SetPasskeyRequest& aRequest)
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TSetPasskeyRequest);
|
||||
|
||||
mService->SetPasskeyInternal(aRequest.path(),
|
||||
mService->SetPasskeyInternal(aRequest.address(),
|
||||
aRequest.passkey(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
@ -626,7 +626,7 @@ BluetoothRequestParent::DoRequest(const ConfirmPairingConfirmationRequest&
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TConfirmPairingConfirmationRequest);
|
||||
|
||||
mService->SetPairingConfirmationInternal(aRequest.path(),
|
||||
mService->SetPairingConfirmationInternal(aRequest.address(),
|
||||
true,
|
||||
mReplyRunnable.get());
|
||||
|
||||
@ -640,7 +640,7 @@ BluetoothRequestParent::DoRequest(const DenyPairingConfirmationRequest&
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TDenyPairingConfirmationRequest);
|
||||
|
||||
mService->SetPairingConfirmationInternal(aRequest.path(),
|
||||
mService->SetPairingConfirmationInternal(aRequest.address(),
|
||||
false,
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -129,8 +129,8 @@ BluetoothServiceChildProcess::GetConnectedDevicePropertiesInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
PairedDevicePropertiesRequest request;
|
||||
request.addresses().AppendElements(aDeviceAddresses);
|
||||
@ -141,9 +141,9 @@ BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::FetchUuidsInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, FetchUuidsRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, FetchUuidsRequest(aDeviceAddress));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -188,22 +188,18 @@ BluetoothServiceChildProcess::SetProperty(BluetoothObjectType aType,
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::CreatePairedDeviceInternal(
|
||||
const nsAString& aAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
PairRequest(nsString(aAddress), aTimeout));
|
||||
SendRequest(aRunnable, PairRequest(aDeviceAddress, aTimeout));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::RemoveDeviceInternal(
|
||||
const nsAString& aObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
UnpairRequest(nsString(aObjectPath)));
|
||||
SendRequest(aRunnable, UnpairRequest(aDeviceAddress));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -224,82 +220,72 @@ BluetoothServiceChildProcess::UpdateSdpRecords(const BluetoothAddress& aDeviceAd
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::PinReplyInternal(
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
PinReplyRequest(nsString(aDeviceAddress),
|
||||
PinReplyRequest(aDeviceAddress,
|
||||
aAccept,
|
||||
nsString(aPinCode)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SspReplyInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant, bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SspReplyRequest(nsString(aDeviceAddress),
|
||||
aVariant,
|
||||
aAccept));
|
||||
SendRequest(aRunnable, SspReplyRequest(aDeviceAddress, aVariant, aAccept));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPinCodeInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SetPinCodeRequest(nsString(aDeviceAddress), nsString(aPinCode)));
|
||||
SetPinCodeRequest(aDeviceAddress, nsString(aPinCode)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPasskeyInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SetPasskeyRequest(nsString(aDeviceAddress), aPasskey));
|
||||
SendRequest(aRunnable, SetPasskeyRequest(aDeviceAddress, aPasskey));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
if(aConfirm) {
|
||||
SendRequest(aRunnable,
|
||||
ConfirmPairingConfirmationRequest(nsString(aDeviceAddress)));
|
||||
if (aConfirm) {
|
||||
SendRequest(aRunnable, ConfirmPairingConfirmationRequest(aDeviceAddress));
|
||||
} else {
|
||||
SendRequest(aRunnable,
|
||||
DenyPairingConfirmationRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, DenyPairingConfirmationRequest(aDeviceAddress));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::Connect(
|
||||
const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
ConnectRequest(nsString(aDeviceAddress),
|
||||
aCod,
|
||||
aServiceUuid));
|
||||
SendRequest(aRunnable, ConnectRequest(aDeviceAddress, aCod, aServiceUuid));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::Disconnect(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
DisconnectRequest(nsString(aDeviceAddress), aServiceUuid));
|
||||
SendRequest(aRunnable, DisconnectRequest(aDeviceAddress, aServiceUuid));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
StopInternal(BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
|
||||
@ -50,7 +50,7 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -73,12 +73,12 @@ public:
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
@ -91,41 +91,41 @@ public:
|
||||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
|
@ -12,7 +12,10 @@ include BluetoothTypes;
|
||||
|
||||
include "mozilla/dom/bluetooth/ipc/BluetoothMessageUtils.h";
|
||||
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothAddress
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -42,7 +45,7 @@ struct SetPropertyRequest
|
||||
struct GetPropertyRequest
|
||||
{
|
||||
BluetoothObjectType type;
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct StartDiscoveryRequest
|
||||
@ -65,54 +68,54 @@ struct StopLeScanRequest
|
||||
|
||||
struct PairRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint32_t timeoutMS;
|
||||
};
|
||||
|
||||
struct UnpairRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct PinReplyRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
bool accept;
|
||||
nsString pinCode;
|
||||
};
|
||||
|
||||
struct SspReplyRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
BluetoothSspVariant variant;
|
||||
bool accept;
|
||||
};
|
||||
|
||||
struct SetPinCodeRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
nsString pincode;
|
||||
};
|
||||
|
||||
struct SetPasskeyRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
uint32_t passkey;
|
||||
};
|
||||
|
||||
struct ConfirmPairingConfirmationRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct DenyPairingConfirmationRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct PairedDevicePropertiesRequest
|
||||
{
|
||||
nsString[] addresses;
|
||||
BluetoothAddress[] addresses;
|
||||
};
|
||||
|
||||
struct ConnectedDevicePropertiesRequest
|
||||
@ -122,19 +125,19 @@ struct ConnectedDevicePropertiesRequest
|
||||
|
||||
struct FetchUuidsRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct ConnectRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint32_t cod;
|
||||
uint16_t serviceUuid;
|
||||
};
|
||||
|
||||
struct DisconnectRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint16_t serviceUuid;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user