Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f41087c1 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Automerger Merge Worker
Browse files

floss: Use socket to monitor hci dev presence am: cf537fee

parents 2f250122 cf537fee
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -6,12 +6,10 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bt_common = { path = "../../common" }
bt_topshim = { path = "../../topshim" }
bt_socket = { path = "../socket" }
btstack = { path = "../stack" }
num-traits = "0.2"

# bt deps
bt_common = { path = "../../common" }

# external deps
clap = "2.33.3"
@@ -24,6 +22,7 @@ futures = "0.3.13"
inotify = "*"
log = "0.4.14"
nix = "*"
num-traits = "0.2"
protobuf = "2.0"
regex = "1.5"
serde_json = "1.0"
+12 −14
Original line number Diff line number Diff line
@@ -109,13 +109,9 @@ impl IBluetoothManager for BluetoothManager {
        self.manager_context.proxy.stop_bluetooth(hci_interface);
    }

    fn get_adapter_enabled(&mut self, _hci_interface: i32) -> bool {
        let proxy = self.manager_context.proxy.clone();

        // TODO(b/189501676) - State should depend on given adapter.
        let state = proxy.get_state();
        let result = state_machine::state_to_enabled(state);
        result
    fn get_adapter_enabled(&mut self, hci_interface: i32) -> bool {
        let state = self.manager_context.proxy.get_state(hci_interface);
        state_machine::state_to_enabled(state)
    }

    fn register_callback(&mut self, mut callback: Box<dyn IBluetoothManagerCallback + Send>) {
@@ -142,15 +138,17 @@ impl IBluetoothManager for BluetoothManager {
            if let Err(e) = Command::new("initctl").args(&["stop", BLUEZ_INIT_TARGET]).output() {
                warn!("Failed to stop bluetoothd: {}", e);
            }
            // TODO: Implement multi-hci case
            let default_device = config_util::list_hci_devices()[0];
            if config_util::is_hci_n_enabled(default_device) {
                let _ = self.manager_context.proxy.start_bluetooth(default_device);
            for hci in config_util::list_hci_devices() {
                if config_util::is_hci_n_enabled(hci) {
                    let _ = self.manager_context.proxy.start_bluetooth(hci);
                }
            }
        } else if prev != enabled {
            // TODO: Implement multi-hci case
            let default_device = config_util::list_hci_devices()[0];
            self.manager_context.proxy.stop_bluetooth(default_device);
            for hci in config_util::list_hci_devices() {
                if config_util::is_hci_n_enabled(hci) {
                    let _ = self.manager_context.proxy.stop_bluetooth(hci);
                }
            }
            if let Err(e) = Command::new("initctl").args(&["start", BLUEZ_INIT_TARGET]).output() {
                warn!("Failed to start bluetoothd: {}", e);
            }
+395 −298

File changed.

Preview size limit exceeded, changes collapsed.