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

Commit c8eb2930 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

floss: Convert some hard failures to soft failures

* Don't panic if starting/stopping BlueZ fails
* Don't panic if starting/stopping btadapterd fails

Bug: 209475048
Tag: #floss
Test: Run chrome on gLinux with btmanagerd running.

Change-Id: I505d2fbc76e83ce17434ee975f4a83ca4c003448
parent 23ccbad0
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
use log::{error, info};
use log::{error, info, warn};

use manager_service::iface_bluetooth_manager::{
    AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback,
@@ -123,10 +123,9 @@ impl IBluetoothManager for BluetoothManager {
        let prev = self.manager_context.floss_enabled.swap(enabled, Ordering::Relaxed);
        config_util::write_floss_enabled(enabled);
        if prev != enabled && enabled {
            Command::new("initctl")
                .args(&["stop", BLUEZ_INIT_TARGET])
                .output()
                .expect("failed to stop bluetoothd");
            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) {
@@ -136,10 +135,9 @@ impl IBluetoothManager for BluetoothManager {
            // TODO: Implement multi-hci case
            let default_device = config_util::list_hci_devices()[0];
            self.manager_context.proxy.stop_bluetooth(default_device);
            Command::new("initctl")
                .args(&["start", BLUEZ_INIT_TARGET])
                .output()
                .expect("failed to start bluetoothd");
            if let Err(e) = Command::new("initctl").args(&["start", BLUEZ_INIT_TARGET]).output() {
                warn!("Failed to start bluetoothd: {}", e);
            }
        }
    }

+8 −4
Original line number Diff line number Diff line
@@ -495,17 +495,21 @@ impl UpstartInvoker {

impl ProcessManager for UpstartInvoker {
    fn start(&mut self, hci_interface: String) {
        Command::new("initctl")
        if let Err(e) = Command::new("initctl")
            .args(&["start", "btadapterd", format!("HCI={}", hci_interface).as_str()])
            .output()
            .expect("failed to start bluetooth");
        {
            error!("Failed to start btadapterd: {}", e);
        }
    }

    fn stop(&mut self, hci_interface: String) {
        Command::new("initctl")
        if let Err(e) = Command::new("initctl")
            .args(&["stop", "btadapterd", format!("HCI={}", hci_interface).as_str()])
            .output()
            .expect("failed to stop bluetooth");
        {
            error!("Failed to stop btadapterd: {}", e);
        }
    }
}