Skip to content

Commit 9041142

Browse files
committed
fix: 修复笔记本插拔外接电源时,屏幕自动变为待机状态
休眠盒盖状态未更新 Log: pms: Bug-301633
1 parent e443a4e commit 9041142

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

session/power1/lid_switch.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,20 @@ func (h *LidSwitchHandler) Start() error {
5050
}
5151

5252
func (h *LidSwitchHandler) onLidClosed() {
53+
m := h.manager
54+
m.PropsMu.Lock()
55+
m.lidSwitchState = lidSwitchStateClose
56+
m.PropsMu.Unlock()
57+
logger.Info("Lid Closed")
5358
h.onLidDelayOperate(false)
5459
}
5560

5661
func (h *LidSwitchHandler) onLidOpened() {
62+
m := h.manager
63+
m.PropsMu.Lock()
64+
m.lidSwitchState = lidSwitchStateOpen
65+
m.PropsMu.Unlock()
66+
logger.Info("Lid Opened")
5767
h.onLidDelayOperate(true)
5868
}
5969

@@ -93,9 +103,6 @@ func (h *LidSwitchHandler) doLidStateChanged(state bool) {
93103
// 合盖
94104
if !state {
95105
m.setPrepareSuspend(suspendStateLidClose)
96-
m.PropsMu.Lock()
97-
m.lidSwitchState = lidSwitchStateClose
98-
m.PropsMu.Unlock()
99106
m.claimOrReleaseAmbientLight()
100107

101108
var lidCloseAction int32
@@ -111,9 +118,6 @@ func (h *LidSwitchHandler) doLidStateChanged(state bool) {
111118
}
112119
} else { // 开盖
113120
m.setPrepareSuspend(suspendStateLidOpen)
114-
m.PropsMu.Lock()
115-
m.lidSwitchState = lidSwitchStateOpen
116-
m.PropsMu.Unlock()
117121
m.claimOrReleaseAmbientLight()
118122

119123
err := h.stopAskUser()

session/power1/manager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,10 @@ func (m *Manager) listenEventToHandleIdleOff() error {
529529
}
530530

531531
func (m *Manager) doLidClosedAction(action int32) {
532+
if !m.sessionActive {
533+
return
534+
}
535+
532536
switch action {
533537
case powerActionShutdown:
534538
m.doShutdown()

0 commit comments

Comments
 (0)