mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
WebBluetooth Android support
This commit is contained in:
parent
5f702d6e7f
commit
ccc66d0c32
6 changed files with 50 additions and 24 deletions
|
@ -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(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
15
components/servo/Cargo.lock
generated
15
components/servo/Cargo.lock
generated
|
@ -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"
|
||||
|
|
15
ports/cef/Cargo.lock
generated
15
ports/cef/Cargo.lock
generated
|
@ -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)" = "<none>"
|
||||
"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
|
||||
|
|
|
@ -135,6 +135,15 @@ class PackageCommands(CommandBase):
|
|||
|
||||
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,
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
<uses-sdk android:minSdkVersion="18" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"></uses-feature>
|
||||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||
|
||||
<application android:label="Servo" android:icon="@mipmap/servo">
|
||||
<activity android:name="com.mozilla.servo.MainActivity"
|
||||
|
|
|
@ -13,6 +13,7 @@ public class MainActivity extends android.app.NativeActivity {
|
|||
private static final String LOGTAG="servo_wrapper";
|
||||
static {
|
||||
Log.i(LOGTAG, "Loading the NativeActivity");
|
||||
System.loadLibrary("main");
|
||||
}
|
||||
|
||||
private void set_url(String url) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue