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

Commit 65d20ea8 authored by Sonny Sasaka's avatar Sonny Sasaka Committed by Automerger Merge Worker
Browse files

Merge "Floss: Fix deadlock in powerd suspend manager" am: 0fcf1bd7 am:...

Merge "Floss: Fix deadlock in powerd suspend manager" am: 0fcf1bd7 am: 3257e498 am: 7a3cb957 am: 820bf324

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2103270



Change-Id: I6bbd4623e5f1590f9d39644b77db91f0420631ba
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a6d00e93 820bf324
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -428,7 +428,11 @@ impl PowerdSuspendManager {

        self.context.lock().unwrap().pending_suspend_imminent = Some(suspend_imminent.clone());

        if let Some(adapter_suspend_dbus) = &self.context.lock().unwrap().adapter_suspend_dbus {
        {
            // Anonymous block to contain locked `self.context` which needs to be called multiple
            // times in the `if let` block below. Prevent deadlock by locking only once.
            let context_locked = self.context.lock().unwrap();
            if let Some(adapter_suspend_dbus) = &context_locked.adapter_suspend_dbus {
                let adapter_suspend_id =
                    adapter_suspend_dbus.suspend(match suspend_imminent.get_reason() {
                        SuspendImminent_Reason::IDLE => SuspendType::Connected,
@@ -437,10 +441,10 @@ impl PowerdSuspendManager {
                    });
                log::debug!("Adapter suspend id = {}", adapter_suspend_id);
            } else {
            // If there is no adapter, that means Bluetooth is not active and we should always tell
            // powerd that we are ready to suspend.
                // If there is no adapter, that means Bluetooth is not active and we should always
                // tell powerd that we are ready to suspend.
                log::debug!("Adapter not available, suspend is ready.");
            if let Some(session) = &self.context.lock().unwrap().powerd_session {
                if let Some(session) = &context_locked.powerd_session {
                    send_handle_suspend_readiness(
                        session.powerd_proxy.clone(),
                        session.delay_id,
@@ -451,6 +455,7 @@ impl PowerdSuspendManager {
                }
            }
        }
    }

    fn on_suspend_done(&mut self, suspend_done: SuspendDone) {
        // powerd is telling us that suspend is done (system has resumed), so we tell btadapterd