mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Check if the BluetoothDevice is connected, when calling getGATT functions.
This commit is contained in:
parent
11dbb7120f
commit
b72dcf326b
15 changed files with 28 additions and 50 deletions
|
@ -87,6 +87,9 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
|
||||
return Err(Security)
|
||||
}
|
||||
if !self.Service().Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetDescriptor(self.get_instance_id(), uuid, sender)).unwrap();
|
||||
|
@ -117,6 +120,9 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
}
|
||||
}
|
||||
};
|
||||
if !self.Service().Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetDescriptors(self.get_instance_id(), uuid, sender)).unwrap();
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMet
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::{self, Security};
|
||||
use dom::bindings::error::Error::{self, Network, Security};
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
|
@ -72,6 +72,9 @@ impl BluetoothRemoteGATTServer {
|
|||
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
|
||||
return Err(Security)
|
||||
}
|
||||
if !self.Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetPrimaryService(String::from(self.Device().Id()), uuid, sender)).unwrap();
|
||||
|
@ -103,6 +106,9 @@ impl BluetoothRemoteGATTServer {
|
|||
}
|
||||
}
|
||||
};
|
||||
if !self.Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetPrimaryServices(String::from(self.Device().Id()), uuid, sender)).unwrap();
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::error::Error::{self, Security};
|
||||
use dom::bindings::error::Error::{self, Network, Security};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
|
@ -76,6 +78,9 @@ impl BluetoothRemoteGATTService {
|
|||
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
|
||||
return Err(Security)
|
||||
}
|
||||
if !self.Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetCharacteristic(self.get_instance_id(), uuid, sender)).unwrap();
|
||||
|
@ -118,6 +123,9 @@ impl BluetoothRemoteGATTService {
|
|||
}
|
||||
}
|
||||
};
|
||||
if !self.Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let mut characteristics = vec!();
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
|
@ -159,6 +167,9 @@ impl BluetoothRemoteGATTService {
|
|||
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
|
||||
return Err(Security)
|
||||
}
|
||||
if !self.Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetIncludedService(self.get_instance_id(),
|
||||
|
@ -192,6 +203,9 @@ impl BluetoothRemoteGATTService {
|
|||
}
|
||||
}
|
||||
};
|
||||
if !self.Device().Gatt().Connected() {
|
||||
return Err(Network)
|
||||
}
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::GetIncludedServices(self.get_instance_id(),
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before.html]
|
||||
type: testharness
|
||||
[disconnect() called before getCharacteristic. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before-with-uuid.html]
|
||||
type: testharness
|
||||
[disconnect() called before getCharacteristics. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before.html]
|
||||
type: testharness
|
||||
[disconnect() called before getCharacteristics. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before.html]
|
||||
type: testharness
|
||||
[disconnect() called before getDescriptor. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before-with-uuid.html]
|
||||
type: testharness
|
||||
[disconnect() called before getDescriptors. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before.html]
|
||||
type: testharness
|
||||
[disconnect() called before getDescriptors. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before.html]
|
||||
type: testharness
|
||||
[disconnect() called before getPrimaryService. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnected-device.html]
|
||||
type: testharness
|
||||
[getPrimaryService called before connecting. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before-with-uuid.html]
|
||||
type: testharness
|
||||
[disconnect() called before getPrimaryServices. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnect-called-before.html]
|
||||
type: testharness
|
||||
[disconnect() called before getPrimaryServices. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnected-device-with-uuid.html]
|
||||
type: testharness
|
||||
[getPrimaryServices called before connecting. Reject with NetworkError.]
|
||||
expected: FAIL
|
|
@ -1,4 +0,0 @@
|
|||
[disconnected-device.html]
|
||||
type: testharness
|
||||
[getPrimaryServices called before connecting. Reject with NetworkError.]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue