Skip to content

Commit c1f483c

Browse files
committed
fix: handle notification closed signal properly
Added connection to the NotificationClosed signal in initNotifications function to properly handle when notifications are closed. When a notification is closed, the globalNotifyId should be reset to 0 to prevent stale notification ID references. This ensures the system correctly tracks active notifications and avoids potential issues with notification management. Influence: 1. Test notification creation and closure scenarios 2. Verify globalNotifyId is properly reset when notifications are closed 3. Check for any race conditions in notification ID management 4. Ensure notification system stability after multiple open/close cycles fix: 正确处理通知关闭信号 在 initNotifications 函数中添加了对 NotificationClosed 信号的连接,以正 确处理通知关闭事件。当通知被关闭时,需要将 globalNotifyId 重置为 0,以 防止过时的通知ID引用。这确保系统能正确跟踪活动通知,避免通知管理中的潜在 问题。 主要为了,蓝牙模块在连接后,通知发出来后,此时等待通知bubble消失,然后断开蓝牙连接,会导致通知读取不到原来窗口,导致不显示窗口, 目前处理是监听通知横幅关闭,从而重置窗口id,保证断开后能够显示正确一个新窗口。 PMS: BUG-352131
1 parent c225f14 commit c1f483c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

bluetooth1/utils_notify.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -64,6 +64,17 @@ func initNotifications() error {
6464
logger.Warningf("listen action invoked failed,err:%v", err)
6565
}
6666

67+
_, err = globalNotifications.ConnectNotificationClosed(func(id uint32, reason uint32) {
68+
globalNotifyMu.Lock()
69+
if globalNotifyId == id {
70+
globalNotifyId = 0
71+
}
72+
globalNotifyMu.Unlock()
73+
})
74+
if err != nil {
75+
logger.Warningf("listen notification closed failed,err:%v", err)
76+
}
77+
6778
return nil
6879
}
6980

0 commit comments

Comments
 (0)