Loading system/gd/rust/linux/mgmt/src/powerd_suspend_manager.rs +24 −19 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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, Loading @@ -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 Loading Loading
system/gd/rust/linux/mgmt/src/powerd_suspend_manager.rs +24 −19 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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, Loading @@ -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 Loading