From dede6c19a8d98c785e41949c74a5f131bf57d1fc Mon Sep 17 00:00:00 2001 From: zhengzhuolan Date: Sat, 13 Sep 2025 14:14:28 +0800 Subject: [PATCH] fix bug Signed-off-by: zhengzhuolan --- ...advanced_notification_distributed_manager_service.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp b/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp index 597916cbb..9a804a38d 100644 --- a/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp +++ b/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp @@ -899,15 +899,18 @@ ErrCode AdvancedNotificationService::SetDistributedAuthStatus( auto result = NotificationPreferences::GetInstance()->SetDistributedAuthStatus(deviceType, deviceId, userId, isAuth); if (result == ERR_OK) { - if (isAuth) { - UpdateDistributedDeviceList(deviceType, userId); + int32_t currentUserId = userId; + auto ret = OsAccountManagerHelper::GetInstance().GetCurrentActiveUserId(currentUserId); + if (isAuth && ret == ERR_OK) { + UpdateDistributedDeviceList(deviceType, currentUserId); } EventFwk::Want want; want.SetAction(NOTIFICATION_EVENT_DISTRIBUTED_DEVICE_TYPES_CHANGE); EventFwk::CommonEventData commonData{ want }; EventFwk::CommonEventPublishInfo publishInfo; publishInfo.SetSubscriberType(EventFwk::SubscriberType::SYSTEM_SUBSCRIBER_TYPE); - if (!EventFwk::CommonEventManager::PublishCommonEventAsUser(commonData, publishInfo, userId)) { + if (ret != ERR_OK || !EventFwk::CommonEventManager::PublishCommonEventAsUser( + commonData, publishInfo, currentUserId)) { ANS_LOGE("Publish common event failed"); } } -- Gitee