Bug 933113 - Modify Pair/Unpair interface for Gaia being able to Pair/Unpair with only BD address, r=gyeh, sr=mrbkap

NFC handover is a mechanism for two devices to exchange their Bluetooth device
address with each other. Then one device would be initialize the Bluetooth
pairing process with received Bluetooth device address. However currently we
need a BluetoothDevice object for Pairing/Unpairing, but actually the address
of the Bluetooth device object is the only thing Gecko requires.
This commit is contained in:
Eric Chou 2013-11-15 17:19:31 +08:00
Родитель 09e8a50de3
Коммит d5abf52a20
3 изменённых файлов: 12 добавлений и 15 удалений

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

@ -526,7 +526,7 @@ BluetoothAdapter::GetPairedDevices(ErrorResult& aRv)
}
already_AddRefed<DOMRequest>
BluetoothAdapter::PairUnpair(bool aPair, BluetoothDevice& aDevice,
BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
@ -539,9 +539,6 @@ BluetoothAdapter::PairUnpair(bool aPair, BluetoothDevice& aDevice,
nsRefPtr<BluetoothVoidReplyRunnable> results =
new BluetoothVoidReplyRunnable(request);
nsAutoString addr;
aDevice.GetAddress(addr);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
@ -549,11 +546,11 @@ BluetoothAdapter::PairUnpair(bool aPair, BluetoothDevice& aDevice,
}
nsresult rv;
if (aPair) {
rv = bs->CreatePairedDeviceInternal(addr,
rv = bs->CreatePairedDeviceInternal(aDeviceAddress,
kCreatePairedDeviceTimeout,
results);
} else {
rv = bs->RemoveDeviceInternal(addr, results);
rv = bs->RemoveDeviceInternal(aDeviceAddress, results);
}
if (NS_FAILED(rv)) {
BT_WARNING("Pair/Unpair failed!");
@ -565,15 +562,15 @@ BluetoothAdapter::PairUnpair(bool aPair, BluetoothDevice& aDevice,
}
already_AddRefed<DOMRequest>
BluetoothAdapter::Pair(BluetoothDevice& aDevice, ErrorResult& aRv)
BluetoothAdapter::Pair(const nsAString& aDeviceAddress, ErrorResult& aRv)
{
return PairUnpair(true, aDevice, aRv);
return PairUnpair(true, aDeviceAddress, aRv);
}
already_AddRefed<DOMRequest>
BluetoothAdapter::Unpair(BluetoothDevice& aDevice, ErrorResult& aRv)
BluetoothAdapter::Unpair(const nsAString& aDeviceAddress, ErrorResult& aRv)
{
return PairUnpair(false, aDevice, aRv);
return PairUnpair(false, aDeviceAddress, aRv);
}
already_AddRefed<DOMRequest>

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

@ -96,9 +96,9 @@ public:
already_AddRefed<DOMRequest> StopDiscovery(ErrorResult& aRv);
already_AddRefed<DOMRequest>
Pair(BluetoothDevice& aDevice, ErrorResult& aRv);
Pair(const nsAString& aDeviceAddress, ErrorResult& aRv);
already_AddRefed<DOMRequest>
Unpair(BluetoothDevice& aDevice, ErrorResult& aRv);
Unpair(const nsAString& aDeviceAddress, ErrorResult& aRv);
already_AddRefed<DOMRequest>
GetPairedDevices(ErrorResult& aRv);
already_AddRefed<DOMRequest>
@ -170,7 +170,7 @@ private:
already_AddRefed<mozilla::dom::DOMRequest>
StartStopDiscovery(bool aStart, ErrorResult& aRv);
already_AddRefed<mozilla::dom::DOMRequest>
PairUnpair(bool aPair, BluetoothDevice& aDevice, ErrorResult& aRv);
PairUnpair(bool aPair, const nsAString& aDeviceAddress, ErrorResult& aRv);
JS::Heap<JSObject*> mJsUuids;
JS::Heap<JSObject*> mJsDeviceAddresses;

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

@ -76,9 +76,9 @@ interface BluetoothAdapter : EventTarget {
[NewObject, Throws]
DOMRequest stopDiscovery();
[NewObject, Throws]
DOMRequest pair(BluetoothDevice device);
DOMRequest pair(DOMString deviceAddress);
[NewObject, Throws]
DOMRequest unpair(BluetoothDevice device);
DOMRequest unpair(DOMString deviceAddress);
[NewObject, Throws]
DOMRequest getPairedDevices();
[NewObject, Throws]