From 118efdae2f3f30ef2c136ea409893d4674f4ba15 Mon Sep 17 00:00:00 2001 From: ECQZXC Date: Tue, 21 Jan 2025 10:45:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AC=94=E8=AE=B0?= =?UTF-8?q?=E6=9C=AC=E6=8F=92=E6=8B=94=E5=A4=96=E6=8E=A5=E7=94=B5=E6=BA=90?= =?UTF-8?q?=E6=97=B6,=E5=B1=8F=E5=B9=95=E8=87=AA=E5=8A=A8=E5=8F=98?= =?UTF-8?q?=E4=B8=BA=E5=BE=85=E6=9C=BA=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 休眠盒盖状态未更新 Log: pms: Bug-301633 --- session/power1/lid_switch.go | 16 ++++++++++------ session/power1/manager.go | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/session/power1/lid_switch.go b/session/power1/lid_switch.go index 1260efe54..c44ab003a 100644 --- a/session/power1/lid_switch.go +++ b/session/power1/lid_switch.go @@ -50,10 +50,20 @@ func (h *LidSwitchHandler) Start() error { } func (h *LidSwitchHandler) onLidClosed() { + m := h.manager + m.PropsMu.Lock() + m.lidSwitchState = lidSwitchStateClose + m.PropsMu.Unlock() + logger.Info("Lid Closed") h.onLidDelayOperate(false) } func (h *LidSwitchHandler) onLidOpened() { + m := h.manager + m.PropsMu.Lock() + m.lidSwitchState = lidSwitchStateOpen + m.PropsMu.Unlock() + logger.Info("Lid Opened") h.onLidDelayOperate(true) } @@ -93,9 +103,6 @@ func (h *LidSwitchHandler) doLidStateChanged(state bool) { // 合盖 if !state { m.setPrepareSuspend(suspendStateLidClose) - m.PropsMu.Lock() - m.lidSwitchState = lidSwitchStateClose - m.PropsMu.Unlock() m.claimOrReleaseAmbientLight() var lidCloseAction int32 @@ -111,9 +118,6 @@ func (h *LidSwitchHandler) doLidStateChanged(state bool) { } } else { // 开盖 m.setPrepareSuspend(suspendStateLidOpen) - m.PropsMu.Lock() - m.lidSwitchState = lidSwitchStateOpen - m.PropsMu.Unlock() m.claimOrReleaseAmbientLight() err := h.stopAskUser() diff --git a/session/power1/manager.go b/session/power1/manager.go index f66ee61a1..17c98766d 100644 --- a/session/power1/manager.go +++ b/session/power1/manager.go @@ -529,6 +529,10 @@ func (m *Manager) listenEventToHandleIdleOff() error { } func (m *Manager) doLidClosedAction(action int32) { + if !m.sessionActive { + return + } + switch action { case powerActionShutdown: m.doShutdown()