From ccc66d0c3202641ae6079aa169a46540f00d8c73 Mon Sep 17 00:00:00 2001 From: Attila Dusnoki Date: Mon, 15 Aug 2016 14:59:22 +0200 Subject: [PATCH] WebBluetooth Android support --- components/net/bluetooth_thread.rs | 31 +++++++++---------- components/servo/Cargo.lock | 15 ++++++--- ports/cef/Cargo.lock | 15 ++++++--- python/servo/package_commands.py | 9 ++++++ support/android/apk/AndroidManifest.xml | 3 ++ .../src/com/mozilla/servo/MainActivity.java | 1 + 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/components/net/bluetooth_thread.rs b/components/net/bluetooth_thread.rs index 3c2538b1f88b..51226e21d902 100644 --- a/components/net/bluetooth_thread.rs +++ b/components/net/bluetooth_thread.rs @@ -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>) { 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(), }); } } diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 01de19d553bb..475f5dfc7d92 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -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)" = "" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index b6309194def6..bec408e86580 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -154,9 +154,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)", @@ -435,9 +440,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]] @@ -2588,7 +2594,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)" = "" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 5b1a75b6301d..fbc659d56963 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -135,6 +135,15 @@ def package(self, release=False, dev=False, android=None, debug=False, debugger= target_dir = path.dirname(binary_path) output_apk = "{}.apk".format(binary_path) + blurdroid_path = find_dep_path_newest('blurdroid', binary_path) + if blurdroid_path is None: + print("Could not find blurdroid package; perhaps you haven't built Servo.") + return 1 + else: + dir_to_libs = path.join("support", "android", "apk", "libs") + if not path.exists(dir_to_libs): + os.makedirs(dir_to_libs) + shutil.copy2(blurdroid_path + '/out/blurdroid.jar', dir_to_libs) try: with cd(path.join("support", "android", "build-apk")): subprocess.check_call(["cargo", "run", "--", dev_flag, "-o", output_apk, "-t", target_dir, diff --git a/support/android/apk/AndroidManifest.xml b/support/android/apk/AndroidManifest.xml index 10e31d7ea83c..9f2eea71e975 100644 --- a/support/android/apk/AndroidManifest.xml +++ b/support/android/apk/AndroidManifest.xml @@ -8,9 +8,12 @@ + + +