From 91d99e0645ff30326b0b0ec0dd16f099ea816fc8 Mon Sep 17 00:00:00 2001 From: z00454238 Date: Sat, 14 Jun 2025 18:58:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20Signed-off-by:=20z00454238=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bundle.json | 2 +- frameworks/ans/IAnsManager.idl | 2 +- .../notification_preferences_database.h | 2 ++ .../advanced_notification_publish_service.cpp | 11 ++++++++++ .../ans/src/enable_manager/enable_manager.cpp | 2 ++ .../ans/src/notification_dialog_manager.cpp | 2 ++ .../src/notification_extension_wrapper.cpp | 2 +- services/ans/src/notification_preferences.cpp | 22 +++++++++---------- .../src/notification_preferences_database.cpp | 2 ++ 9 files changed, 33 insertions(+), 14 deletions(-) diff --git a/bundle.json b/bundle.json index 5908c6c58..7a8154240 100644 --- a/bundle.json +++ b/bundle.json @@ -44,9 +44,9 @@ "SystemCapability.Notification.NotificationSettings" ], "features": [ + "distributed_notification_service_feature_privileged_message", "distributed_notification_service_feature_additional_control", "distributed_notification_service_feature_disable_fa_model", - "distributed_notification_service_feature_privileged_message", "distributed_notification_service_disable_control", "distributed_notification_service_feature_badge_manager", "distributed_notification_service_feature_local_liveview", diff --git a/frameworks/ans/IAnsManager.idl b/frameworks/ans/IAnsManager.idl index 3668425a7..fbdcb4d8f 100644 --- a/frameworks/ans/IAnsManager.idl +++ b/frameworks/ans/IAnsManager.idl @@ -128,7 +128,7 @@ interface OHOS.Notification.IAnsManager { void SetNotificationsEnabledForAllBundles([in] String deviceId, [in] boolean enabled); void SetNotificationsEnabledForSpecialBundle( - [in] String deviceId, [in] sptr bundleOption, [in] boolean enabled, [in] boolean updateUnEnbaleTime); + [in] String deviceId, [in] sptr bundleOption, [in] boolean enabled, [in] boolean updateUnEnableTime); void SetShowBadgeEnabledForBundle([in] sptr bundleOption, [in] boolean enabled); diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index 941a6d6c6..92ed70479 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -303,7 +303,9 @@ public: int32_t SetKvToDb(const std::string &key, const std::string &value, const int32_t &userId); int32_t SetByteToDb(const std::string &key, const std::vector &value, const int32_t &userId); int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId); +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode); +#endif int32_t GetByteFromDb(const std::string &key, std::vector &value, const int32_t &userId); int32_t GetBatchKvsFromDb( const std::string &key, std::unordered_map &values, const int32_t &userId); diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index ff2ab3399..f3c889394 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -971,6 +971,17 @@ bool AdvancedNotificationService::IsDuplicateMsg(const std::list &bundleOption) +{ + ANS_LOGD("SetDialogPoppedRefuseTime called."); + int32_t userId = SUBSCRIBE_USER_INIT; + OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(bundleOption->GetUid(), userId); + EXTENTION_WRAPPER->SetDialogOpenSuccessTimeStamp(bundleOption, userId); + ANS_LOGD("SetDialogPoppedRefuseTime end."); +} +#endif + ErrCode AdvancedNotificationService::PublishRemoveDuplicateEvent(const std::shared_ptr &record) { if (record == nullptr) { diff --git a/services/ans/src/enable_manager/enable_manager.cpp b/services/ans/src/enable_manager/enable_manager.cpp index 16d71a698..4bc7c4faf 100644 --- a/services/ans/src/enable_manager/enable_manager.cpp +++ b/services/ans/src/enable_manager/enable_manager.cpp @@ -142,6 +142,7 @@ ErrCode AdvancedNotificationService::CommonRequestEnableNotification(const std:: #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER int32_t userId = -1; OsAccountManagerHelper::GetInstance().GetOsAccountLocalIdFromUid(bundleOption->GetUid(), userId); + ANS_LOGD("GetOsAccountLocalIdFromUid PRI, %{public}d, %{public}d", bundleOption->GetUid(), userId); if (!EXTENTION_WRAPPER->GetPrivilegeDialogPopped(bundleOption, userId)) { ANS_LOGE("GetPrivilegeDialogPopped false."); message.ErrorCode(ERR_ANS_NOT_ALLOWED).Append(" Has no permission popped"); @@ -347,6 +348,7 @@ ErrCode AdvancedNotificationService::CanPopEnableNotificationDialog( #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER int32_t userId = -1; OsAccountManagerHelper::GetInstance().GetOsAccountLocalIdFromUid(bundleOption->GetUid(), userId); + ANS_LOGD("GetOsAccountLocalIdFromUid PRI, %{public}d, %{public}d", bundleOption->GetUid(), userId); if (!EXTENTION_WRAPPER->GetPrivilegeDialogPopped(bundleOption, userId)) { ANS_LOGE("GetPrivilegeDialogPopped false."); message.ErrorCode(ERR_ANS_NOT_ALLOWED).Append(" Has no permission popped"); diff --git a/services/ans/src/notification_dialog_manager.cpp b/services/ans/src/notification_dialog_manager.cpp index c58cdf8d4..10639edbb 100644 --- a/services/ans/src/notification_dialog_manager.cpp +++ b/services/ans/src/notification_dialog_manager.cpp @@ -24,8 +24,10 @@ #include "notification_bundle_option.h" #include "notification_dialog.h" #include "notification_preferences.h" +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER #include "os_account_manager_helper.h" #include "notification_extension_wrapper.h" +#endif #include #include diff --git a/services/ans/src/notification_extension_wrapper.cpp b/services/ans/src/notification_extension_wrapper.cpp index 4e0028176..5398af24e 100644 --- a/services/ans/src/notification_extension_wrapper.cpp +++ b/services/ans/src/notification_extension_wrapper.cpp @@ -52,13 +52,13 @@ void UpdateUnifiedGroupInfo(const std::string &key, std::shared_ptrUpdateUnifiedGroupInfo(key, groupInfo); } +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER SYMBOL_EXPORT void GetAdditionalConfig(const std::string &key, std::string &value) { value = NotificationPreferences::GetInstance()->GetAdditionalConfig(key); ANS_LOGD("GetAdditionalConfig SYMBOL_EXPORT valiue %{public}s", value.c_str()); } -#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER SYMBOL_EXPORT int32_t SetKvToDb(const std::string &key, const std::string &value, const int32_t &userId) { return NotificationPreferences::GetInstance()->SetKvToDb(key, value, userId); diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 13404d66f..6a605aea7 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -1318,17 +1318,6 @@ int32_t NotificationPreferences::GetBatchKvsFromDbContainsKey( return preferncesDB_->GetBatchKvsFromDbContainsKey(key, values, userId); } -#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER -int32_t NotificationPreferences::GetKvFromDb( - const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode) -{ - if (preferncesDB_ == nullptr) { - return ERR_ANS_SERVICE_NOT_READY; - } - return preferncesDB_->GetKvFromDb(key, value, userId, retCode); -} -#endif - int32_t NotificationPreferences::GetBatchKvsFromDb( const std::string &key, std::unordered_map &values, const int32_t &userId) { @@ -1586,5 +1575,16 @@ bool NotificationPreferences::SetBundleRemoveFlag(const sptrSetBundleRemoveFlag(bundleOption, slotType, sourceType); } + +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER +int32_t NotificationPreferences::GetKvFromDb( + const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode) +{ + if (preferncesDB_ == nullptr) { + return ERR_ANS_SERVICE_NOT_READY; + } + return preferncesDB_->GetKvFromDb(key, value, userId, retCode); +} +#endif } // namespace Notification } // namespace OHOS diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index 53f912600..32a931dac 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -1901,6 +1901,7 @@ int32_t NotificationPreferencesDatabase::GetKvFromDb( return NativeRdb::E_OK; } +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER int32_t NotificationPreferencesDatabase::GetKvFromDb( const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode) { @@ -1912,6 +1913,7 @@ int32_t NotificationPreferencesDatabase::GetKvFromDb( retCode = rdbDataManager_->QueryData(key, value, userId); return retCode; } +#endif int32_t NotificationPreferencesDatabase::GetByteFromDb( const std::string &key, std::vector &value, const int32_t &userId) -- Gitee