зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 31a5c454f6fc (bug 1220121)
This commit is contained in:
Родитель
4b689b06f4
Коммит
f603f4b528
|
@ -1028,8 +1028,7 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<nsString>& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -1045,10 +1044,17 @@ 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(aDeviceAddress[i],
|
||||
new GetRemoteDevicePropertiesResultHandler(mGetDeviceRequests,
|
||||
aDeviceAddress[i]));
|
||||
sBtInterface->GetRemoteDeviceProperties(address,
|
||||
new GetRemoteDevicePropertiesResultHandler(mGetDeviceRequests, address));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1094,7 +1100,7 @@ BluetoothServiceBluedroid::StartDiscoveryInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::FetchUuidsInternal(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -1108,8 +1114,15 @@ 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(aDeviceAddress,
|
||||
sBtInterface->GetRemoteServices(address,
|
||||
new DispatchReplyErrorResultHandler(mFetchUuidsRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1345,15 +1358,22 @@ BluetoothServiceBluedroid::UpdateSdpRecords(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress, int aTimeout,
|
||||
const nsAString& 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(aDeviceAddress, TRANSPORT_AUTO,
|
||||
sBtInterface->CreateBond(address, TRANSPORT_AUTO,
|
||||
new DispatchReplyErrorResultHandler(mCreateBondRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1361,14 +1381,21 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::RemoveDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& 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(aDeviceAddress,
|
||||
sBtInterface->RemoveBond(address,
|
||||
new DispatchReplyErrorResultHandler(mRemoveBondRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1398,27 +1425,34 @@ private:
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::PinReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothPinCode pinCode;
|
||||
auto rv = StringToPinCode(aPinCode, pinCode);
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->PinReply(aDeviceAddress, aAccept, pinCode,
|
||||
BluetoothPinCode pinCode;
|
||||
rv = StringToPinCode(aPinCode, pinCode);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->PinReply(address, aAccept, pinCode,
|
||||
new PinReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
const BluetoothAddress& aDeviceAddress, const nsAString& aPinCode,
|
||||
const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
@ -1426,7 +1460,7 @@ BluetoothServiceBluedroid::SetPinCodeInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPasskeyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
@ -1456,20 +1490,27 @@ private:
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::SspReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
sBtInterface->SspReply(aDeviceAddress, aVariant, aAccept, 0 /* passkey */,
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->SspReply(address, aVariant, aAccept, 0 /* passkey */,
|
||||
new SspReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPairingConfirmationInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
const nsAString& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
@ -1492,15 +1533,22 @@ BluetoothServiceBluedroid::NextBluetoothProfileController()
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConnectDisconnect(
|
||||
bool aConnect, const BluetoothAddress& aDeviceAddress,
|
||||
bool aConnect, const nsAString& 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, aDeviceAddress, aRunnable,
|
||||
new BluetoothProfileController(aConnect, address, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
|
@ -1516,7 +1564,7 @@ BluetoothServiceBluedroid::ConnectDisconnect(
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -1526,7 +1574,7 @@ BluetoothServiceBluedroid::Connect(const BluetoothAddress& aDeviceAddress,
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::Disconnect(
|
||||
const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
ConnectDisconnect(false, aDeviceAddress, aRunnable, aServiceUuid);
|
||||
|
|
|
@ -50,12 +50,11 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
|
||||
|
@ -76,48 +75,48 @@ public:
|
|||
BluetoothProfileManagerBase* aManager);
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
|
@ -490,7 +489,7 @@ protected:
|
|||
const nsAString& aPlayStatus);
|
||||
|
||||
static void ConnectDisconnect(bool aConnect,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& 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<BluetoothAddress>& aDeviceAddresses,
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
const FilterFunc aFilterFunc, BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddresses(aDeviceAddresses)
|
||||
, mProcessedDeviceAddresses(0)
|
||||
|
@ -2772,11 +2772,8 @@ public:
|
|||
}
|
||||
|
||||
if (mFilterFunc(deviceProperties)) {
|
||||
nsString deviceAddressStr;
|
||||
AddressToString(mDeviceAddresses[i], deviceAddressStr);
|
||||
|
||||
mValues.get_ArrayOfBluetoothNamedValue().AppendElement(
|
||||
BluetoothNamedValue(deviceAddressStr, deviceProperties));
|
||||
BluetoothNamedValue(mDeviceAddresses[i], deviceProperties));
|
||||
}
|
||||
|
||||
ProcessRemainingDeviceAddresses();
|
||||
|
@ -2825,7 +2822,7 @@ protected:
|
|||
|
||||
private:
|
||||
nsString mObjectPath;
|
||||
const nsTArray<BluetoothAddress> mDeviceAddresses;
|
||||
const nsTArray<nsString> mDeviceAddresses;
|
||||
nsTArray<nsString>::size_type mProcessedDeviceAddresses;
|
||||
const FilterFunc mFilterFunc;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
|
@ -2871,8 +2868,7 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTArray<BluetoothAddress> deviceAddresses;
|
||||
|
||||
nsTArray<nsString> deviceAddresses;
|
||||
BluetoothProfileManagerBase* profile =
|
||||
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
|
||||
if (!profile) {
|
||||
|
@ -2884,7 +2880,11 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
if (profile->IsConnected()) {
|
||||
BluetoothAddress address;
|
||||
profile->GetAddress(address);
|
||||
deviceAddresses.AppendElement(address);
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(address, addressStr);
|
||||
|
||||
deviceAddresses.AppendElement(addressStr);
|
||||
}
|
||||
|
||||
BluetoothArrayOfDevicePropertiesReplyHandler* handler =
|
||||
|
@ -2899,8 +2899,8 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -2921,7 +2921,7 @@ BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
|||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothDBusService::FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -3092,14 +3092,14 @@ BluetoothDBusService::SetProperty(BluetoothObjectType aType,
|
|||
class CreatePairedDeviceInternalTask : public Task
|
||||
{
|
||||
public:
|
||||
CreatePairedDeviceInternalTask(const BluetoothAddress& aDeviceAddress,
|
||||
CreatePairedDeviceInternalTask(const nsACString& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mTimeout(aTimeout)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
|
@ -3109,11 +3109,7 @@ public:
|
|||
MOZ_ASSERT(sDBusConnection);
|
||||
MOZ_ASSERT(!sAdapterPath.IsEmpty());
|
||||
|
||||
nsString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
auto utf8DeviceAddressStr = NS_ConvertUTF16toUTF8(deviceAddressStr);
|
||||
|
||||
const char *deviceAddress = utf8DeviceAddressStr.get();
|
||||
const char *deviceAddress = mDeviceAddress.get();
|
||||
const char *deviceAgentPath = KEY_REMOTE_AGENT;
|
||||
const char *capabilities = B2G_AGENT_CAPABILITIES;
|
||||
|
||||
|
@ -3149,20 +3145,20 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
BluetoothAddress mDeviceAddress;
|
||||
const nsCString mDeviceAddress;
|
||||
int mTimeout;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::CreatePairedDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new CreatePairedDeviceInternalTask(aDeviceAddress,
|
||||
aTimeout,
|
||||
aRunnable);
|
||||
Task* task = new CreatePairedDeviceInternalTask(
|
||||
NS_ConvertUTF16toUTF8(aDeviceAddress),
|
||||
aTimeout, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3225,9 +3221,8 @@ private:
|
|||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::RemoveDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -3237,7 +3232,14 @@ BluetoothDBusService::RemoveDeviceInternal(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(aDeviceAddress, aRunnable);
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(deviceAddress, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3308,7 +3310,7 @@ private:
|
|||
|
||||
void
|
||||
BluetoothDBusService::PinReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
|
@ -3316,18 +3318,25 @@ BluetoothDBusService::PinReplyInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::SspReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress,
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPinCodeTask(deviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aPinCode),
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
@ -3397,12 +3406,17 @@ private:
|
|||
};
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPasskeyInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPasskeyTask(aDeviceAddress,
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPasskeyTask(deviceAddress,
|
||||
aPasskey,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
@ -3410,13 +3424,19 @@ BluetoothDBusService::SetPasskeyInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::SetPairingConfirmationInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(aDeviceAddress,
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(deviceAddress,
|
||||
aConfirm,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
@ -3437,15 +3457,22 @@ NextBluetoothProfileController()
|
|||
}
|
||||
|
||||
static void
|
||||
ConnectDisconnect(bool aConnect, const BluetoothAddress& aDeviceAddress,
|
||||
ConnectDisconnect(bool aConnect, const nsAString& 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, aDeviceAddress, aRunnable,
|
||||
new BluetoothProfileController(aConnect, deviceAddress, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
|
@ -3461,7 +3488,7 @@ ConnectDisconnect(bool aConnect, const BluetoothAddress& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothDBusService::Connect(const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -3470,7 +3497,7 @@ BluetoothDBusService::Connect(const BluetoothAddress& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::Disconnect(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothDBusService::Disconnect(const nsAString& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -3515,13 +3542,16 @@ BluetoothDBusService::ToggleCalls(BluetoothReplyRunnable* aRunnable)
|
|||
class OnUpdateSdpRecordsRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OnUpdateSdpRecordsRunnable(const BluetoothAddress& aDeviceAddress,
|
||||
OnUpdateSdpRecordsRunnable(const nsAString& aObjectPath,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mManager(aManager)
|
||||
: mManager(aManager)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mManager);
|
||||
MOZ_ASSERT(!aObjectPath.IsEmpty());
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
const nsString deviceAddressStr = GetAddressFromObjectPath(aObjectPath);
|
||||
|
||||
StringToAddress(deviceAddressStr, mDeviceAddress);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -3728,7 +3758,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(mDeviceAddress, mBluetoothProfileManager);
|
||||
new OnUpdateSdpRecordsRunnable(objectPath, mBluetoothProfileManager);
|
||||
|
||||
sDBusConnection->SendWithReply(DiscoverServicesCallback,
|
||||
(void*)callbackRunnable, -1,
|
||||
|
|
|
@ -59,12 +59,11 @@ public:
|
|||
uint16_t aServiceUuid, BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -88,48 +87,46 @@ public:
|
|||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
|
|
@ -149,9 +149,8 @@ public:
|
|||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Returns the properties of connected devices regarding to specific profile,
|
||||
|
@ -170,7 +169,7 @@ public:
|
|||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -214,12 +213,12 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const nsAString& aAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
RemoveDeviceInternal(const nsAString& aObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -242,13 +241,13 @@ public:
|
|||
BluetoothProfileManagerBase* aManager) = 0;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
@ -257,7 +256,7 @@ public:
|
|||
* Legacy method used by bluez only to reply pincode request.
|
||||
*/
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
|
@ -265,24 +264,22 @@ public:
|
|||
* Legacy method used by bluez only to reply passkey entry request.
|
||||
*/
|
||||
virtual void
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Legacy method used by bluez only to reply pairing confirmation request.
|
||||
*/
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod, uint16_t aServiceUuid,
|
||||
Connect(const nsAString& aDeviceAddress, uint32_t aCod, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
|
|
|
@ -405,24 +405,13 @@ 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);
|
||||
|
||||
auto rv = bs->GetPairedDevicePropertiesInternal(deviceAddresses, results);
|
||||
nsresult rv =
|
||||
bs->GetPairedDevicePropertiesInternal(aDeviceAddresses, results);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("GetPairedDeviceProperties failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -862,13 +851,11 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
|
|||
|
||||
/**
|
||||
* Ensure
|
||||
* - device address is valid,
|
||||
* - device address is not empty,
|
||||
* - adapter is already enabled, and
|
||||
* - BluetoothService is available.
|
||||
*/
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(aDeviceAddress,
|
||||
deviceAddress)),
|
||||
BT_ENSURE_TRUE_REJECT(!aDeviceAddress.IsEmpty(),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
BT_ENSURE_TRUE_REJECT(mState == BluetoothAdapterState::Enabled,
|
||||
|
@ -880,10 +867,10 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
|
|||
nsresult rv;
|
||||
if (aPair) {
|
||||
rv = bs->CreatePairedDeviceInternal(
|
||||
deviceAddress, kCreatePairedDeviceTimeout,
|
||||
aDeviceAddress, kCreatePairedDeviceTimeout,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else {
|
||||
rv = bs->RemoveDeviceInternal(deviceAddress,
|
||||
rv = bs->RemoveDeviceInternal(aDeviceAddress,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
}
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv), promise, NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
@ -1674,12 +1661,6 @@ 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()) {
|
||||
|
@ -1691,7 +1672,7 @@ BluetoothAdapter::Connect(BluetoothDevice& aDevice,
|
|||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->Connect(deviceAddress, deviceClass, serviceUuid, results);
|
||||
bs->Connect(address, deviceClass, serviceUuid, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -1713,12 +1694,6 @@ 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();
|
||||
|
@ -1729,7 +1704,7 @@ BluetoothAdapter::Disconnect(BluetoothDevice& aDevice,
|
|||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->Disconnect(deviceAddress, serviceUuid, results);
|
||||
bs->Disconnect(address, serviceUuid, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
|
|
@ -187,13 +187,10 @@ 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(address, new FetchUuidsTask(promise, this))),
|
||||
bs->FetchUuidsInternal(mAddress, new FetchUuidsTask(promise, this))),
|
||||
promise, NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
return promise.forget();
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "BluetoothPairingHandle.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothUtils.h"
|
||||
|
||||
#include "mozilla/dom/BluetoothPairingHandleBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
@ -80,16 +79,10 @@ 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(deviceAddress, true /* accept */, aPinCode,
|
||||
bs->PinReplyInternal(mDeviceAddress, true /* accept */, aPinCode,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -115,18 +108,12 @@ 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(deviceAddress, variant, true /* aAccept */,
|
||||
bs->SspReplyInternal(mDeviceAddress, variant, true /* aAccept */,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -144,17 +131,11 @@ 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(deviceAddress, false /* aAccept */, EmptyString(),
|
||||
bs->PinReplyInternal(mDeviceAddress, false /* aAccept */, EmptyString(),
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else { // Ssp request
|
||||
BluetoothSspVariant variant;
|
||||
|
@ -162,7 +143,7 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv)
|
|||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->SspReplyInternal(deviceAddress, variant, false /* aAccept */,
|
||||
bs->SspReplyInternal(mDeviceAddress, 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.address(),
|
||||
mService->SetPinCodeInternal(aRequest.path(),
|
||||
aRequest.pincode(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -612,7 +612,7 @@ BluetoothRequestParent::DoRequest(const SetPasskeyRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TSetPasskeyRequest);
|
||||
|
||||
mService->SetPasskeyInternal(aRequest.address(),
|
||||
mService->SetPasskeyInternal(aRequest.path(),
|
||||
aRequest.passkey(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -626,7 +626,7 @@ BluetoothRequestParent::DoRequest(const ConfirmPairingConfirmationRequest&
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TConfirmPairingConfirmationRequest);
|
||||
|
||||
mService->SetPairingConfirmationInternal(aRequest.address(),
|
||||
mService->SetPairingConfirmationInternal(aRequest.path(),
|
||||
true,
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -640,7 +640,7 @@ BluetoothRequestParent::DoRequest(const DenyPairingConfirmationRequest&
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TDenyPairingConfirmationRequest);
|
||||
|
||||
mService->SetPairingConfirmationInternal(aRequest.address(),
|
||||
mService->SetPairingConfirmationInternal(aRequest.path(),
|
||||
false,
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ BluetoothServiceChildProcess::GetConnectedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
PairedDevicePropertiesRequest request;
|
||||
request.addresses().AppendElements(aDeviceAddresses);
|
||||
|
@ -141,9 +141,9 @@ BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::FetchUuidsInternal(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, FetchUuidsRequest(aDeviceAddress));
|
||||
SendRequest(aRunnable, FetchUuidsRequest(nsString(aDeviceAddress)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -188,18 +188,22 @@ BluetoothServiceChildProcess::SetProperty(BluetoothObjectType aType,
|
|||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::CreatePairedDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress, int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, PairRequest(aDeviceAddress, aTimeout));
|
||||
SendRequest(aRunnable,
|
||||
PairRequest(nsString(aAddress), aTimeout));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::RemoveDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, UnpairRequest(aDeviceAddress));
|
||||
SendRequest(aRunnable,
|
||||
UnpairRequest(nsString(aObjectPath)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -220,72 +224,82 @@ BluetoothServiceChildProcess::UpdateSdpRecords(const BluetoothAddress& aDeviceAd
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::PinReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
PinReplyRequest(aDeviceAddress,
|
||||
PinReplyRequest(nsString(aDeviceAddress),
|
||||
aAccept,
|
||||
nsString(aPinCode)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SspReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant, bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, SspReplyRequest(aDeviceAddress, aVariant, aAccept));
|
||||
SendRequest(aRunnable,
|
||||
SspReplyRequest(nsString(aDeviceAddress),
|
||||
aVariant,
|
||||
aAccept));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPinCodeInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SetPinCodeRequest(aDeviceAddress, nsString(aPinCode)));
|
||||
SetPinCodeRequest(nsString(aDeviceAddress), nsString(aPinCode)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPasskeyInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, SetPasskeyRequest(aDeviceAddress, aPasskey));
|
||||
SendRequest(aRunnable,
|
||||
SetPasskeyRequest(nsString(aDeviceAddress), aPasskey));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPairingConfirmationInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
if (aConfirm) {
|
||||
SendRequest(aRunnable, ConfirmPairingConfirmationRequest(aDeviceAddress));
|
||||
if(aConfirm) {
|
||||
SendRequest(aRunnable,
|
||||
ConfirmPairingConfirmationRequest(nsString(aDeviceAddress)));
|
||||
} else {
|
||||
SendRequest(aRunnable, DenyPairingConfirmationRequest(aDeviceAddress));
|
||||
SendRequest(aRunnable,
|
||||
DenyPairingConfirmationRequest(nsString(aDeviceAddress)));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::Connect(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod, uint16_t aServiceUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, ConnectRequest(aDeviceAddress, aCod, aServiceUuid));
|
||||
SendRequest(aRunnable,
|
||||
ConnectRequest(nsString(aDeviceAddress),
|
||||
aCod,
|
||||
aServiceUuid));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::Disconnect(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const nsAString& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, DisconnectRequest(aDeviceAddress, aServiceUuid));
|
||||
SendRequest(aRunnable,
|
||||
DisconnectRequest(nsString(aDeviceAddress), aServiceUuid));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
StopInternal(BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -73,12 +73,12 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const nsAString& aAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
RemoveDeviceInternal(const nsAString& aObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
|
@ -91,41 +91,41 @@ public:
|
|||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress,
|
||||
Disconnect(const nsAString& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
|
|
|
@ -12,10 +12,7 @@ include BluetoothTypes;
|
|||
|
||||
include "mozilla/dom/bluetooth/ipc/BluetoothMessageUtils.h";
|
||||
|
||||
using mozilla::dom::bluetooth::BluetoothAddress
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -45,7 +42,7 @@ struct SetPropertyRequest
|
|||
struct GetPropertyRequest
|
||||
{
|
||||
BluetoothObjectType type;
|
||||
BluetoothAddress address;
|
||||
nsString path;
|
||||
};
|
||||
|
||||
struct StartDiscoveryRequest
|
||||
|
@ -68,54 +65,54 @@ struct StopLeScanRequest
|
|||
|
||||
struct PairRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
uint32_t timeoutMS;
|
||||
};
|
||||
|
||||
struct UnpairRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
};
|
||||
|
||||
struct PinReplyRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
bool accept;
|
||||
nsString pinCode;
|
||||
};
|
||||
|
||||
struct SspReplyRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
BluetoothSspVariant variant;
|
||||
bool accept;
|
||||
};
|
||||
|
||||
struct SetPinCodeRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString path;
|
||||
nsString pincode;
|
||||
};
|
||||
|
||||
struct SetPasskeyRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString path;
|
||||
uint32_t passkey;
|
||||
};
|
||||
|
||||
struct ConfirmPairingConfirmationRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString path;
|
||||
};
|
||||
|
||||
struct DenyPairingConfirmationRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString path;
|
||||
};
|
||||
|
||||
struct PairedDevicePropertiesRequest
|
||||
{
|
||||
BluetoothAddress[] addresses;
|
||||
nsString[] addresses;
|
||||
};
|
||||
|
||||
struct ConnectedDevicePropertiesRequest
|
||||
|
@ -125,19 +122,19 @@ struct ConnectedDevicePropertiesRequest
|
|||
|
||||
struct FetchUuidsRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
};
|
||||
|
||||
struct ConnectRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
uint32_t cod;
|
||||
uint16_t serviceUuid;
|
||||
};
|
||||
|
||||
struct DisconnectRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
nsString address;
|
||||
uint16_t serviceUuid;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче