aboutsummaryrefslogtreecommitdiffstats
path: root/components/bluetooth/lib.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-01-09 10:13:41 +0100
committerGitHub <noreply@github.com>2024-01-09 09:13:41 +0000
commit6a804cd775e3976103269ac54ae997a3accc8618 (patch)
tree1a125d1901e5aa3cc98a1f5beabebd927a3b9472 /components/bluetooth/lib.rs
parentfddc4a430fca591152c69f0793ab946dcdc81617 (diff)
downloadservo-6a804cd775e3976103269ac54ae997a3accc8618.tar.gz
servo-6a804cd775e3976103269ac54ae997a3accc8618.zip
Integrate the `devices` respository (#30974)
Despite the name of this dependency, it only handles bluetooth. Because it's a separate repository. Integrating it, allows changes here to be tested more consistently. In addition, it's likely that new bluetooth libraries will allow removing the majority of the platform-specific code in this directory. This is based on the version of this dependency from: https://github.com/servo/devices/pull/34
Diffstat (limited to 'components/bluetooth/lib.rs')
-rw-r--r--components/bluetooth/lib.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/components/bluetooth/lib.rs b/components/bluetooth/lib.rs
index e6d7a533a53..f2a7bc4de70 100644
--- a/components/bluetooth/lib.rs
+++ b/components/bluetooth/lib.rs
@@ -2,6 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+pub mod adapter;
+pub mod bluetooth;
+#[cfg(not(any(
+ all(target_os = "linux", feature = "bluetooth"),
+ all(target_os = "android", feature = "bluetooth"),
+ all(target_os = "macos", feature = "bluetooth")
+)))]
+mod empty;
+mod macros;
pub mod test;
use std::borrow::ToOwned;
@@ -20,16 +29,17 @@ use bluetooth_traits::{
BluetoothRequest, BluetoothResponse, BluetoothResponseResult, BluetoothResult,
BluetoothServiceMsg, GATTType,
};
-use device::bluetooth::{
- BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic, BluetoothGATTDescriptor,
- BluetoothGATTService,
-};
use embedder_traits::{EmbedderMsg, EmbedderProxy};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use log::warn;
use servo_config::pref;
use servo_rand::{self, Rng};
+use crate::bluetooth::{
+ BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic, BluetoothGATTDescriptor,
+ BluetoothGATTService,
+};
+
// A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed.
// https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 480)
const MAXIMUM_TRANSACTION_TIME: u8 = 30;
@@ -67,9 +77,9 @@ impl BluetoothThreadFactory for IpcSender<BluetoothRequest> {
fn new(embedder_proxy: EmbedderProxy) -> IpcSender<BluetoothRequest> {
let (sender, receiver) = ipc::channel().unwrap();
let adapter = if pref!(dom.bluetooth.enabled) {
- BluetoothAdapter::init()
+ BluetoothAdapter::new()
} else {
- BluetoothAdapter::init_mock()
+ BluetoothAdapter::new_mock()
}
.ok();
thread::Builder::new()
@@ -287,7 +297,7 @@ impl BluetoothManager {
self.cached_characteristics.clear();
self.cached_descriptors.clear();
self.allowed_services.clear();
- self.adapter = BluetoothAdapter::init_mock().ok();
+ self.adapter = BluetoothAdapter::new_mock().ok();
match test::test(self, data_set_name) {
Ok(_) => return Ok(()),
Err(error) => Err(BluetoothError::Type(error.to_string())),
@@ -324,7 +334,7 @@ impl BluetoothManager {
.as_ref()
.map_or(false, |a| a.get_address().is_ok());
if !adapter_valid {
- self.adapter = BluetoothAdapter::init().ok();
+ self.adapter = BluetoothAdapter::new().ok();
}
let adapter = self.adapter.as_ref()?;