From 708a2f40217cab7f3c705ef9e83e8b81c69f6c05 Mon Sep 17 00:00:00 2001 From: z30053788 Date: Sun, 11 Aug 2024 17:20:54 +0800 Subject: [PATCH] update Signed-off-by: z30053788 Change-Id: Icc5d46ae005e097a89bdabac88fdadbf5572a717 --- .../notification_preferences_database.h | 1 - .../ans/src/advanced_notification_utils.cpp | 31 +++---------------- .../src/notification_preferences_database.cpp | 19 +----------- 3 files changed, 5 insertions(+), 46 deletions(-) diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index f4ecb94f3..3a7a668ff 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -303,7 +303,6 @@ private: void ParseSlotFlags(sptr &slot, const std::string &value) const; void ParseSlotAuthorizedStatus(sptr &slot, const std::string &value) const; void ParseSlotAuthHitnCnt(sptr &slot, const std::string &value) const; - void ParseSlotReminderMode(sptr &slot, const std::string &value) const; std::string GenerateBundleLablel(const NotificationPreferencesInfo::BundleInfo &bundleInfo) const; std::string GenerateBundleLablel(const NotificationPreferencesInfo::BundleInfo &bundleInfo, diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index decf7240d..1793f1ee6 100644 --- a/services/ans/src/advanced_notification_utils.cpp +++ b/services/ans/src/advanced_notification_utils.cpp @@ -644,37 +644,14 @@ void AdvancedNotificationService::OnBundleDataUpdate(const sptrGetHasPoppedDialog(bundleOption, hasPopped); + bool enabled = false; + auto errCode = NotificationPreferences::GetInstance()->GetNotificationsEnabledForBundle( + bundleOption, enabled); if (errCode != ERR_OK) { ANS_LOGD("Get notification user option fail, need to insert data"); - errCode = NotificationPreferences::GetInstance()->SetNotificationsEnabledForBundle( - bundleOption, bundleInfo.applicationInfo.allowEnableNotification); - if (errCode != ERR_OK) { - ANS_LOGE("Set notification enable error! code: %{public}d", errCode); - } - SetSlotFlagsTrustlistsAsBundle(bundleOption); - errCode = NotificationPreferences::GetInstance()->SetShowBadge(bundleOption, true); - if (errCode != ERR_OK) { - ANS_LOGE("Set badge enable error! code: %{public}d", errCode); - } + OnBundleDataAdd(bundleOption); return; } - - if (hasPopped) { - ANS_LOGI("The user has made changes, subject to the user's selection"); - return; - } - - errCode = NotificationPreferences::GetInstance()->SetNotificationsEnabledForBundle( - bundleOption, bundleInfo.applicationInfo.allowEnableNotification); - if (errCode != ERR_OK) { - ANS_LOGE("Set notification enable error! code: %{public}d", errCode); - } - errCode = NotificationPreferences::GetInstance()->SetShowBadge(bundleOption, true); - if (errCode != ERR_OK) { - ANS_LOGE("Set badge enable error! code: %{public}d", errCode); - } }; notificationSvrQueue_ != nullptr ? notificationSvrQueue_->submit(bundleUpdate) : bundleUpdate(); diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index e80541632..e7b3b4204 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -214,11 +214,6 @@ const static std::string KEY_SLOT_AUTHORIZED_STATUS = "authorizedStatus"; */ const static std::string KEY_SLOT_AUTH_HINT_CNT = "authHintCnt"; -/** - * Indicates that reminder mode of slot. - */ -const static std::string KEY_REMINDER_MODE = "reminderMode"; - constexpr char RELATIONSHIP_JSON_KEY_SERVICE[] = "service"; constexpr char RELATIONSHIP_JSON_KEY_APP[] = "app"; @@ -970,8 +965,6 @@ void NotificationPreferencesDatabase::GenerateSlotEntry(const std::string &bundl std::to_string(slot->GetAuthorizedStatus()), values); GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_AUTH_HINT_CNT), std::to_string(slot->GetAuthHintCnt()), values); - GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_REMINDER_MODE), - std::to_string(slot->GetReminderMode()), values); } void NotificationPreferencesDatabase::ParseBundleFromDistureDB(NotificationPreferencesInfo &info, @@ -1026,6 +1019,7 @@ void NotificationPreferencesDatabase::ParseSlotFromDisturbeDB(NotificationPrefer } std::string findString = GenerateSlotKey(bundleKey, typeStr) + KEY_UNDER_LINE; ParseSlot(findString, slot, entry, userId); + slot->SetReminderMode(bundleInfo->GetSlotFlags()); bundleInfo.SetSlot(slot); } @@ -1125,9 +1119,6 @@ void NotificationPreferencesDatabase::SetSoltProperty(sptr &sl void NotificationPreferencesDatabase::ExecuteDisturbeDB(sptr &slot, std::string &typeStr, std::string &valueStr, const std::string &findString, const int32_t &userId) { - if (typeStr.compare(KEY_REMINDER_MODE) == 0) { - return ParseSlotReminderMode(slot, valueStr); - } if (!typeStr.compare(KEY_SLOT_VIBRATION_STYLE)) { GetValueFromDisturbeDB(findString + KEY_SLOT_ENABLE_VRBRATION, userId, [&](std::string &value) { ParseSlotEnableVrbration(slot, value); }); @@ -1421,14 +1412,6 @@ void NotificationPreferencesDatabase::ParseSlotAuthHitnCnt( slot->SetAuthHintCnt(count); } -void NotificationPreferencesDatabase::ParseSlotReminderMode( - sptr &slot, const std::string &value) const -{ - ANS_LOGD("ParseSlotReminderMode slot reminder mode is %{public}s.", value.c_str()); - int32_t reminderMode = static_cast(StringToInt(value)); - slot->SetReminderMode(reminderMode); -} - std::string NotificationPreferencesDatabase::GenerateBundleLablel( const NotificationPreferencesInfo::BundleInfo &bundleInfo) const { -- Gitee