From 6814b33eaed1b022857363fba3ca73aae9d2e0a8 Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Tue, 15 Mar 2022 17:31:53 +0800 Subject: [PATCH] get notification enable modify Signed-off-by: fangJinliang1 Change-Id: I0254c5bf3e8d505a6037cc1916d096e2711e2ebc Signed-off-by: fangJinliang1 --- .../include/advanced_notification_service.h | 2 ++ .../ans/src/advanced_notification_service.cpp | 33 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 73aa6acaf..2173274d0 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -213,6 +213,8 @@ private: ErrCode GetDoNotDisturbDateByUser(const int32_t &userId, sptr &date); ErrCode SetHasPoppedDialog(const sptr bundleOption, bool hasPopped); ErrCode GetHasPoppedDialog(const sptr bundleOption, bool &hasPopped); + ErrCode GetAppTargetBundle(const sptr &bundleOption, + sptr &targetBundle); private: static sptr instance_; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 439022d77..85154907c 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1547,17 +1547,14 @@ ErrCode AdvancedNotificationService::IsAllowedNotifySelf(bool &allowed) return result; } -ErrCode AdvancedNotificationService::IsSpecialBundleAllowedNotify( - const sptr &bundleOption, bool &allowed) +ErrCode AdvancedNotificationService::GetAppTargetBundle(const sptr &bundleOption, + sptr &targetBundle) { - ANS_LOGD("%{public}s", __FUNCTION__); - sptr clientBundle = GenerateBundleOption(); if (clientBundle == nullptr) { return ERR_ANS_INVALID_BUNDLE; } - sptr targetBundle = nullptr; if (bundleOption == nullptr) { targetBundle = clientBundle; } else { @@ -1568,12 +1565,32 @@ ErrCode AdvancedNotificationService::IsSpecialBundleAllowedNotify( if (!IsSystemApp()) { return ERR_ANS_NON_SYSTEM_APP; } - if (!CheckPermission()) { - return ERR_ANS_PERMISSION_DENIED; - } targetBundle = GenerateValidBundleOption(bundleOption); } } + return ERR_OK; +} + +ErrCode AdvancedNotificationService::IsSpecialBundleAllowedNotify( + const sptr &bundleOption, bool &allowed) +{ + ANS_LOGD("%{public}s", __FUNCTION__); + + if (!CheckPermission()) { + return ERR_ANS_PERMISSION_DENIED; + } + + sptr targetBundle = nullptr; + if (IPCSkeleton::GetCallingUid() == SYSTEM_SERVICE_UID) { + if (bundleOption != nullptr) { + targetBundle = GenerateValidBundleOption(bundleOption); + } + } else { + ErrCode result = GetAppTargetBundle(bundleOption, targetBundle); + if (result != ERR_OK) { + return result; + } + } if (targetBundle == nullptr) { return ERR_ANS_INVALID_BUNDLE; -- Gitee