From 994f057e41e6547608c31204c9fce3736745982c Mon Sep 17 00:00:00 2001 From: zhengzhuolan Date: Wed, 3 Sep 2025 15:43:53 +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 879442900..518fb1da2 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 @@ -908,15 +908,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