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

Commit 5db25325 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Gerrit Code Review
Browse files

Merge "floss: Increase logging in btmanagerd" into main

parents dd7865c3 3f0a4470
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -41,9 +41,9 @@ impl BluetoothManager {

    pub(crate) fn callback_hci_enabled_change(&mut self, hci_device: i32, enabled: bool) {
        if enabled {
            info!("Started {}", hci_device);
            warn!("Started {}", hci_device);
        } else {
            info!("Stopped {}", hci_device);
            warn!("Stopped {}", hci_device);
        }

        for (_, callback) in &mut self.callbacks {
@@ -72,7 +72,7 @@ impl BluetoothManager {

impl IBluetoothManager for BluetoothManager {
    fn start(&mut self, hci_interface: i32) {
        info!("Starting {}", hci_interface);
        warn!("Starting {}", hci_interface);

        if !config_util::modify_hci_n_enabled(hci_interface, true) {
            error!("Config is not successfully modified");
@@ -84,7 +84,13 @@ impl IBluetoothManager for BluetoothManager {
        self.proxy.modify_state(virt_hci, move |a: &mut AdapterState| a.config_enabled = true);

        // Ignore the request if adapter is already enabled or not present.
        if self.is_adapter_enabled(virt_hci) || !self.is_adapter_present(virt_hci) {
        if self.is_adapter_enabled(virt_hci) {
            warn!("Adapter {} is already enabled.", hci_interface);
            return;
        }

        if !self.is_adapter_present(virt_hci) {
            warn!("Adapter {} is not present.", hci_interface);
            return;
        }

@@ -92,7 +98,7 @@ impl IBluetoothManager for BluetoothManager {
    }

    fn stop(&mut self, hci_interface: i32) {
        info!("Stopping {}", hci_interface);
        warn!("Stopping {}", hci_interface);
        if !config_util::modify_hci_n_enabled(hci_interface, false) {
            error!("Config is not successfully modified");
        }
@@ -104,6 +110,7 @@ impl IBluetoothManager for BluetoothManager {

        // Ignore the request if adapter is already disabled.
        if !self.is_adapter_enabled(virt_hci) {
            warn!("Adapter {} is already stopped", hci_interface);
            return;
        }

+8 −7
Original line number Diff line number Diff line
@@ -634,7 +634,7 @@ pub async fn mainloop(
        let m = context.rx.recv().await;

        if m.is_none() {
            info!("Exiting manager mainloop");
            warn!("Exiting manager mainloop");
            break;
        }

@@ -642,13 +642,13 @@ pub async fn mainloop(

        match m.unwrap() {
            // Adapter action has changed
            Message::AdapterStateChange(action) => {
            Message::AdapterStateChange(adapter_action) => {
                // Grab previous state from lock and release
                let hci: VirtualHciIndex;
                let next_state;
                let prev_state;

                match &action {
                match &adapter_action {
                    AdapterStateActions::StartBluetooth(i) => {
                        hci = *i;
                        prev_state = context.state_machine.get_process_state(hci);
@@ -754,9 +754,10 @@ pub async fn mainloop(
                    }
                };

                debug!(
                    "[hci{}]: Took action {:?} with prev_state({:?}) and next_state({:?})",
                    hci, action, prev_state, next_state
                // All actions and the resulting state changes should be logged for debugging.
                info!(
                    "[hci{}]: Action={:?}, Previous State({:?}), Next State({:?})",
                    hci, adapter_action, prev_state, next_state
                );

                // Only emit enabled event for certain transitions
@@ -1467,7 +1468,7 @@ impl StateMachineInternal {
            // If Floss is not enabled, just send |Stop| to process manager and end the state
            // machine actions.
            ProcessState::TurningOn if !floss_enabled => {
                info!("Timed out turning on but floss is disabled: {}", hci);
                warn!("Timed out turning on but floss is disabled: {}", hci);
                self.modify_state(hci, |s: &mut AdapterState| s.state = ProcessState::Off);
                self.process_manager
                    .stop(hci.to_string(), self.get_real_hci_by_virtual_id(hci).to_string());