Backed out changeset 7251fc4dce99 (bug 1220121)

This commit is contained in:
Carsten "Tomcat" Book 2015-11-11 12:06:44 +01:00
Родитель ca229888f4
Коммит ecd9413df1
10 изменённых файлов: 122 добавлений и 119 удалений

Просмотреть файл

@ -363,7 +363,7 @@ BluetoothServiceBluedroid::StopLeScanInternal(
void void
BluetoothServiceBluedroid::ConnectGattClientInternal( BluetoothServiceBluedroid::ConnectGattClientInternal(
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress, const nsAString& aAppUuid, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -376,12 +376,18 @@ BluetoothServiceBluedroid::ConnectGattClientInternal(
BluetoothUuid appUuid; BluetoothUuid appUuid;
StringToUuid(aAppUuid, appUuid); StringToUuid(aAppUuid, appUuid);
gatt->Connect(appUuid, aDeviceAddress, aRunnable); BluetoothAddress deviceAddress;
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->Connect(appUuid, deviceAddress, aRunnable);
} }
void void
BluetoothServiceBluedroid::DisconnectGattClientInternal( BluetoothServiceBluedroid::DisconnectGattClientInternal(
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress, const nsAString& aAppUuid, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -394,7 +400,13 @@ BluetoothServiceBluedroid::DisconnectGattClientInternal(
BluetoothUuid appUuid; BluetoothUuid appUuid;
StringToUuid(aAppUuid, appUuid); StringToUuid(aAppUuid, appUuid);
gatt->Disconnect(appUuid, aDeviceAddress, aRunnable); BluetoothAddress deviceAddress;
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->Disconnect(appUuid, deviceAddress, aRunnable);
} }
void void
@ -466,7 +478,7 @@ BluetoothServiceBluedroid::UnregisterGattClientInternal(
void void
BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal( BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal(
int aClientIf, const BluetoothAddress& aDeviceAddress, int aClientIf, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -476,7 +488,13 @@ BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal(
BluetoothGattManager* gatt = BluetoothGattManager::Get(); BluetoothGattManager* gatt = BluetoothGattManager::Get();
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable); ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
gatt->ReadRemoteRssi(aClientIf, aDeviceAddress, aRunnable); BluetoothAddress deviceAddress;
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->ReadRemoteRssi(aClientIf, deviceAddress, aRunnable);
} }
void void
@ -571,7 +589,7 @@ BluetoothServiceBluedroid::GattClientWriteDescriptorValueInternal(
// GATT Server // GATT Server
void void
BluetoothServiceBluedroid::GattServerConnectPeripheralInternal( BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const BluetoothAddress& aAddress, const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -584,12 +602,18 @@ BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
BluetoothUuid appUuid; BluetoothUuid appUuid;
StringToUuid(aAppUuid, appUuid); StringToUuid(aAppUuid, appUuid);
gatt->ConnectPeripheral(appUuid, aAddress, aRunnable); BluetoothAddress address;
if (NS_FAILED(StringToAddress(aAddress, address))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->ConnectPeripheral(appUuid, address, aRunnable);
} }
void void
BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal( BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const BluetoothAddress& aAddress, const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -602,7 +626,13 @@ BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
BluetoothUuid appUuid; BluetoothUuid appUuid;
StringToUuid(aAppUuid, appUuid); StringToUuid(aAppUuid, appUuid);
gatt->DisconnectPeripheral(appUuid, aAddress, aRunnable); BluetoothAddress address;
if (NS_FAILED(StringToAddress(aAddress, address))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->DisconnectPeripheral(appUuid, address, aRunnable);
} }
void void
@ -776,7 +806,7 @@ BluetoothServiceBluedroid::GattServerStopServiceInternal(
void void
BluetoothServiceBluedroid::GattServerSendResponseInternal( BluetoothServiceBluedroid::GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,
@ -792,14 +822,20 @@ BluetoothServiceBluedroid::GattServerSendResponseInternal(
BluetoothUuid appUuid; BluetoothUuid appUuid;
StringToUuid(aAppUuid, appUuid); StringToUuid(aAppUuid, appUuid);
BluetoothAddress address;
if (NS_FAILED(StringToAddress(aAddress, address))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->ServerSendResponse( gatt->ServerSendResponse(
appUuid, aAddress, aStatus, aRequestId, aRsp, aRunnable); appUuid, address, aStatus, aRequestId, aRsp, aRunnable);
} }
void void
BluetoothServiceBluedroid::GattServerSendIndicationInternal( BluetoothServiceBluedroid::GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,
@ -815,8 +851,14 @@ BluetoothServiceBluedroid::GattServerSendIndicationInternal(
BluetoothUuid appUuid; BluetoothUuid appUuid;
StringToUuid(aAppUuid, appUuid); StringToUuid(aAppUuid, appUuid);
BluetoothAddress address;
if (NS_FAILED(StringToAddress(aAddress, address))) {
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
return;
}
gatt->ServerSendIndication(appUuid, gatt->ServerSendIndication(appUuid,
aAddress, address,
aCharacteristicHandle, aCharacteristicHandle,
aConfirm, aConfirm,
aValue, aValue,

Просмотреть файл

@ -283,12 +283,12 @@ public:
virtual void virtual void
ConnectGattClientInternal(const nsAString& aAppUuid, ConnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
DisconnectGattClientInternal(const nsAString& aAppUuid, DisconnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -315,7 +315,7 @@ public:
virtual void virtual void
GattClientReadRemoteRssiInternal( GattClientReadRemoteRssiInternal(
int aClientIf, const BluetoothAddress& aDeviceAddress, int aClientIf, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -354,13 +354,13 @@ public:
virtual void virtual void
GattServerConnectPeripheralInternal( GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
GattServerDisconnectPeripheralInternal( GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -420,7 +420,7 @@ public:
virtual void virtual void
GattServerSendResponseInternal( GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,
@ -429,7 +429,7 @@ public:
virtual void virtual void
GattServerSendIndicationInternal( GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,

Просмотреть файл

@ -4309,14 +4309,14 @@ BluetoothDBusService::StopLeScanInternal(
void void
BluetoothDBusService::ConnectGattClientInternal( BluetoothDBusService::ConnectGattClientInternal(
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress, const nsAString& aAppUuid, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
} }
void void
BluetoothDBusService::DisconnectGattClientInternal( BluetoothDBusService::DisconnectGattClientInternal(
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress, const nsAString& aAppUuid, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
} }
@ -4349,7 +4349,7 @@ BluetoothDBusService::UnregisterGattClientInternal(
void void
BluetoothDBusService::GattClientReadRemoteRssiInternal( BluetoothDBusService::GattClientReadRemoteRssiInternal(
int aClientIf, const BluetoothAddress& aDeviceAddress, int aClientIf, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
} }
@ -4521,14 +4521,14 @@ BluetoothDBusService::ReplyToMapMessageUpdate(long aMasId, bool aStatus,
void void
BluetoothDBusService::GattServerConnectPeripheralInternal( BluetoothDBusService::GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const BluetoothAddress& aAddress, const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
} }
void void
BluetoothDBusService::GattServerDisconnectPeripheralInternal( BluetoothDBusService::GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const BluetoothAddress& aAddress, const nsAString& aAppUuid, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
} }
@ -4606,7 +4606,7 @@ BluetoothDBusService::GattServerStopServiceInternal(
void void
BluetoothDBusService::GattServerSendIndicationInternal( BluetoothDBusService::GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,
@ -4617,7 +4617,7 @@ BluetoothDBusService::GattServerSendIndicationInternal(
void void
BluetoothDBusService::GattServerSendResponseInternal( BluetoothDBusService::GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,

Просмотреть файл

@ -294,12 +294,12 @@ public:
virtual void virtual void
ConnectGattClientInternal(const nsAString& aAppUuid, ConnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
DisconnectGattClientInternal(const nsAString& aAppUuid, DisconnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -326,7 +326,7 @@ public:
virtual void virtual void
GattClientReadRemoteRssiInternal( GattClientReadRemoteRssiInternal(
int aClientIf, const BluetoothAddress& aDeviceAddress, int aClientIf, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -365,13 +365,13 @@ public:
virtual void virtual void
GattServerConnectPeripheralInternal( GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
GattServerDisconnectPeripheralInternal( GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -431,7 +431,7 @@ public:
virtual void virtual void
GattServerSendResponseInternal( GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,
@ -440,7 +440,7 @@ public:
virtual void virtual void
GattServerSendIndicationInternal( GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,

Просмотреть файл

@ -442,7 +442,7 @@ public:
*/ */
virtual void virtual void
ConnectGattClientInternal(const nsAString& aAppUuid, ConnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) = 0; BluetoothReplyRunnable* aRunnable) = 0;
/** /**
@ -451,7 +451,7 @@ public:
*/ */
virtual void virtual void
DisconnectGattClientInternal(const nsAString& aAppUuid, DisconnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) = 0; BluetoothReplyRunnable* aRunnable) = 0;
/** /**
@ -494,7 +494,7 @@ public:
*/ */
virtual void virtual void
GattClientReadRemoteRssiInternal(int aClientIf, GattClientReadRemoteRssiInternal(int aClientIf,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) = 0; BluetoothReplyRunnable* aRunnable) = 0;
/** /**
@ -549,13 +549,13 @@ public:
virtual void virtual void
GattServerConnectPeripheralInternal( GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) = 0; BluetoothReplyRunnable* aRunnable) = 0;
virtual void virtual void
GattServerDisconnectPeripheralInternal( GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) = 0; BluetoothReplyRunnable* aRunnable) = 0;
/** /**
@ -618,7 +618,7 @@ public:
virtual void virtual void
GattServerSendResponseInternal( GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,
@ -627,7 +627,7 @@ public:
virtual void virtual void
GattServerSendIndicationInternal( GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,

Просмотреть файл

@ -112,12 +112,6 @@ BluetoothGatt::Connect(ErrorResult& aRv)
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothAddress deviceAddr;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
promise,
NS_ERROR_DOM_OPERATION_ERR);
if (mAppUuid.IsEmpty()) { if (mAppUuid.IsEmpty()) {
nsresult rv = GenerateUuid(mAppUuid); nsresult rv = GenerateUuid(mAppUuid);
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv) && !mAppUuid.IsEmpty(), BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv) && !mAppUuid.IsEmpty(),
@ -128,7 +122,7 @@ BluetoothGatt::Connect(ErrorResult& aRv)
UpdateConnectionState(BluetoothConnectionState::Connecting); UpdateConnectionState(BluetoothConnectionState::Connecting);
bs->ConnectGattClientInternal( bs->ConnectGattClientInternal(
mAppUuid, deviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise)); mAppUuid, mDeviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
return promise.forget(); return promise.forget();
} }
@ -153,15 +147,9 @@ BluetoothGatt::Disconnect(ErrorResult& aRv)
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothAddress deviceAddr;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
promise,
NS_ERROR_DOM_OPERATION_ERR);
UpdateConnectionState(BluetoothConnectionState::Disconnecting); UpdateConnectionState(BluetoothConnectionState::Disconnecting);
bs->DisconnectGattClientInternal( bs->DisconnectGattClientInternal(
mAppUuid, deviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise)); mAppUuid, mDeviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
return promise.forget(); return promise.forget();
} }
@ -208,14 +196,8 @@ BluetoothGatt::ReadRemoteRssi(ErrorResult& aRv)
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothAddress deviceAddr;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
promise,
NS_ERROR_DOM_OPERATION_ERR);
bs->GattClientReadRemoteRssiInternal( bs->GattClientReadRemoteRssiInternal(
mClientIf, deviceAddr, new ReadRemoteRssiTask(promise)); mClientIf, mDeviceAddr, new ReadRemoteRssiTask(promise));
return promise.forget(); return promise.forget();
} }

Просмотреть файл

@ -319,18 +319,12 @@ BluetoothGattServer::Connect(const nsAString& aAddress, ErrorResult& aRv)
RefPtr<Promise> promise = Promise::Create(global, aRv); RefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr); NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BluetoothAddress address;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(aAddress, address)),
promise,
NS_ERROR_INVALID_ARG);
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
bs->GattServerConnectPeripheralInternal( bs->GattServerConnectPeripheralInternal(
mAppUuid, address, new BluetoothVoidReplyRunnable(nullptr, promise)); mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
return promise.forget(); return promise.forget();
} }
@ -347,18 +341,12 @@ BluetoothGattServer::Disconnect(const nsAString& aAddress, ErrorResult& aRv)
RefPtr<Promise> promise = Promise::Create(global, aRv); RefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr); NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BluetoothAddress address;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(aAddress, address)),
promise,
NS_ERROR_INVALID_ARG);
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
bs->GattServerDisconnectPeripheralInternal( bs->GattServerDisconnectPeripheralInternal(
mAppUuid, address, new BluetoothVoidReplyRunnable(nullptr, promise)); mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
return promise.forget(); return promise.forget();
} }
@ -810,12 +798,6 @@ BluetoothGattServer::NotifyCharacteristicChanged(
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
BluetoothAddress address;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(aAddress, address)),
promise,
NS_ERROR_INVALID_ARG);
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
@ -826,7 +808,7 @@ BluetoothGattServer::NotifyCharacteristicChanged(
NS_ERROR_NOT_AVAILABLE); NS_ERROR_NOT_AVAILABLE);
bs->GattServerSendIndicationInternal( bs->GattServerSendIndicationInternal(
mAppUuid, address, aCharacteristic.GetCharacteristicHandle(), aConfirm, mAppUuid, aAddress, aCharacteristic.GetCharacteristicHandle(), aConfirm,
aCharacteristic.GetValue(), aCharacteristic.GetValue(),
new BluetoothVoidReplyRunnable(nullptr, promise)); new BluetoothVoidReplyRunnable(nullptr, promise));
@ -848,12 +830,6 @@ BluetoothGattServer::SendResponse(const nsAString& aAddress,
RefPtr<Promise> promise = Promise::Create(global, aRv); RefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr); NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BluetoothAddress address;
BT_ENSURE_TRUE_REJECT(
NS_SUCCEEDED(StringToAddress(aAddress, address)),
promise,
NS_ERROR_INVALID_ARG);
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE); BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
RequestData* requestData; RequestData* requestData;
@ -886,7 +862,7 @@ BluetoothGattServer::SendResponse(const nsAString& aAddress,
bs->GattServerSendResponseInternal( bs->GattServerSendResponseInternal(
mAppUuid, mAppUuid,
address, aAddress,
aStatus, aStatus,
aRequestId, aRequestId,
response, response,

Просмотреть файл

@ -550,20 +550,20 @@ BluetoothServiceChildProcess::SendPlayStatus(int64_t aDuration,
void void
BluetoothServiceChildProcess::ConnectGattClientInternal( BluetoothServiceChildProcess::ConnectGattClientInternal(
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress, const nsAString& aAppUuid, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
SendRequest(aRunnable, ConnectGattClientRequest(nsString(aAppUuid), SendRequest(aRunnable, ConnectGattClientRequest(nsString(aAppUuid),
aDeviceAddress)); nsString(aDeviceAddress)));
} }
void void
BluetoothServiceChildProcess::DisconnectGattClientInternal( BluetoothServiceChildProcess::DisconnectGattClientInternal(
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress, const nsAString& aAppUuid, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
SendRequest(aRunnable, SendRequest(aRunnable,
DisconnectGattClientRequest(nsString(aAppUuid), aDeviceAddress)); DisconnectGattClientRequest(nsString(aAppUuid), nsString(aDeviceAddress)));
} }
void void
@ -601,11 +601,12 @@ BluetoothServiceChildProcess::UnregisterGattClientInternal(
void void
BluetoothServiceChildProcess::GattClientReadRemoteRssiInternal( BluetoothServiceChildProcess::GattClientReadRemoteRssiInternal(
int aClientIf, const BluetoothAddress& aDeviceAddress, int aClientIf, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
SendRequest(aRunnable, SendRequest(aRunnable,
GattClientReadRemoteRssiRequest(aClientIf, aDeviceAddress)); GattClientReadRemoteRssiRequest(aClientIf,
nsString(aDeviceAddress)));
} }
void void
@ -673,21 +674,23 @@ BluetoothServiceChildProcess::GattClientWriteDescriptorValueInternal(
void void
BluetoothServiceChildProcess::GattServerConnectPeripheralInternal( BluetoothServiceChildProcess::GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
SendRequest(aRunnable, SendRequest(aRunnable,
GattServerConnectPeripheralRequest(nsString(aAppUuid), aAddress)); GattServerConnectPeripheralRequest(nsString(aAppUuid),
nsString(aAddress)));
} }
void void
BluetoothServiceChildProcess::GattServerDisconnectPeripheralInternal( BluetoothServiceChildProcess::GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
{ {
SendRequest(aRunnable, SendRequest(aRunnable,
GattServerDisconnectPeripheralRequest(nsString(aAppUuid), aAddress)); GattServerDisconnectPeripheralRequest(nsString(aAppUuid),
nsString(aAddress)));
} }
void void
@ -788,7 +791,7 @@ BluetoothServiceChildProcess::GattServerStopServiceInternal(
void void
BluetoothServiceChildProcess::GattServerSendResponseInternal( BluetoothServiceChildProcess::GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,
@ -796,13 +799,13 @@ BluetoothServiceChildProcess::GattServerSendResponseInternal(
{ {
SendRequest(aRunnable, SendRequest(aRunnable,
GattServerSendResponseRequest( GattServerSendResponseRequest(
nsString(aAppUuid), aAddress, aStatus, aRequestId, aRsp)); nsString(aAppUuid), nsString(aAddress), aStatus, aRequestId, aRsp));
} }
void void
BluetoothServiceChildProcess::GattServerSendIndicationInternal( BluetoothServiceChildProcess::GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,
@ -810,7 +813,7 @@ BluetoothServiceChildProcess::GattServerSendIndicationInternal(
{ {
SendRequest(aRunnable, SendRequest(aRunnable,
GattServerSendIndicationRequest(nsString(aAppUuid), GattServerSendIndicationRequest(nsString(aAppUuid),
aAddress, nsString(aAddress),
aCharacteristicHandle, aCharacteristicHandle,
aConfirm, aConfirm,
aValue)); aValue));

Просмотреть файл

@ -285,12 +285,12 @@ public:
virtual void virtual void
ConnectGattClientInternal(const nsAString& aAppUuid, ConnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
DisconnectGattClientInternal(const nsAString& aAppUuid, DisconnectGattClientInternal(const nsAString& aAppUuid,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -317,7 +317,7 @@ public:
virtual void virtual void
GattClientReadRemoteRssiInternal(int aClientIf, GattClientReadRemoteRssiInternal(int aClientIf,
const BluetoothAddress& aDeviceAddress, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -356,13 +356,13 @@ public:
virtual void virtual void
GattServerConnectPeripheralInternal( GattServerConnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
GattServerDisconnectPeripheralInternal( GattServerDisconnectPeripheralInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
BluetoothReplyRunnable* aRunnable) override; BluetoothReplyRunnable* aRunnable) override;
virtual void virtual void
@ -422,7 +422,7 @@ public:
virtual void virtual void
GattServerSendResponseInternal( GattServerSendResponseInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
uint16_t aStatus, uint16_t aStatus,
int32_t aRequestId, int32_t aRequestId,
const BluetoothGattResponse& aRsp, const BluetoothGattResponse& aRsp,
@ -431,7 +431,7 @@ public:
virtual void virtual void
GattServerSendIndicationInternal( GattServerSendIndicationInternal(
const nsAString& aAppUuid, const nsAString& aAppUuid,
const BluetoothAddress& aAddress, const nsAString& aAddress,
const BluetoothAttributeHandle& aCharacteristicHandle, const BluetoothAttributeHandle& aCharacteristicHandle,
bool aConfirm, bool aConfirm,
const nsTArray<uint8_t>& aValue, const nsTArray<uint8_t>& aValue,

Просмотреть файл

@ -276,13 +276,13 @@ struct SendPlayStatusRequest
struct ConnectGattClientRequest struct ConnectGattClientRequest
{ {
nsString appUuid; nsString appUuid;
BluetoothAddress deviceAddress; nsString deviceAddress;
}; };
struct DisconnectGattClientRequest struct DisconnectGattClientRequest
{ {
nsString appUuid; nsString appUuid;
BluetoothAddress deviceAddress; nsString deviceAddress;
}; };
struct DiscoverGattServicesRequest struct DiscoverGattServicesRequest
@ -312,7 +312,7 @@ struct UnregisterGattClientRequest
struct GattClientReadRemoteRssiRequest struct GattClientReadRemoteRssiRequest
{ {
int clientIf; int clientIf;
BluetoothAddress deviceAddress; nsString deviceAddress;
}; };
struct GattClientReadCharacteristicValueRequest struct GattClientReadCharacteristicValueRequest
@ -351,13 +351,13 @@ struct GattClientWriteDescriptorValueRequest
struct GattServerConnectPeripheralRequest struct GattServerConnectPeripheralRequest
{ {
nsString appUuid; nsString appUuid;
BluetoothAddress address; nsString address;
}; };
struct GattServerDisconnectPeripheralRequest struct GattServerDisconnectPeripheralRequest
{ {
nsString appUuid; nsString appUuid;
BluetoothAddress address; nsString address;
}; };
struct UnregisterGattServerRequest struct UnregisterGattServerRequest
@ -418,7 +418,7 @@ struct GattServerStopServiceRequest
struct GattServerSendResponseRequest struct GattServerSendResponseRequest
{ {
nsString appUuid; nsString appUuid;
BluetoothAddress address; nsString address;
uint16_t status; uint16_t status;
int32_t requestId; int32_t requestId;
BluetoothGattResponse response; BluetoothGattResponse response;
@ -427,7 +427,7 @@ struct GattServerSendResponseRequest
struct GattServerSendIndicationRequest struct GattServerSendIndicationRequest
{ {
nsString appUuid; nsString appUuid;
BluetoothAddress address; nsString address;
BluetoothAttributeHandle characteristicHandle; BluetoothAttributeHandle characteristicHandle;
bool confirm; bool confirm;
uint8_t[] value; uint8_t[] value;