diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index f4ecb94f3d3dd78d88913968106e0004f3638477..3a7a668ff406297c58686252c8f816c9e62fe163 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 decf7240db4ef9590049a95a8b889eda82c13705..1793f1ee60e09ded39ec42b7f8a676262d1fc12d 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 e805416323a5d21b30a5128c91d78ddb532e94e8..e7b3b42045a86f248b434d8f733fe110b5762592 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 {