Auto merge of #12875 - dati91:android, r=larsbergstrom

WebBluetooth Android support

<!-- Please describe your changes on the following line: -->
Add android support for Webbluetooth.
Also adjust to the changed device api.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because there is no test api yet.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12875)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-06 10:44:41 -05:00 committed by GitHub
commit 057bcddd0f
6 changed files with 50 additions and 24 deletions

View file

@ -4,7 +4,6 @@
use device::bluetooth::BluetoothAdapter;
use device::bluetooth::BluetoothDevice;
use device::bluetooth::BluetoothDiscoverySession;
use device::bluetooth::BluetoothGATTCharacteristic;
use device::bluetooth::BluetoothGATTDescriptor;
use device::bluetooth::BluetoothGATTService;
@ -294,8 +293,8 @@ impl BluetoothManager {
None => vec!(),
};
for service in &services {
self.cached_services.insert(service.get_object_path(), service.clone());
self.service_to_device.insert(service.get_object_path(), device_id.to_owned());
self.cached_services.insert(service.get_id(), service.clone());
self.service_to_device.insert(service.get_id(), device_id.to_owned());
}
services
}
@ -332,8 +331,8 @@ impl BluetoothManager {
};
for characteristic in &characteristics {
self.cached_characteristics.insert(characteristic.get_object_path(), characteristic.clone());
self.characteristic_to_service.insert(characteristic.get_object_path(), service_id.to_owned());
self.cached_characteristics.insert(characteristic.get_id(), characteristic.clone());
self.characteristic_to_service.insert(characteristic.get_id(), service_id.to_owned());
}
characteristics
}
@ -395,8 +394,8 @@ impl BluetoothManager {
};
for descriptor in &descriptors {
self.cached_descriptors.insert(descriptor.get_object_path(), descriptor.clone());
self.descriptor_to_characteristic.insert(descriptor.get_object_path(), characteristic_id.to_owned());
self.cached_descriptors.insert(descriptor.get_id(), descriptor.clone());
self.descriptor_to_characteristic.insert(descriptor.get_id(), characteristic_id.to_owned());
}
descriptors
}
@ -432,7 +431,7 @@ impl BluetoothManager {
options: RequestDeviceoptions,
sender: IpcSender<BluetoothResult<BluetoothDeviceMsg>>) {
let mut adapter = get_adapter_or_return_error!(self, sender);
if let Some(ref session) = BluetoothDiscoverySession::create_session(adapter.get_object_path()).ok() {
if let Ok(ref session) = adapter.create_discovery_session() {
if session.start_discovery().is_ok() {
thread::sleep(Duration::from_millis(DISCOVERY_TIMEOUT_MS));
}
@ -526,7 +525,7 @@ impl BluetoothManager {
return drop(sender.send(Ok(BluetoothServiceMsg {
uuid: uuid,
is_primary: true,
instance_id: service.get_object_path(),
instance_id: service.get_id(),
})));
}
}
@ -558,7 +557,7 @@ impl BluetoothManager {
services_vec.push(BluetoothServiceMsg {
uuid: uuid,
is_primary: true,
instance_id: service.get_object_path(),
instance_id: service.get_id(),
});
}
}
@ -589,7 +588,7 @@ impl BluetoothManager {
return drop(sender.send(Ok(BluetoothServiceMsg {
uuid: uuid,
is_primary: service.is_primary().unwrap_or(false),
instance_id: service.get_object_path(),
instance_id: service.get_id(),
})));
}
}
@ -616,7 +615,7 @@ impl BluetoothManager {
services_vec.push(BluetoothServiceMsg {
uuid: service_uuid,
is_primary: service.is_primary().unwrap_or(false),
instance_id: service.get_object_path(),
instance_id: service.get_id(),
});
}
}
@ -644,7 +643,7 @@ impl BluetoothManager {
let properties = self.get_characteristic_properties(&characteristic);
let message = Ok(BluetoothCharacteristicMsg {
uuid: uuid,
instance_id: characteristic.get_object_path(),
instance_id: characteristic.get_id(),
broadcast: properties.contains(BROADCAST),
read: properties.contains(READ),
write_without_response: properties.contains(WRITE_WITHOUT_RESPONSE),
@ -680,7 +679,7 @@ impl BluetoothManager {
characteristics_vec.push(
BluetoothCharacteristicMsg {
uuid: uuid,
instance_id: characteristic.get_object_path(),
instance_id: characteristic.get_id(),
broadcast: properties.contains(BROADCAST),
read: properties.contains(READ),
write_without_response: properties.contains(WRITE_WITHOUT_RESPONSE),
@ -713,7 +712,7 @@ impl BluetoothManager {
if let Ok(uuid) = descriptor.get_uuid() {
return drop(sender.send(Ok(BluetoothDescriptorMsg {
uuid: uuid,
instance_id: descriptor.get_object_path(),
instance_id: descriptor.get_id(),
})));
}
}
@ -737,7 +736,7 @@ impl BluetoothManager {
if let Ok(uuid) = descriptor.get_uuid() {
descriptors_vec.push(BluetoothDescriptorMsg {
uuid: uuid,
instance_id: descriptor.get_object_path(),
instance_id: descriptor.get_id(),
});
}
}

View file

@ -180,9 +180,14 @@ name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "blurdroid"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "blurz"
version = "0.1.7"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dbus 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -477,9 +482,10 @@ dependencies = [
[[package]]
name = "device"
version = "0.0.1"
source = "git+https://github.com/servo/devices#09ab8682bddfa73ba36025a150625504212d34da"
source = "git+https://github.com/servo/devices#6d40b1412fb496b0d9434ee2f46e9dfc4dc67ae7"
dependencies = [
"blurz 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"blurdroid 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"blurz 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2728,7 +2734,8 @@ dependencies = [
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
"checksum blurz 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a18fbcef6db7f58d135f77ad561e8f9b7fc809c91619c33422714cf5548004ed"
"checksum blurdroid 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5fce4ea3366b583e9d49e1aa3a42252e53b42911bccd06f31c3e81c48ccfc79e"
"checksum blurz 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96134f6ac62fa6925761dbdb4096617d65d7c1d383d90e5c2d4c489919f773dc"
"checksum brotli 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "bff2d5511b5ba5840f46cc3f9c0c3ab09db20e9b9a4db344ef7df3fb547a627a"
"checksum browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)" = "<none>"
"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"