diff --git a/frameworks/ans/BUILD.gn b/frameworks/ans/BUILD.gn index 3e07cf3f54260c526df47a6cdd209ed53c5b440e..8f04ffc13d22788f31d27d6452f77a87f147a185 100644 --- a/frameworks/ans/BUILD.gn +++ b/frameworks/ans/BUILD.gn @@ -62,7 +62,6 @@ ohos_shared_library("ans_innerkits") { "src/notification_picture_content.cpp", "src/notification_request.cpp", "src/notification_slot.cpp", - "src/notification_slot_group.cpp", "src/notification_sorting.cpp", "src/notification_sorting_map.cpp", "src/notification_subscribe_info.cpp", diff --git a/frameworks/ans/src/notification_helper.cpp b/frameworks/ans/src/notification_helper.cpp index 330879179c1a9548f94a29339302c4e2b270babf..fb3053653e5ab1c46cf314beaabe8a896dee6ad3 100644 --- a/frameworks/ans/src/notification_helper.cpp +++ b/frameworks/ans/src/notification_helper.cpp @@ -55,31 +55,6 @@ ErrCode NotificationHelper::GetNotificationSlots(std::vector::GetInstance()->GetNotificationSlots(slots); } -ErrCode NotificationHelper::AddNotificationSlotGroup(const NotificationSlotGroup &slotGroup) -{ - return DelayedSingleton::GetInstance()->AddNotificationSlotGroup(slotGroup); -} - -ErrCode NotificationHelper::AddNotificationSlotGroups(const std::vector &slotGroups) -{ - return DelayedSingleton::GetInstance()->AddNotificationSlotGroups(slotGroups); -} - -ErrCode NotificationHelper::RemoveNotificationSlotGroup(const std::string &slotGroupId) -{ - return DelayedSingleton::GetInstance()->RemoveNotificationSlotGroup(slotGroupId); -} - -ErrCode NotificationHelper::GetNotificationSlotGroup(const std::string &groupId, sptr &group) -{ - return DelayedSingleton::GetInstance()->GetNotificationSlotGroup(groupId, group); -} - -ErrCode NotificationHelper::GetNotificationSlotGroups(std::vector> &groups) -{ - return DelayedSingleton::GetInstance()->GetNotificationSlotGroups(groups); -} - ErrCode NotificationHelper::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num) { return DelayedSingleton::GetInstance()->GetNotificationSlotNumAsBundle(bundleOption, num); @@ -259,12 +234,6 @@ ErrCode NotificationHelper::UpdateNotificationSlots( return DelayedSingleton::GetInstance()->UpdateNotificationSlots(bundleOption, slots); } -ErrCode NotificationHelper::UpdateNotificationSlotGroups( - const NotificationBundleOption &bundleOption, const std::vector> &groups) -{ - return DelayedSingleton::GetInstance()->UpdateNotificationSlotGroups(bundleOption, groups); -} - ErrCode NotificationHelper::GetAllActiveNotifications(std::vector> ¬ification) { return DelayedSingleton::GetInstance()->GetAllActiveNotifications(notification); diff --git a/frameworks/ans/src/notification_slot.cpp b/frameworks/ans/src/notification_slot.cpp index e41616918dab38dd063bc087708795b546c508fd..3bef9e5d45d10402ec0eaeccae3b69e32ff98f0d 100644 --- a/frameworks/ans/src/notification_slot.cpp +++ b/frameworks/ans/src/notification_slot.cpp @@ -149,16 +149,6 @@ void NotificationSlot::SetName(const std::string &name) name_ = TruncateString(name); } -std::string NotificationSlot::GetSlotGroup() const -{ - return groupId_; -} - -void NotificationSlot::SetSlotGroup(const std::string &groupId) -{ - groupId_ = groupId; -} - Uri NotificationSlot::GetSound() const { return sound_; @@ -226,7 +216,6 @@ std::string NotificationSlot::Dump() const ", isVibrate = " + (isVibrationEnabled_ ? "true" : "false") + ", vibration = " + MergeVectorToString(vibrationValues_) + ", isShowBadge = " + (isShowBadge_ ? "true" : "false") + - ", groupId = " + groupId_ + ", enabled = " + (enabled_ ? "true" : "false") + " }"; } @@ -288,11 +277,6 @@ bool NotificationSlot::Marshalling(Parcel &parcel) const return false; } - if (!parcel.WriteString(groupId_)) { - ANS_LOGE("Failed to write groupId"); - return false; - } - if (sound_.ToString().empty()) { if (!parcel.WriteInt32(VALUE_NULL)) { ANS_LOGE("Failed to write int"); @@ -335,7 +319,6 @@ bool NotificationSlot::ReadFromParcel(Parcel &parcel) level_ = static_cast(parcel.ReadInt32()); type_ = static_cast(parcel.ReadInt32()); lockScreenVisibleness_ = static_cast(parcel.ReadInt32()); - groupId_ = parcel.ReadString(); int32_t empty = VALUE_NULL; if (!parcel.ReadInt32(empty)) { diff --git a/frameworks/ans/src/notification_slot_group.cpp b/frameworks/ans/src/notification_slot_group.cpp deleted file mode 100644 index cb63278eb9264c8c00cafcb4dd51d63219cfe44b..0000000000000000000000000000000000000000 --- a/frameworks/ans/src/notification_slot_group.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "notification_slot_group.h" -#include "ans_log_wrapper.h" -#include "string_ex.h" - -namespace OHOS { -namespace Notification { -const int32_t MAX_TEXT_LENGTH = 1000; -const std::string LINE_SEPARATOR = "\n"; - -NotificationSlotGroup::NotificationSlotGroup() -{} - -NotificationSlotGroup::NotificationSlotGroup(const std::string &id, const std::string &name) : id_(id), name_(name) -{ - id_ = TruncateString(id); - name_ = TruncateString(name); -} - -NotificationSlotGroup::~NotificationSlotGroup() -{} - -std::string NotificationSlotGroup::GetDescription() const -{ - return description_; -} - -std::string NotificationSlotGroup::GetId() const -{ - return id_; -} - -std::string NotificationSlotGroup::GetName() const -{ - return name_; -} - -void NotificationSlotGroup::SetSlots(const std::vector &slots) -{ - slots_ = slots; -} - -std::vector NotificationSlotGroup::GetSlots() const -{ - return slots_; -} - -bool NotificationSlotGroup::IsDisabled() const -{ - return isDisabled_; -} - -void NotificationSlotGroup::SetDescription(const std::string &description) -{ - description_ = TruncateString(description); -} - -std::string NotificationSlotGroup::Dump() const -{ - std::string contents; - for (auto it = slots_.begin(); it != slots_.end(); ++it) { - contents += it->Dump(); - if (it != slots_.end() - 1) { - contents += ","; - } - } - return "NotificationSlotGroup{ " - "id = " + id_ + - ", name = " + name_ + - ", description = " + description_ + - ", slots = " + contents + - ", isDisabled = " + (isDisabled_ ? "true" : "false") + - " }"; -} - -bool NotificationSlotGroup::Marshalling(Parcel &parcel) const -{ - if (!parcel.WriteString(id_)) { - ANS_LOGE("Failed to write id"); - return false; - } - - if (!parcel.WriteString(name_)) { - ANS_LOGE("Failed to write name"); - return false; - } - - if (!parcel.WriteString(description_)) { - ANS_LOGE("Failed to write description"); - return false; - } - - if (slots_.empty()) { - if (!parcel.WriteUint64(0)) { - ANS_LOGE("Failed to write the size of slots"); - return false; - } - } else { - if (!parcel.WriteUint64(slots_.size())) { - ANS_LOGE("Failed to write the size of slots"); - return false; - } - for (size_t it = 0; it < slots_.size(); ++it) { - if (!parcel.WriteParcelable(&slots_.at(it))) { - ANS_LOGE("Failed to write slots"); - return false; - } - } - } - - if (!parcel.WriteBool(isDisabled_)) { - ANS_LOGE("Failed to write isDisabled"); - return false; - } - - return true; -} - -bool NotificationSlotGroup::ReadFromParcel(Parcel &parcel) -{ - id_ = parcel.ReadString(); - name_ = parcel.ReadString(); - description_ = parcel.ReadString(); - uint64_t size = parcel.ReadUint64(); - if (size) { - for (uint64_t i = 0; i < size; ++i) { - auto slot = parcel.ReadParcelable(); - if (slot == nullptr) { - ANS_LOGE("Failed to read slot"); - return false; - } - slots_.emplace_back(*slot); - } - } - isDisabled_ = parcel.ReadBool(); - return true; -} - -NotificationSlotGroup *NotificationSlotGroup::Unmarshalling(Parcel &parcel) -{ - NotificationSlotGroup *notificationSlotGroup = new (std::nothrow) NotificationSlotGroup(); - - if (notificationSlotGroup && !notificationSlotGroup->ReadFromParcel(parcel)) { - delete notificationSlotGroup; - notificationSlotGroup = nullptr; - } - - return notificationSlotGroup; -} - -std::string NotificationSlotGroup::TruncateString(const std::string &inPutString) -{ - std::string temp = inPutString; - if (inPutString.length() > MAX_TEXT_LENGTH) { - temp = inPutString.substr(0, MAX_TEXT_LENGTH); - } - return temp; -} -} // namespace Notification -} // namespace OHOS \ No newline at end of file diff --git a/frameworks/core/BUILD.gn b/frameworks/core/BUILD.gn index 184dadf0c757b24b719944929bbf8afaab74bb1b..77a95d3d8e5e1c223e8eb718d59192d0a7f24d50 100644 --- a/frameworks/core/BUILD.gn +++ b/frameworks/core/BUILD.gn @@ -60,7 +60,6 @@ ohos_shared_library("ans_core") { "${frameworks_module_ans_path}/src/notification_picture_content.cpp", "${frameworks_module_ans_path}/src/notification_request.cpp", "${frameworks_module_ans_path}/src/notification_slot.cpp", - "${frameworks_module_ans_path}/src/notification_slot_group.cpp", "${frameworks_module_ans_path}/src/notification_sorting.cpp", "${frameworks_module_ans_path}/src/notification_sorting_map.cpp", "${frameworks_module_ans_path}/src/notification_subscribe_info.cpp", diff --git a/frameworks/core/common/include/ans_const_define.h b/frameworks/core/common/include/ans_const_define.h index eb286069d04345e8d10e457df9023eb1ea1474b0..66454a4a09b765b7f8aaedac724d07948cff689b 100644 --- a/frameworks/core/common/include/ans_const_define.h +++ b/frameworks/core/common/include/ans_const_define.h @@ -29,7 +29,6 @@ constexpr size_t MAX_ACTIVE_NUM = 1000; constexpr uint32_t MAX_ACTIVE_NUM_PERAPP = 100; constexpr uint32_t MAX_ACTIVE_NUM_PERSECOND = 10; constexpr size_t MAX_SLOT_NUM = 5; -constexpr size_t MAX_SLOT_GROUP_NUM = 4; constexpr uint32_t MAX_ICON_SIZE = 50 * 1024; constexpr uint32_t MAX_PICTURE_SIZE = 2 * 1024 * 1024; constexpr bool SUPPORT_DO_NOT_DISTRUB = true; diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h index 376489c55cb5880366dd1dc7ba735f5f25ca0f86..afd8a3fd1900fc2fa8d873b86105036e3cd584b7 100644 --- a/frameworks/core/include/ans_manager_interface.h +++ b/frameworks/core/include/ans_manager_interface.h @@ -26,7 +26,6 @@ #include "notification_do_not_disturb_date.h" #include "notification_request.h" #include "notification_slot.h" -#include "notification_slot_group.h" #include "notification_subscribe_info.h" #include "reminder_request.h" @@ -126,16 +125,6 @@ public: */ virtual ErrCode RemoveAllSlots() = 0; - /** - * @brief Creates multiple notification slot groups. - * @note The precautions for using this method are similar to those for - * AddNotificationSlotGroup(NotificationSlotGroup). - * - * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddSlotGroups(std::vector> groups) = 0; - /** * @brief Queries a created notification slot. * @@ -154,23 +143,6 @@ public: */ virtual ErrCode GetSlots(std::vector> &slots) = 0; - /** - * @brief Queries a created notification slot group. - * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotGroup(const std::string &groupId, sptr &group) = 0; - - /** - * @brief Obtains a list of created notification slot groups. - * - * @param groups Indicates a list of created notification slot groups. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotGroups(std::vector> &groups) = 0; - /** * @brief Obtains the number of slot. * @@ -180,15 +152,6 @@ public: */ virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) = 0; - /** - * @brief Deletes multiple notification slot groups. - * - * @param groupIds Indicates the IDs of the notification slot groups, which is created by - * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveSlotGroups(const std::vector &groupIds) = 0; - /** * @brief Obtains active notifications of the current application in the system. * @@ -374,16 +337,6 @@ public: virtual ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) = 0; - /** - * @brief Update slotgroup according to bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param groups Indicates the notification slots to be updated. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode UpdateSlotGroups( - const sptr &bundleOption, const std::vector> &groups) = 0; - /** * @brief Allow notifications to be sent based on the deviceId. * diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h index 696c44c56f9b8c6adc0a6009d8906cfda12de207..59baba2a2931268f3418749566e33b633829b6f5 100644 --- a/frameworks/core/include/ans_manager_proxy.h +++ b/frameworks/core/include/ans_manager_proxy.h @@ -113,16 +113,6 @@ public: */ ErrCode RemoveAllSlots() override; - /** - * @brief Creates multiple notification slot groups. - * @note The precautions for using this method are similar to those for - * AddNotificationSlotGroup(NotificationSlotGroup). - * - * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AddSlotGroups(std::vector> groups) override; - /** * @brief Queries a created notification slot. * @@ -141,23 +131,6 @@ public: */ ErrCode GetSlots(std::vector> &slots) override; - /** - * @brief Queries a created notification slot group. - * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotGroup(const std::string &groupId, sptr &group) override; - - /** - * @brief Obtains a list of created notification slot groups. - * - * @param groups Indicates a list of created notification slot groups. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotGroups(std::vector> &groups) override; - /** * @brief Obtains the number of slot. * @@ -167,15 +140,6 @@ public: */ ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; - /** - * @brief Deletes multiple notification slot groups. - * - * @param groupIds Indicates the IDs of the notification slot groups, which is created by - * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveSlotGroups(const std::vector &groupIds) override; - /** * @brief Obtains active notifications of the current application in the system. * @@ -361,16 +325,6 @@ public: ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; - /** - * @brief Update slotgroup according to bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param groups Indicates the notification slots to be updated. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode UpdateSlotGroups(const sptr &bundleOption, - const std::vector> &groups) override; - /** * @brief Allow notifications to be sent based on the deviceId. * diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index 2d857d6f1a6318c18dde26fef8b280e2d071f0b9..ed28f92c225dff3867c730578e6bc8902baa4d42 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.h @@ -128,16 +128,6 @@ public: */ virtual ErrCode RemoveAllSlots() override; - /** - * @brief Creates multiple notification slot groups. - * @note The precautions for using this method are similar to those for - * AddNotificationSlotGroup(NotificationSlotGroup). - * - * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddSlotGroups(std::vector> groups) override; - /** * @brief Queries a created notification slot. * @@ -157,23 +147,6 @@ public: */ virtual ErrCode GetSlots(std::vector> &slots) override; - /** - * @brief Queries a created notification slot group. - * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotGroup(const std::string &groupId, sptr &group) override; - - /** - * @brief Obtains a list of created notification slot groups. - * - * @param groups Indicates a list of created notification slot groups. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotGroups(std::vector> &groups) override; - /** * @brief Obtains the number of slot. * @@ -183,15 +156,6 @@ public: */ virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; - /** - * @brief Deletes multiple notification slot groups. - * - * @param groupIds Indicates the IDs of the notification slot groups, which is created by - * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveSlotGroups(const std::vector &groupIds) override; - /** * @brief Obtains active notifications of the current application in the system. * @@ -377,16 +341,6 @@ public: virtual ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; - /** - * @brief Update slotgroup according to bundle. - * @param bundleOption Bundle as a condition. - * @param groups Groups that needs to be updated. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode UpdateSlotGroups(const sptr &bundleOption, - const std::vector> &groups) override; - /** * @brief Allow notifications to be sent based on the deviceId. * @@ -759,13 +713,9 @@ private: ErrCode HandleAddSlots(MessageParcel &data, MessageParcel &reply); ErrCode HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply); ErrCode HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply); - ErrCode HandleAddSlotGroups(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetSlots(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetSlotByType(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotGroup(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotGroups(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveSlotGroups(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply); @@ -786,7 +736,6 @@ private: ErrCode HandleDeleteAll(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply); ErrCode HandleUpdateSlots(MessageParcel &data, MessageParcel &reply); - ErrCode HandleUpdateSlotGroups(MessageParcel &data, MessageParcel &reply); ErrCode HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply); ErrCode HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply); ErrCode HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply); diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index 05bf40439a3cd8cee4a2b6b21b002ef723506790..cba7025602a2da7a68f8279d3f8d254ef13c2bb6 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -91,56 +91,6 @@ public: */ ErrCode GetNotificationSlots(std::vector> &slots); - /** - * @brief Creates a notification slot group to which a NotificationSlot object can be bound by - * calling NotificationSlot::SetSlotGroup(string). - * @note A NotificationSlotGroup instance cannot be used directly after being initialized. - * Instead, you have to call this method to create a notification slot group so that you can bind - * NotificationSlot objects to it. - * - * @param slotGroup Indicates the notification slot group to be created, which is set by NotificationSlotGroup. - * This parameter must be specified. the notification slot to be created, which is set by - * NotificationSlot. - * @return Returns add notification slot group result. - */ - ErrCode AddNotificationSlotGroup(const NotificationSlotGroup &slotGroup); - - /** - * @brief Creates multiple notification slot groups. - * @note The precautions for using this method are similar to those for - * AddNotificationSlotGroup(NotificationSlotGroup). - * - * @param slotGroups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. - * @return Returns add notification slot groups result. - */ - ErrCode AddNotificationSlotGroups(const std::vector &slotGroups); - - /** - * @brief Deletes a created notification slot group based on the slot group ID. - * - * @param slotGroupId Indicates the ID of the notification slot group, which is created by - * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. - * @return Returns remove notification slot group result. - */ - ErrCode RemoveNotificationSlotGroup(const std::string &slotGroupId); - - /** - * @brief Queries a created notification slot group. - * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. - * @return Returns get notification slot group result. - */ - ErrCode GetNotificationSlotGroup(const std::string &groupId, sptr &group); - - /** - * @brief Obtains a list of created notification slot groups. - * - * @param groups Indicates a list of created notification slot groups. - * @return Returns get notification slot groups result. - */ - ErrCode GetNotificationSlotGroups(std::vector> &groups); - /** * @brief Obtains number of slot. * @@ -494,16 +444,6 @@ public: ErrCode UpdateNotificationSlots( const NotificationBundleOption &bundleOption, const std::vector> &slots); - /** - * @brief Updates all notification slot groups for the specified bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param groups Indicates a list of new notification slot groups. - * @return Returns update notification slot groups for bundle result. - */ - ErrCode UpdateNotificationSlotGroups( - const NotificationBundleOption &bundleOption, const std::vector> &groups); - /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to * call this method. diff --git a/frameworks/core/src/ans_manager_proxy.cpp b/frameworks/core/src/ans_manager_proxy.cpp index fb5851ff8211599b1a4b1df6d4230d11d1d6e8a7..a5e654c05bb2e59e41e20af4864819ec167613dc 100644 --- a/frameworks/core/src/ans_manager_proxy.cpp +++ b/frameworks/core/src/ans_manager_proxy.cpp @@ -332,46 +332,6 @@ ErrCode AnsManagerProxy::RemoveAllSlots() return result; } -ErrCode AnsManagerProxy::AddSlotGroups(std::vector> groups) -{ - if (groups.empty()) { - ANS_LOGE("[AddSlotGroups] fail: groups is empty."); - return ERR_ANS_INVALID_PARAM; - } - - size_t groupsSize = groups.size(); - if (groupsSize > MAX_SLOT_GROUP_NUM) { - ANS_LOGE("[AddSlotGroups] fail: groupsSize over max size."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[AddSlotGroups] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!WriteParcelableVector(groups, data)) { - ANS_LOGE("[AddSlotGroups] fail: write groups failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(ADD_SLOT_GROUPS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[AddSlotGroups] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[AddSlotGroups] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - ErrCode AnsManagerProxy::GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) { MessageParcel data; @@ -433,72 +393,6 @@ ErrCode AnsManagerProxy::GetSlots(std::vector> &slots) return result; } -ErrCode AnsManagerProxy::GetSlotGroup(const std::string &groupId, sptr &group) -{ - if (groupId.empty()) { - ANS_LOGE("[GetSlotGroup] fail: groupId is null."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotGroup] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(groupId)) { - ANS_LOGE("[GetSlotGroup] fail:: write groupId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(GET_SLOT_GROUP, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSlotGroup] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetSlotGroup] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - group = reply.ReadParcelable(); - if (group == nullptr) { - ANS_LOGE("[GetSlotGroup] fail: read group failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlotGroups(std::vector> &groups) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotGroups] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(GET_SLOT_GROUPS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSlotGroups] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(groups, reply, result)) { - ANS_LOGE("[GetSlotGroups] fail: read groups failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - ErrCode AnsManagerProxy::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) { if (bundleOption == nullptr) { @@ -538,40 +432,6 @@ ErrCode AnsManagerProxy::GetSlotNumAsBundle(const sptr return result; } -ErrCode AnsManagerProxy::RemoveSlotGroups(const std::vector &groupIds) -{ - if (groupIds.empty()) { - ANS_LOGE("[RemoveSlotGroups] fail: groupIds is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RemoveSlotGroups] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStringVector(groupIds)) { - ANS_LOGE("[RemoveSlotGroups] fail:: write groupIds failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(REMOVE_SLOT_GROUPS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveSlotGroups] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RemoveSlotGroups] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - ErrCode AnsManagerProxy::GetActiveNotifications(std::vector> ¬ifications) { MessageParcel data; @@ -1233,57 +1093,6 @@ ErrCode AnsManagerProxy::UpdateSlots( return result; } -ErrCode AnsManagerProxy::UpdateSlotGroups( - const sptr &bundleOption, const std::vector> &groups) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[UpdateSlotGroups] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - if (groups.empty()) { - ANS_LOGE("[UpdateSlotGroups] fail: groups is empty."); - return ERR_ANS_INVALID_PARAM; - } - - size_t groupSize = groups.size(); - if (groupSize > MAX_SLOT_GROUP_NUM) { - ANS_LOGE("[UpdateSlotGroups] fail: groupSize over max size."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[UpdateSlotGroups] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[UpdateSlotGroups] fail:: write bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!WriteParcelableVector(groups, data)) { - ANS_LOGE("[UpdateSlotGroups] fail: write groups failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(UPDATE_SLOT_GROUPS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[UpdateSlotGroups] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[UpdateSlotGroups] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - ErrCode AnsManagerProxy::RequestEnableNotification(const std::string &deviceId) { MessageParcel data; diff --git a/frameworks/core/src/ans_manager_stub.cpp b/frameworks/core/src/ans_manager_stub.cpp index e72fdafc9683ee010bf7cd445499933d152b6d32..4305dd3ac1cb55a267b57e47a4b13fae19313a2b 100644 --- a/frameworks/core/src/ans_manager_stub.cpp +++ b/frameworks/core/src/ans_manager_stub.cpp @@ -55,27 +55,15 @@ const std::map> groups; - if (!ReadParcelableVector(groups, data)) { - ANS_LOGE("[HandleAddSlotGroups] fail: read slotsSize failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = AddSlotGroups(groups); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleAddSlotGroups] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - ErrCode AnsManagerStub::HandleGetSlots(MessageParcel &data, MessageParcel &reply) { std::vector> slots; @@ -505,40 +474,6 @@ ErrCode AnsManagerStub::HandleGetSlotByType(MessageParcel &data, MessageParcel & return ERR_OK; } -ErrCode AnsManagerStub::HandleGetSlotGroup(MessageParcel &data, MessageParcel &reply) -{ - std::string groupId; - if (!data.ReadString(groupId)) { - ANS_LOGE("[HandleGetSlotGroup] fail: read groupId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr group; - ErrCode result = GetSlotGroup(groupId, group); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetSlotGroup] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteParcelable(group)) { - ANS_LOGE("[HandleGetSlotGroup] fail: write group failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlotGroups(MessageParcel &data, MessageParcel &reply) -{ - std::vector> groups; - ErrCode result = GetSlotGroups(groups); - if (!WriteParcelableVector(groups, reply, result)) { - ANS_LOGE("[HandleGetSlotGroups] fail: write groups failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply) { sptr bundleOption = data.ReadStrongParcelable(); @@ -561,22 +496,6 @@ ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessagePar return ERR_OK; } -ErrCode AnsManagerStub::HandleRemoveSlotGroups(MessageParcel &data, MessageParcel &reply) -{ - std::vector groupIds; - if (!data.ReadStringVector(&groupIds)) { - ANS_LOGE("[HandleRemoveSlotGroups] fail: read groupIds failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RemoveSlotGroups(groupIds); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveSlotGroups] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - ErrCode AnsManagerStub::HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply) { std::vector> notifications; @@ -1003,28 +922,6 @@ ErrCode AnsManagerStub::HandleUpdateSlots(MessageParcel &data, MessageParcel &re return ERR_OK; } -ErrCode AnsManagerStub::HandleUpdateSlotGroups(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleUpdateSlotGroups] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::vector> groups; - if (!ReadParcelableVector(groups, data)) { - ANS_LOGE("[HandleUpdateSlotGroups] fail: read groups failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = UpdateSlotGroups(bundleOption, groups); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleUpdateSlotGroups] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - ErrCode AnsManagerStub::HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply) { std::string deviceId; @@ -1922,12 +1819,6 @@ ErrCode AnsManagerStub::RemoveAllSlots() return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::AddSlotGroups(std::vector> groups) -{ - ANS_LOGE("AnsManagerStub::AddSlotGroups called!"); - return ERR_INVALID_OPERATION; -} - ErrCode AnsManagerStub::GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) { ANS_LOGE("AnsManagerStub::GetSlotByType called!"); @@ -1940,30 +1831,12 @@ ErrCode AnsManagerStub::GetSlots(std::vector> &slots) return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::GetSlotGroup(const std::string &groupId, sptr &group) -{ - ANS_LOGE("AnsManagerStub::GetSlotGroup called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotGroups(std::vector> &groups) -{ - ANS_LOGE("AnsManagerStub::GetSlotGroups called!"); - return ERR_INVALID_OPERATION; -} - ErrCode AnsManagerStub::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) { ANS_LOGE("AnsManagerStub::GetSlotNumAsBundle called!"); return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::RemoveSlotGroups(const std::vector &groupIds) -{ - ANS_LOGE("AnsManagerStub::RemoveSlotGroups called!"); - return ERR_INVALID_OPERATION; -} - ErrCode AnsManagerStub::GetActiveNotifications(std::vector> ¬ifications) { ANS_LOGE("AnsManagerStub::GetActiveNotifications called!"); @@ -2089,13 +1962,6 @@ ErrCode AnsManagerStub::UpdateSlots( return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::UpdateSlotGroups( - const sptr &bundleOption, const std::vector> &groups) -{ - ANS_LOGE("AnsManagerStub::UpdateSlotGroups called!"); - return ERR_INVALID_OPERATION; -} - ErrCode AnsManagerStub::RequestEnableNotification(const std::string &deviceId) { ANS_LOGE("AnsManagerStub::RequestEnableNotification called!"); diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index a88d5b6e6369c0c4a04d14a9d630d35bf0d15c4f..2a9fd677d66c117af2120ec722729e44ceee1be2 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -103,62 +103,6 @@ ErrCode AnsNotification::GetNotificationSlots(std::vector return ansManagerProxy_->GetSlots(slots); } -ErrCode AnsNotification::AddNotificationSlotGroup(const NotificationSlotGroup &slotGroup) -{ - std::vector slotGroups; - slotGroups.emplace_back(slotGroup); - return AddNotificationSlotGroups(slotGroups); -} - -ErrCode AnsNotification::AddNotificationSlotGroups(const std::vector &slotGroups) -{ - if (!GetAnsManagerProxy()) { - ANS_LOGE("GetAnsManagerProxy fail."); - return ERR_ANS_SERVICE_NOT_CONNECTED; - } - - std::vector> slotGroupsSptr; - for (auto it = slotGroups.begin(); it != slotGroups.end(); ++it) { - sptr slotGroup = new (std::nothrow) NotificationSlotGroup(*it); - if (slotGroup == nullptr) { - ANS_LOGE("Failed to add notification slot groups with NotificationSlotGroup nullptr"); - return ERR_ANS_NO_MEMORY; - } - slotGroupsSptr.emplace_back(slotGroup); - } - - return ansManagerProxy_->AddSlotGroups(slotGroupsSptr); -} - -ErrCode AnsNotification::RemoveNotificationSlotGroup(const std::string &slotGroupId) -{ - if (!GetAnsManagerProxy()) { - ANS_LOGE("GetAnsManagerProxy fail."); - return ERR_ANS_SERVICE_NOT_CONNECTED; - } - std::vector slotGroupIds; - slotGroupIds.emplace_back(slotGroupId); - return ansManagerProxy_->RemoveSlotGroups(slotGroupIds); -} - -ErrCode AnsNotification::GetNotificationSlotGroup(const std::string &groupId, sptr &group) -{ - if (!GetAnsManagerProxy()) { - ANS_LOGE("GetAnsManagerProxy fail."); - return ERR_ANS_SERVICE_NOT_CONNECTED; - } - return ansManagerProxy_->GetSlotGroup(groupId, group); -} - -ErrCode AnsNotification::GetNotificationSlotGroups(std::vector> &groups) -{ - if (!GetAnsManagerProxy()) { - ANS_LOGE("GetAnsManagerProxy fail."); - return ERR_ANS_SERVICE_NOT_CONNECTED; - } - return ansManagerProxy_->GetSlotGroups(groups); -} - ErrCode AnsNotification::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num) { if (bundleOption.GetBundleName().empty()) { @@ -659,23 +603,6 @@ ErrCode AnsNotification::UpdateNotificationSlots( return ansManagerProxy_->UpdateSlots(bo, slots); } -ErrCode AnsNotification::UpdateNotificationSlotGroups( - const NotificationBundleOption &bundleOption, const std::vector> &groups) -{ - if (bundleOption.GetBundleName().empty()) { - ANS_LOGE("Invalid bundle name."); - return ERR_ANS_INVALID_PARAM; - } - - if (!GetAnsManagerProxy()) { - ANS_LOGE("GetAnsManagerProxy fail."); - return ERR_ANS_SERVICE_NOT_CONNECTED; - } - - sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); - return ansManagerProxy_->UpdateSlotGroups(bo, groups); -} - ErrCode AnsNotification::GetAllActiveNotifications(std::vector> ¬ification) { if (!GetAnsManagerProxy()) { diff --git a/frameworks/test/moduletest/ans_fw_module_test.cpp b/frameworks/test/moduletest/ans_fw_module_test.cpp index d108d7d6d3b05f908f2ef594096af30b76d7aea4..7ecf1d6c20ad4cc41875c19fbef7882f8283b2cf 100644 --- a/frameworks/test/moduletest/ans_fw_module_test.cpp +++ b/frameworks/test/moduletest/ans_fw_module_test.cpp @@ -628,11 +628,6 @@ void AnsFWModuleTest::TearDown() NotificationHelper::CancelAllNotifications(); NotificationHelper::RemoveAllSlots(); NotificationHelper::RemoveNotifications(); - std::vector> groups; - NotificationHelper::GetNotificationSlotGroups(groups); - for (auto group : groups) { - NotificationHelper::RemoveNotificationSlotGroup(group->GetId().c_str()); - } SleepForFC(); } diff --git a/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp b/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp index 41d4d23677a1d909e4e3158f6f485659b3e0f3d0..82e87976d451658cac104ff31f999ecacacfb5f0 100644 --- a/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp +++ b/frameworks/test/moduletest/ans_innerkits_module_slot_test.cpp @@ -69,7 +69,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00100, Fu slot.SetDescription("description"); slot.SetLedLightColor(0); slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW); - slot.SetSlotGroup("group"); slot.SetSound(Uri(".")); std::vector style; style.push_back(0); @@ -93,7 +92,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00100, Fu EXPECT_EQ(NotificationConstant::SOCIAL_COMMUNICATION, spSlot->GetType()); EXPECT_EQ(NotificationConstant::VisiblenessType::PUBLIC, spSlot->GetLockScreenVisibleness()); EXPECT_EQ("SOCIAL_COMMUNICATION", spSlot->GetName()); - EXPECT_EQ("group", spSlot->GetSlotGroup()); EXPECT_EQ(Uri("."), spSlot->GetSound()); for (auto it : spSlot->GetVibrationStyle()) { EXPECT_EQ(0, it); @@ -120,7 +118,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00200, Fu slot.SetDescription("description"); slot.SetLedLightColor(0); slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW); - slot.SetSlotGroup("group"); slot.SetSound(Uri(".")); std::vector style; style.push_back(0); @@ -143,7 +140,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00200, Fu EXPECT_EQ(NotificationConstant::SERVICE_REMINDER, spSlot->GetType()); EXPECT_EQ(NotificationConstant::VisiblenessType::PUBLIC, spSlot->GetLockScreenVisibleness()); EXPECT_EQ("SERVICE_REMINDER", spSlot->GetName()); - EXPECT_EQ("group", spSlot->GetSlotGroup()); EXPECT_EQ(Uri("."), spSlot->GetSound()); for (auto it : spSlot->GetVibrationStyle()) { EXPECT_EQ(0, it); @@ -171,7 +167,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00300, Fu slot.SetDescription("description"); slot.SetLedLightColor(0); slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW); - slot.SetSlotGroup("group"); slot.SetSound(Uri(".")); std::vector style; style.push_back(0); @@ -194,7 +189,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00300, Fu EXPECT_EQ(NotificationConstant::CONTENT_INFORMATION, spSlot->GetType()); EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, spSlot->GetLockScreenVisibleness()); EXPECT_EQ("CONTENT_INFORMATION", spSlot->GetName()); - EXPECT_EQ("group", spSlot->GetSlotGroup()); EXPECT_EQ(Uri("."), spSlot->GetSound()); for (auto it : spSlot->GetVibrationStyle()) { EXPECT_EQ(0, it); @@ -221,7 +215,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00400, Fu slot.SetDescription("description"); slot.SetLedLightColor(0); slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW); - slot.SetSlotGroup("group"); slot.SetSound(Uri(".")); std::vector style; style.push_back(0); @@ -244,7 +237,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00400, Fu EXPECT_EQ(NotificationConstant::OTHER, spSlot->GetType()); EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, spSlot->GetLockScreenVisibleness()); EXPECT_EQ("OTHER", spSlot->GetName()); - EXPECT_EQ("group", spSlot->GetSlotGroup()); EXPECT_EQ(Uri("."), spSlot->GetSound()); for (auto it : spSlot->GetVibrationStyle()) { EXPECT_EQ(0, it); @@ -273,7 +265,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00500, Fu slot.SetDescription(description); slot.SetLedLightColor(0); slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW); - slot.SetSlotGroup("group"); slot.SetSound(Uri(".")); std::vector style; style.push_back(0); @@ -298,7 +289,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00500, Fu EXPECT_EQ(NotificationConstant::OTHER, spSlot->GetType()); EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, spSlot->GetLockScreenVisibleness()); EXPECT_EQ("OTHER", spSlot->GetName()); - EXPECT_EQ("group", spSlot->GetSlotGroup()); EXPECT_EQ(Uri("."), spSlot->GetSound()); for (auto it : spSlot->GetVibrationStyle()) { EXPECT_EQ(0, it); @@ -380,107 +370,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00900, Fu EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_MIN, slot.GetLevel()); } -/** - * @tc.number : ANS_Interface_MT_NotificationSlotGroup_00100 - * @tc.name : NotificationSlotGroup_00100 - * @tc.desc : Add notification slot group, get notification slot group and remove notification slot group. - * @tc.expected : Add notification slot group success, get notification slot group correctly and remove notification - * slot group success. - */ -HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlotGroup_00100, Function | MediumTest | Level1) -{ - NotificationSlotGroup slotGroup("id", "name"); - slotGroup.SetDescription("description"); - EXPECT_EQ(0, NotificationHelper::AddNotificationSlotGroup(slotGroup)); - sptr spSlotGroup; - EXPECT_EQ(0, NotificationHelper::GetNotificationSlotGroup("id", spSlotGroup)); - - if (spSlotGroup == nullptr) { - GTEST_LOG_(INFO) << "get slot group is empty"; - } else { - GTEST_LOG_(INFO) << "get slot group is:" << spSlotGroup->Dump(); - EXPECT_EQ("description", spSlotGroup->GetDescription()); - EXPECT_EQ("id", spSlotGroup->GetId()); - EXPECT_EQ("name", spSlotGroup->GetName()); - EXPECT_EQ(false, spSlotGroup->IsDisabled()); - } - EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlotGroup("id")); - EXPECT_EQ((int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST, - NotificationHelper::GetNotificationSlotGroup("id", spSlotGroup)); -} - -/** - * @tc.number : ANS_Interface_MT_NotificationSlotGroup_00200 - * @tc.name : NotificationSlotGroup_00200 - * @tc.desc : Add notification slot group, slot group set description character length exceed 1000 - * characters, get notification slot group and remove notification slot group. - * @tc.expected : Add notification slot group success, get notification slot group correctly and remove notification - * slot group success. - */ -HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlotGroup_00200, Function | MediumTest | Level1) -{ - NotificationSlotGroup slotGroup("id", "name"); - std::string description(2000, 'c'); - slotGroup.SetDescription(description); - EXPECT_EQ(0, NotificationHelper::AddNotificationSlotGroup(slotGroup)); - GTEST_LOG_(INFO) << "after add group is:" << slotGroup.Dump(); - sptr spSlotGroup; - EXPECT_EQ(0, NotificationHelper::GetNotificationSlotGroup("id", spSlotGroup)); - - if (spSlotGroup == nullptr) { - GTEST_LOG_(INFO) << "get slot group is empty"; - } else { - GTEST_LOG_(INFO) << "get slot group is:" << spSlotGroup->Dump(); - std::string expectDescription(1000, 'c'); - EXPECT_EQ(expectDescription, spSlotGroup->GetDescription()); - EXPECT_EQ("id", spSlotGroup->GetId()); - EXPECT_EQ("name", spSlotGroup->GetName()); - EXPECT_EQ(false, spSlotGroup->IsDisabled()); - } - EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlotGroup("id")); - EXPECT_EQ((int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST, - NotificationHelper::GetNotificationSlotGroup("id", spSlotGroup)); -} - -/** - * @tc.number : ANS_Interface_MT_NotificationSlotGroup_00300 - * @tc.name : NotificationSlotGroup_00300 - * @tc.desc : Two different slots added to the same slot group. - * @tc.expected : Add success. - */ -HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlotGroup_00300, Function | MediumTest | Level1) -{ - NotificationSlot slotA(NotificationConstant::OTHER); - slotA.SetSlotGroup("id"); - - NotificationSlot slotB(NotificationConstant::CUSTOM); - slotA.SetSlotGroup("id"); - - NotificationSlotGroup slotGroup("id", "name"); - EXPECT_EQ(0, NotificationHelper::AddNotificationSlotGroup(slotGroup)); - - sptr spSlotGroup; - EXPECT_EQ(0, NotificationHelper::GetNotificationSlotGroup("id", spSlotGroup)); - - if (spSlotGroup == nullptr) { - GTEST_LOG_(INFO) << "get slot group is empty"; - } else { - std::vector slots = spSlotGroup->GetSlots(); - for (auto it : slots) { - if (NotificationConstant::OTHER == it.GetType()) { - EXPECT_EQ("OTHER", it.GetId()); - } else if (NotificationConstant::CUSTOM == it.GetType()) { - EXPECT_EQ("CUSTOM", it.GetId()); - } else { - GTEST_LOG_(INFO) << "slot group has wrong slot"; - } - } - } - EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlotGroup("id")); - EXPECT_EQ((int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST, - NotificationHelper::GetNotificationSlotGroup("id", spSlotGroup)); -} - /** * @tc.number : ANS_Interface_MT_SetEnabledForBundleSlot_00100 * @tc.name : SetEnabledForBundleSlot_00100 @@ -495,7 +384,6 @@ HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00 slot.SetDescription("description"); slot.SetLedLightColor(0); slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW); - slot.SetSlotGroup("group"); slot.SetSound(Uri(".")); std::vector style; style.push_back(0); diff --git a/interfaces/inner_api/notification_helper.h b/interfaces/inner_api/notification_helper.h index 9cf917e7bcd47dc555ece7877b4055c0a6ff1141..13e85e02dec8beb818393c5047bc330f4a62cc59 100644 --- a/interfaces/inner_api/notification_helper.h +++ b/interfaces/inner_api/notification_helper.h @@ -21,7 +21,6 @@ #include "enabled_notification_callback_data.h" #include "notification_request.h" #include "notification_slot.h" -#include "notification_slot_group.h" #include "notification_sorting_map.h" #include "notification_subscriber.h" @@ -93,56 +92,6 @@ public: */ static ErrCode GetNotificationSlots(std::vector> &slots); - /** - * @brief Creates a notification slot group to which a NotificationSlot object can be bound by - * calling NotificationSlot::SetSlotGroup(string). - * @note A NotificationSlotGroup instance cannot be used directly after being initialized. - * Instead, you have to call this method to create a notification slot group so that you can bind - * NotificationSlot objects to it. - * - * @param slotGroup Indicates the notification slot group to be created, which is set by NotificationSlotGroup. - * This parameter must be specified. the notification slot to be created, which is set by - * NotificationSlot. - * @return Returns add notification slot group result. - */ - static ErrCode AddNotificationSlotGroup(const NotificationSlotGroup &slotGroup); - - /** - * @brief Creates multiple notification slot groups. - * @note The precautions for using this method are similar to those for - * AddNotificationSlotGroup(NotificationSlotGroup). - * - * @param slotGroups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. - * @return Returns add notification slot groups result. - */ - static ErrCode AddNotificationSlotGroups(const std::vector &slotGroups); - - /** - * @brief Deletes a created notification slot group based on the slot group ID. - * - * @param slotGroupId Indicates the ID of the notification slot group, which is created by - * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. - * @return Returns remove notification slot group result. - */ - static ErrCode RemoveNotificationSlotGroup(const std::string &slotGroupId); - - /** - * @brief Queries a created notification slot group. - * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. - * @return Returns get notification slot group result. - */ - static ErrCode GetNotificationSlotGroup(const std::string &groupId, sptr &group); - - /** - * @brief Obtains a list of created notification slot groups. - * - * @param groups Indicates a list of created notification slot groups. - * @return Returns get notification slot groups result. - */ - static ErrCode GetNotificationSlotGroups(std::vector> &groups); - /** * @brief Obtains number of slot. * @@ -496,16 +445,6 @@ public: static ErrCode UpdateNotificationSlots( const NotificationBundleOption &bundleOption, const std::vector> &slots); - /** - * @brief Update all notification slot groups for the specified bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param groups Indicates a list of new notification slot groups. - * @return Returns update notification slot groups for bundle result. - */ - static ErrCode UpdateNotificationSlotGroups( - const NotificationBundleOption &bundleOption, const std::vector> &groups); - /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to * call this method. diff --git a/interfaces/inner_api/notification_slot.h b/interfaces/inner_api/notification_slot.h index 903e877b0c1a9927c7bb77f37272bf024f61ba4d..354938d857cdbf762fda984813b256a04a0a9409 100644 --- a/interfaces/inner_api/notification_slot.h +++ b/interfaces/inner_api/notification_slot.h @@ -189,25 +189,6 @@ public: */ std::string GetName() const; - /** - * @brief Obtains the ID of the NotificationSlotGroup object to which this NotificationSlot object belongs, - * which is set by SetSlotGroup(string). - * - * @return Returns the ID of the NotificationSlotGroup to which this NotificationSlot object belongs. - */ - std::string GetSlotGroup() const; - - /** - * @brief Binds a NotificationSlot object to a specified NotificationSlotGroup. - * @note SetSlotGroup must be called before the NotificationHelper::AddNotificationSlot(NotificationSlot) method is - * called. Otherwise, this method will not take effect. - * - * @param groupId Indicates the ID of the NotificationSlotGroup object to bind, - * which must have been created by calling - * NotificationHelper::AddNotificationSlotGroup(NotificationSlotGroup). - */ - void SetSlotGroup(const std::string &groupId); - /** * @brief Obtains the prompt tone of a NotificationSlot object, which is set by SetSound(Uri). * @@ -368,7 +349,6 @@ private: NotificationLevel level_ {LEVEL_DEFAULT}; NotificationConstant::SlotType type_ {}; NotificationConstant::VisiblenessType lockScreenVisibleness_ {NotificationConstant::VisiblenessType::NO_OVERRIDE}; - std::string groupId_ {}; Uri sound_; std::vector vibrationValues_ {}; bool enabled_ {true}; diff --git a/interfaces/inner_api/notification_slot_group.h b/interfaces/inner_api/notification_slot_group.h deleted file mode 100644 index 09c3413348fc559ec6abea244893859dddc13dfc..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/notification_slot_group.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SLOT_GROUP_H -#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SLOT_GROUP_H - -#include "notification_slot.h" - -namespace OHOS { -namespace Notification { -class NotificationSlotGroup : public Parcelable { -public: - - /** - * @brief A constructor used to create a NotificationSlotGroup instance with the group ID and name initialized. - * - * @param id Indicates the ID of the NotificationSlotGroup. - * The ID must be unique and its length must not exceed 1000 characters (the excess part is automatically - * truncated). - * @param name Indicates the name of the NotificationSlotGroup. - * Its length must not exceed 1000 characters (the excess part is automatically truncated). - */ - NotificationSlotGroup(const std::string &id, const std::string &name); - - ~NotificationSlotGroup(); - - /** - * @brief Obtains the description of this NotificationSlotGroup object, which is set by SetDescription(string). - * - * @return Returns the description of this NotificationSlotGroup. - */ - std::string GetDescription() const; - - /** - * @brief Obtains the ID of this NotificationSlotGroup object, which is set by - * NotificationSlotGroup(string, string). - * - * @return Returns the ID of this NotificationSlotGroup. - */ - std::string GetId() const; - - /** - * @brief Obtains the name of this NotificationSlotGroup object, which is set by - * NotificationSlotGroup(string, string). - * - * @return Returns the name of this NotificationSlotGroup. - */ - std::string GetName() const; - - /** - * @brief Obtains a list of notification slots bound to this NotificationSlotGroup object. - * @note NotificationSlot::SetSlotGroup(string) is used to bind a notification slot to a notification slot group. - * - * @param slots Indicates the slots which to set to the slotgroup. - */ - void SetSlots(const std::vector &slots); - - /** - * @brief Sets a list of notification slots bound to this NotificationSlotGroup object. - * @note NotificationSlot::SetSlotGroup(string) is used to bind a notification slot to a notification slot group. - * - * @return Returns the list of notification slots bound to this NotificationSlotGroup. - */ - std::vector GetSlots() const; - - /** - * @brief Checks whether this NotificationSlotGroup is disabled. - * - * @return Returns true if this NotificationSlotGroup is disabled; returns false otherwise. - */ - bool IsDisabled() const; - - /** - * @brief Sets the description for this NotificationSlotGroup object. - * - * @param description describes this NotificationSlotGroup object. - * Its length must not exceed 1000 characters (the excess part is automatically truncated). - */ - void SetDescription(const std::string &description); - - /** - * @brief Dumps a string representation of the object. - * - * @return Returns a string representation of the object. - */ - std::string Dump() const; - - /** - * @brief Marshals NotificationSlotGroup objects and writes them into Parcel. - * - * @param parcel Indicates the Parcel object for marshalling. - * @return Returns true if the marshalling is successful; returns false otherwise. - */ - virtual bool Marshalling(Parcel &parcel) const override; - - /** - * @brief Unmarshals a NotificationSlotGroup object from a Parcel. - * - * @param parcel Indicates the Parcel object for unmarshalling. - * @return Returns the NotificationSlotGroup object. - */ - static NotificationSlotGroup *Unmarshalling(Parcel &parcel); - - /** - * @brief If string length exceed 1000 characters, the excessive part is automatically truncated. - * - * @param truncatedString Indicates the sting which will be truncated - * @return Returns the string that has been truncated. - */ - std::string TruncateString(const std::string &inPutString); - -private: - NotificationSlotGroup(); - - /** - * @brief Read NotificationSlotGroup object from a Parcel. - * - * @param parcel Indicates the parcel object. - * @return Returns true if succeed; returns false otherwise. - */ - bool ReadFromParcel(Parcel &parcel); - -private: - std::string id_ {}; - std::string name_ {}; - std::string description_ {}; - std::vector slots_ {}; - bool isDisabled_ {false}; -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SLOT_GROUP_H \ No newline at end of file diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 8b349142d4ca155a227bc5a564b5832b245c1848..7281f3a1a9d0d68214f2324b8d813e9b83895094 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -125,16 +125,6 @@ public: */ ErrCode RemoveAllSlots() override; - /** - * @brief Creates multiple notification slot groups. - * @note The precautions for using this method are similar to those for - * AddNotificationSlotGroup(NotificationSlotGroup). - * - * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AddSlotGroups(std::vector> groups) override; - /** * @brief Queries a created notification slot. * @@ -153,23 +143,6 @@ public: */ ErrCode GetSlots(std::vector> &slots) override; - /** - * @brief Queries a created notification slot group. - * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotGroup(const std::string &groupId, sptr &group) override; - - /** - * @brief Obtains a list of created notification slot groups. - * - * @param groups Indicates a list of created notification slot groups. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotGroups(std::vector> &groups) override; - /** * @brief Obtains the number of slot. * @@ -179,15 +152,6 @@ public: */ ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; - /** - * @brief Deletes multiple notification slot groups. - * - * @param groupIds Indicates the IDs of the notification slot groups, which is created by - * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveSlotGroups(const std::vector &groupIds) override; - /** * @brief Obtains active notifications of the current application in the system. * @@ -373,16 +337,6 @@ public: ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; - /** - * @brief Update slotgroup according to bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param groups Indicates the notification slots to be updated. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode UpdateSlotGroups(const sptr &bundleOption, - const std::vector> &groups) override; - /** * @brief Allow notifications to be sent based on the deviceId. * diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index 2c55af91468c819193882476fc59bc52f1fce75e..7548eb5f797d1ecb61d6e3ffbdb4b994647151f2 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -43,16 +43,6 @@ public: ErrCode AddNotificationSlots( const sptr &bundleOption, const std::vector> &slots); - /** - * @brief Add notification slot groups into DB. - * - * @param bundleOption Indicates bunlde info label. - * @param groups Indicates add notification slot groups. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode AddNotificationSlotGroups( - const sptr &bundleOption, const std::vector> &groups); - /** * @brief Add notification bunle info into DB. * @@ -79,15 +69,6 @@ public: */ ErrCode RemoveNotificationAllSlots(const sptr &bundleOption); - /** - * @brief Remove notification all slot in the of bundle from DB. - * - * @param bundleOption Indicates bunlde info label. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode RemoveNotificationSlotGroups( - const sptr &bundleOption, const std::vector &groupIds); - /** * @brief Remove notification bundle from DB. * @@ -106,16 +87,6 @@ public: ErrCode UpdateNotificationSlots( const sptr &bundleOption, const std::vector> &slot); - /** - * @brief Update notification slot group into DB. - * - * @param bundleOption Indicates bunlde info label. - * @param slot Indicates need to upadte slot group. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode UpdateNotificationSlotGroups( - const sptr &bundleOption, const std::vector> &groups); - /** * @brief Get notification slot from DB. * @@ -146,38 +117,6 @@ public: */ ErrCode GetNotificationSlotsNumForBundle(const sptr &bundleOption, uint64_t &num); - /** - * @brief Get notification group in a bundle from DB. - * - * @param bundleOption Indicates bunlde info label. - * @param groupId Indicates to get group id. - * @param group Indicates to get slot group. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode GetNotificationSlotGroup(const sptr &bundleOption, const std::string &groupId, - sptr &group); - - /** - * @brief Get notification all group in a bundle from DB. - * - * @param bundleOption Indicates bunlde info label. - * @param groups Indicates to get slot groups. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode GetNotificationAllSlotGroups( - const sptr &bundleOption, std::vector> &groups); - - /** - * @brief Get notification all slot in a group in the of bunlde from DB. - * - * @param bundleOption Indicates bunlde info label. - * @param groupId Indicates to get group id. - * @param slots Indicates to get slots. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode GetNotificationAllSlotInSlotGroup(const sptr &bundleOption, - const std::string &groupId, std::vector> &slots); - /** * @brief Get show badge in the of bunlde from DB. * @@ -326,16 +265,10 @@ public: private: ErrCode CheckSlotForCreateSlot(const sptr &bundleOption, const sptr &slot, NotificationPreferencesInfo &preferencesInfo) const; - ErrCode CheckGroupForCreateSlotGroup(const sptr &bundleOption, - const sptr &group, NotificationPreferencesInfo &preferencesInfo) const; ErrCode CheckSlotForRemoveSlot(const sptr &bundleOption, const NotificationConstant::SlotType &slotType, NotificationPreferencesInfo &preferencesInfo) const; - ErrCode CheckGroupForRemoveSlotGroup(const sptr &bundleOption, const std::string &groupId, - NotificationPreferencesInfo &preferencesInfo) const; ErrCode CheckSlotForUpdateSlot(const sptr &bundleOption, const sptr &slot, NotificationPreferencesInfo &preferencesInfo) const; - ErrCode CheckGroupForUpdateSlotGroup(const sptr &bundleOption, - const sptr &group, NotificationPreferencesInfo &preferencesInfo) const; template ErrCode SetBundleProperty(NotificationPreferencesInfo &preferencesInfo, const sptr &bundleOption, const BundleType &type, const T &value); diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index 4c3e3c7f1ced6c0a158e2d4d826f1a171f5f86b1..6aee6f7c3c95df3818b26b45ef5fa87c65e175e5 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -40,17 +40,6 @@ public: bool PutSlotsToDisturbeDB( const std::string &bundleName, const int32_t &bundleUid, const std::vector> &slots); - /** - * @brief Put notification slot groups into disturbe DB. - * - * @param bundleName Indicates bundle name. - * @param bundleUid Indicates bundle uid. - * @param groups Indicates notification groups. - * @return Return true on success, false on failure. - */ - bool PutGroupsToDisturbeDB(const std::string &bundleName, const int32_t &bundleUid, - const std::vector> &groups); - /** * @brief Put notification bundle into disturbe DB. * @@ -165,15 +154,6 @@ public: */ bool RemoveAllSlotsFromDisturbeDB(const std::string &bundleKey); - /** - * @brief Delete some groups in the of bundle from disturbe DB. - * - * @param bundleKey Indicates to which a bundle. - * @param groupId Indicates to group id in the of bundle. - * @return Return true on success, false on failure. - */ - bool RemoveGroupsFromDisturbeDB(const std::string &bundleKey, const std::vector &groupId); - /** * @brief Deal death recipient. * @@ -201,15 +181,9 @@ private: void GetValueFromDisturbeDB(const std::string &key, std::function function); void GetValueFromDisturbeDB(const std::string &key, std::function function); - bool GetRemoveGroupKeysFromDisturbeDB( - const std::string &bundleKey, const std::string &groupId, std::vector &keys); bool SlotToEntry(const std::string &bundleName, const int32_t &bundleUid, const sptr &slot, std::vector &entries); - bool GroupToEntry(const std::string &bundleName, const int32_t &bundleUid, const sptr &group, - std::vector &entries); - void GenerateGroupEntry(const std::string &bundleKey, const sptr &group, - std::vector &entries) const; void GenerateSlotEntry(const std::string &bundleKey, const sptr &slot, std::vector &entries) const; void GenerateEntry( @@ -222,26 +196,20 @@ private: int32_t StringToInt(const std::string &str) const; int64_t StringToInt64(const std::string &str) const; bool IsSlotKey(const std::string &bundleKey, const std::string &key) const; - bool IsGroupKey(const std::string &bundleKey, const std::string &key) const; std::string GenerateSlotKey( const std::string &bundleKey, const std::string &type = "", const std::string &subType = "") const; - std::string GenerateGroupKey(const std::string &bundleKey, const std::string &subType = "") const; std::string GenerateBundleKey(const std::string &bundleKey, const std::string &type = "") const; void ParseBundleFromDistureDB( NotificationPreferencesInfo &info, const std::vector &entries); void ParseSlotFromDisturbeDB(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &bundleKey, const DistributedKv::Entry &entry); - void ParseGroupFromDisturbeDB(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &bundleKey, - const DistributedKv::Entry &entry); void ParseBundlePropertyFromDisturbeDB(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &bundleKey, const DistributedKv::Entry &entry); void ParseDoNotDisturbType(NotificationPreferencesInfo &info); void ParseDoNotDisturbBeginDate(NotificationPreferencesInfo &info); void ParseDoNotDisturbEndDate(NotificationPreferencesInfo &info); void ParseEnableAllNotification(NotificationPreferencesInfo &info); - void ParseGroupDescription( - const std::string &bundleKey, sptr &group, const DistributedKv::Entry &entry); void ParseBundleName(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseBundleImportance(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseBundleShowBadge(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; @@ -255,7 +223,6 @@ private: void ParseBundleUid(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseSlot( const std::string &findString, sptr &slot, const DistributedKv::Entry &entry); - void ParseSlotGroupId(sptr &slot, const std::string &value) const; void ParseSlotDescription(sptr &slot, const std::string &value) const; void ParseSlotLevel(sptr &slot, const std::string &value) const; void ParseSlotShowBadge(sptr &slot, const std::string &value) const; diff --git a/services/ans/include/notification_preferences_info.h b/services/ans/include/notification_preferences_info.h index 5a567efcc2671b9b027b10b40a214a25251fbbd0..450655e8db68f7d24a556e28dced99d9e73acf1d 100644 --- a/services/ans/include/notification_preferences_info.h +++ b/services/ans/include/notification_preferences_info.h @@ -23,7 +23,6 @@ #include "notification_bundle_option.h" #include "notification_do_not_disturb_date.h" #include "notification_slot.h" -#include "notification_slot_group.h" #include "preferences_constant.h" namespace OHOS { @@ -170,37 +169,6 @@ public: */ bool GetAllSlotsInGroup(const std::string &groupId, std::vector &slots); - /** - * @brief Set bundle group. - * - * @param group Indicates the set group. - */ - void SetGroup(const sptr &group); - - /** - * @brief Get group from bundle. - * - * @param groupId Indicates the get group id in the of bundle. - * @param group Indicates the get group. - * @return Return true on success, false on failure. - */ - bool GetGroup(const std::string &groupId, sptr &group); - - /** - * @brief Get all group from bundle. - * - * @param group Indicates the get groups. - * @return Return true on success, false on failure. - */ - bool GetAllGroups(std::vector> &group); - - /** - * @brief Get slot group num from bundle. - * - * @return Return num is group size. - */ - size_t GetGroupSize() const; - /** * @brief Check whether to exsist slot in the of bundle. * @@ -209,14 +177,6 @@ public: */ bool IsExsitSlot(const NotificationConstant::SlotType &type) const; - /** - * @brief Check whether to exsist slot group in the of bundle. - * - * @param groupId Indicates the slot group id. - * @return Return true on success, false on failure. - */ - bool IsExsitSlotGroup(const std::string &groupId) const; - /** * @brief Rremove a slot from bundle. * @@ -232,13 +192,6 @@ public: */ void RemoveAllSlots(); - /** - * @brief remove slot group from bundle. - * - * @param groupId Indicates the slot group id. - * @return Return true on success, false on failure. - */ - bool RemoveSlotGroup(const std::string &groupId); void SetBundleUid(const int32_t &uid); int32_t GetBundleUid() const; void SetSlotEnabled(NotificationConstant::SlotType slotType, bool enabled); @@ -254,7 +207,6 @@ public: bool isEnabledNotification_ = BUNDLE_ENABLE_NOTIFICATION; bool hasPoppedDialog_ = BUNDLE_POPPED_DIALOG; std::map> slots_; - std::map> groups_; }; /* diff --git a/services/ans/include/preferences_constant.h b/services/ans/include/preferences_constant.h index c99d818fddb35296b8b324b8f66b4be0c186c92c..fae1fd77ea264c3d4245e9e58bdfa422f9b651be 100644 --- a/services/ans/include/preferences_constant.h +++ b/services/ans/include/preferences_constant.h @@ -21,7 +21,7 @@ namespace Notification { /** * Indicates distributed database app id. */ -constexpr char APP_ID[] = "advanced_notification_service"; +constexpr char APP_ID[] = "notification_service"; /** * Indicates distributed database store id. diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 1d39e77fa8c7812c11c21aff286ae77d96f44c84..11bbd96de2e2be8afaa4e599ad5017a4afaa74dc 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -751,21 +751,6 @@ ErrCode AdvancedNotificationService::AddSlots(const std::vector> groups) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - - sptr bundleOption = GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind( - [&]() { result = NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption, groups); })); - return result; -} - ErrCode AdvancedNotificationService::GetSlots(std::vector> &slots) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -786,62 +771,6 @@ ErrCode AdvancedNotificationService::GetSlots(std::vector return result; } -ErrCode AdvancedNotificationService::GetSlotGroup(const std::string &groupId, sptr &group) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - - sptr bundleOption = GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind([&]() { - result = NotificationPreferences::GetInstance().GetNotificationSlotGroup(bundleOption, groupId, group); - if (result == ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST) { - result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST; - } - })); - return result; -} - -ErrCode AdvancedNotificationService::GetSlotGroups(std::vector> &groups) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - - sptr bundleOption = GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind([&]() { - result = NotificationPreferences::GetInstance().GetNotificationAllSlotGroups(bundleOption, groups); - if (result == ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST) { - result = ERR_OK; - groups.clear(); - } - })); - return result; -} - -ErrCode AdvancedNotificationService::RemoveSlotGroups(const std::vector &groupIds) -{ - sptr bundleOption = GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind([&]() { - result = NotificationPreferences::GetInstance().RemoveNotificationSlotGroups(bundleOption, groupIds); - if (result == ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST) { - result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID; - } - })); - return result; -} - ErrCode AdvancedNotificationService::GetActiveNotifications(std::vector> ¬ifications) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -1194,34 +1123,6 @@ ErrCode AdvancedNotificationService::UpdateSlots( return result; } -ErrCode AdvancedNotificationService::UpdateSlotGroups( - const sptr &bundleOption, const std::vector> &groups) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - - if (!IsSystemApp()) { - return ERR_ANS_NON_SYSTEM_APP; - } - - if (!CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { - return ERR_ANS_PERMISSION_DENIED; - } - - sptr bundle = GenerateValidBundleOption(bundleOption); - if (bundle == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind([&]() { - result = NotificationPreferences::GetInstance().UpdateNotificationSlotGroups(bundle, groups); - if (result == ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST) { - result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST; - } - })); - return result; -} - ErrCode AdvancedNotificationService::SetShowBadgeEnabledForBundle( const sptr &bundleOption, bool enabled) { diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 30bf6e1929bb59b0a4dc1005fce4a66dcd815a31..8d12e9f2cc822339a5fab3e46b7c66bc592415b6 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -69,34 +69,6 @@ ErrCode NotificationPreferences::AddNotificationSlots( return result; } -ErrCode NotificationPreferences::AddNotificationSlotGroups( - const sptr &bundleOption, const std::vector> &groups) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - if (bundleOption == nullptr || bundleOption->GetBundleName().empty() || groups.empty()) { - return ERR_ANS_INVALID_PARAM; - } - - NotificationPreferencesInfo preferencesInfo = preferencesInfo_; - ErrCode result = ERR_OK; - for (auto group : groups) { - result = CheckGroupForCreateSlotGroup(bundleOption, group, preferencesInfo); - if (result != ERR_OK) { - return result; - } - } - - if ((result == ERR_OK) && - (!preferncesDB_->PutGroupsToDisturbeDB(bundleOption->GetBundleName(), bundleOption->GetUid(), groups))) { - return ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; - } - - if (result == ERR_OK) { - preferencesInfo_ = preferencesInfo; - } - return result; -} - ErrCode NotificationPreferences::AddNotificationBundleProperty(const sptr &bundleOption) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { @@ -162,31 +134,6 @@ ErrCode NotificationPreferences::RemoveNotificationAllSlots(const sptr &bundleOption, const std::vector &groupIds) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - if (bundleOption == nullptr || bundleOption->GetBundleName().empty() || groupIds.empty()) { - return ERR_ANS_INVALID_PARAM; - } - NotificationPreferencesInfo preferencesInfo = preferencesInfo_; - ErrCode result = ERR_OK; - for (auto groupId : groupIds) { - result = CheckGroupForRemoveSlotGroup(bundleOption, groupId, preferencesInfo); - if (result != ERR_OK) { - return result; - } - } - if ((result == ERR_OK) && (!preferncesDB_->RemoveGroupsFromDisturbeDB(GenerateBundleKey(bundleOption), groupIds))) { - return ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; - } - - if (result == ERR_OK) { - preferencesInfo_ = preferencesInfo; - } - return result; -} - ErrCode NotificationPreferences::RemoveNotificationForBundle(const sptr &bundleOption) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -242,34 +189,6 @@ ErrCode NotificationPreferences::UpdateNotificationSlots( return result; } -ErrCode NotificationPreferences::UpdateNotificationSlotGroups( - const sptr &bundleOption, const std::vector> &groups) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - if (bundleOption == nullptr || bundleOption->GetBundleName().empty() || groups.empty()) { - return ERR_ANS_INVALID_PARAM; - } - - NotificationPreferencesInfo preferencesInfo = preferencesInfo_; - ErrCode result = ERR_OK; - for (auto groupIter : groups) { - result = CheckGroupForUpdateSlotGroup(bundleOption, groupIter, preferencesInfo); - if (result != ERR_OK) { - return result; - } - } - - if ((result == ERR_OK) && - (!preferncesDB_->PutGroupsToDisturbeDB(bundleOption->GetBundleName(), bundleOption->GetUid(), groups))) { - return ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; - } - - if (result == ERR_OK) { - preferencesInfo_ = preferencesInfo; - } - return result; -} - ErrCode NotificationPreferences::GetNotificationSlot(const sptr &bundleOption, const NotificationConstant::SlotType &type, sptr &slot) { @@ -327,62 +246,6 @@ ErrCode NotificationPreferences::GetNotificationSlotsNumForBundle( return result; } -ErrCode NotificationPreferences::GetNotificationSlotGroup( - const sptr &bundleOption, const std::string &groupId, sptr &group) -{ - if (bundleOption == nullptr || bundleOption->GetBundleName().empty() || groupId.empty()) { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode result = ERR_OK; - NotificationPreferencesInfo::BundleInfo bundleInfo; - if (preferencesInfo_.GetBundleInfo(bundleOption, bundleInfo)) { - if (!bundleInfo.GetGroup(groupId, group)) { - result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST; - } - } else { - ANS_LOGW("Notification bundle does not exsit."); - result = ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST; - } - return result; -} - -ErrCode NotificationPreferences::GetNotificationAllSlotGroups( - const sptr &bundleOption, std::vector> &groups) -{ - if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode result = ERR_OK; - NotificationPreferencesInfo::BundleInfo bundleInfo; - if (preferencesInfo_.GetBundleInfo(bundleOption, bundleInfo)) { - bundleInfo.GetAllGroups(groups); - } else { - ANS_LOGW("Notification bundle does not exsit."); - result = ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST; - } - return result; -} - -ErrCode NotificationPreferences::GetNotificationAllSlotInSlotGroup(const sptr &bundleOption, - const std::string &groupId, std::vector> &slots) -{ - if (bundleOption == nullptr || bundleOption->GetBundleName().empty() || groupId.empty()) { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode result = ERR_OK; - NotificationPreferencesInfo::BundleInfo bundleInfo; - if (preferencesInfo_.GetBundleInfo(bundleOption, bundleInfo)) { - bundleInfo.GetAllSlotsInGroup(groupId, slots); - } else { - ANS_LOGW("Notification bundle does not exsit."); - result = ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST; - } - return result; -} - ErrCode NotificationPreferences::IsShowBadge(const sptr &bundleOption, bool &enable) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { @@ -625,36 +488,6 @@ ErrCode NotificationPreferences::CheckSlotForCreateSlot(const sptr &bundleOption, - const sptr &group, NotificationPreferencesInfo &preferencesInfo) const -{ - if (group == nullptr) { - ANS_LOGE("Notification slot group is nullptr."); - return ERR_ANS_INVALID_PARAM; - } - - if (group->GetId().empty()) { - ANS_LOGE("Notification slot group id is invalid."); - return ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID; - } - - NotificationPreferencesInfo::BundleInfo bundleInfo; - if (!preferencesInfo.GetBundleInfo(bundleOption, bundleInfo)) { - bundleInfo.SetBundleName(bundleOption->GetBundleName()); - bundleInfo.SetBundleUid(bundleOption->GetUid()); - bundleInfo.SetEnableNotification(CheckApiCompatibility(bundleOption)); - } else { - if (bundleInfo.GetGroupSize() >= MAX_SLOT_GROUP_NUM) { - return ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_EXCEED_MAX_NUM; - } - } - - bundleInfo.SetGroup(group); - preferencesInfo.SetBundleInfo(bundleInfo); - - return ERR_OK; -} - ErrCode NotificationPreferences::CheckSlotForRemoveSlot(const sptr &bundleOption, const NotificationConstant::SlotType &slotType, NotificationPreferencesInfo &preferencesInfo) const { @@ -675,26 +508,6 @@ ErrCode NotificationPreferences::CheckSlotForRemoveSlot(const sptr &bundleOption, - const std::string &groupId, NotificationPreferencesInfo &preferencesInfo) const -{ - ErrCode result = ERR_OK; - NotificationPreferencesInfo::BundleInfo bundleInfo; - if (preferencesInfo.GetBundleInfo(bundleOption, bundleInfo)) { - if (bundleInfo.IsExsitSlotGroup(groupId)) { - bundleInfo.RemoveSlotGroup(groupId); - preferencesInfo.SetBundleInfo(bundleInfo); - } else { - ANS_LOGE("Notification slot group id is invalid."); - result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID; - } - } else { - ANS_LOGW("Notification bundle does not exsit."); - result = ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST; - } - return result; -} - ErrCode NotificationPreferences::CheckSlotForUpdateSlot(const sptr &bundleOption, const sptr &slot, NotificationPreferencesInfo &preferencesInfo) const { @@ -723,27 +536,6 @@ ErrCode NotificationPreferences::CheckSlotForUpdateSlot(const sptr &bundleOption, - const sptr &group, NotificationPreferencesInfo &preferencesInfo) const -{ - ErrCode result = ERR_OK; - NotificationPreferencesInfo::BundleInfo bundleInfo; - if (preferencesInfo.GetBundleInfo(bundleOption, bundleInfo)) { - if (bundleInfo.IsExsitSlotGroup(group->GetId())) { - bundleInfo.SetBundleName(bundleOption->GetBundleName()); - bundleInfo.SetBundleUid(bundleOption->GetUid()); - bundleInfo.SetGroup(group); - preferencesInfo.SetBundleInfo(bundleInfo); - } else { - result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST; - } - } else { - ANS_LOGW("Notification slot is nullptr."); - result = ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST; - } - return result; -} - template ErrCode NotificationPreferences::SetBundleProperty(NotificationPreferencesInfo &preferencesInfo, const sptr &bundleOption, const BundleType &type, const T &value) diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index 842216dbbea9c3e0cae10fecfa63f07b156401bd..24299562a474ed581e36c1f89c08a0f49780fddd 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -98,31 +98,6 @@ const static std::string KEY_BUNDLE_POPPED_DIALOG = "poppedDialog"; */ const static std::string KEY_BUNDLE_UID = "uid"; -/** - * Indicates that disturbe key which group. - */ -const static std::string KEY_GROUP = "group"; - -/** - * Indicates that disturbe key which group id. - */ -const static std::string KEY_GROUP_ID = "id"; - -/** - * Indicates that disturbe key which group name. - */ -const static std::string KEY_GROUP_NAME = "name"; - -/** - * Indicates that disturbe key which group description. - */ -const static std::string KEY_GROUP_DESCRIPTION = "groupDescription"; - -/** - * Indicates that disturbe key which group is disable. - */ -const static std::string KEY_GROUP_DISABLE = "isDisable"; - /** * Indicates that disturbe key which slot. */ @@ -139,12 +114,7 @@ const static std::string KEY_SLOT_TYPE = "type"; const static std::string KEY_SLOT_ID = "id"; /** - * Indicates that disturbe key which slot group id. - */ -const static std::string KEY_SLOT_GROUPID = "groupId"; - -/** - * Indicates that disturbe key which slot group name. + * Indicates that disturbe key which slot name. */ const static std::string KEY_SLOT_NAME = "name"; @@ -203,14 +173,11 @@ const static std::string KEY_SLOT_ENABLE_BYPASS_DND = "enableBypassDnd"; */ const static std::string KEY_SLOT_ENABLED = "enabled"; +constexpr char KV_STORE_PATH[] = "/data/service/el1/public/database/notification_service"; + const std::map &, std::string &)>> NotificationPreferencesDatabase::slotMap_ = { - { - KEY_SLOT_GROUPID, - std::bind(&NotificationPreferencesDatabase::ParseSlotGroupId, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3), - }, { KEY_SLOT_DESCRIPTION, std::bind(&NotificationPreferencesDatabase::ParseSlotDescription, std::placeholders::_1, @@ -338,7 +305,9 @@ DistributedKv::Status NotificationPreferencesDatabase::GetKvStore() .createIfMissing = true, .encrypt = false, .autoSync = false, + .area = DistributedKv::EL1, .kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION, + .baseDir = KV_STORE_PATH }; auto status = dataManager_.GetSingleKvStore(options, appId_, storeId_, kvStorePtr_); if (status != DistributedKv::Status::SUCCESS) { @@ -392,37 +361,7 @@ bool NotificationPreferencesDatabase::PutSlotsToDisturbeDB( return false; } DistributedKv::Status status = kvStorePtr_->PutBatch(entries); - return (status == DistributedKv::Status::SUCCESS); -} - -bool NotificationPreferencesDatabase::PutGroupsToDisturbeDB( - const std::string &bundleName, const int32_t &bundleUid, const std::vector> &groups) -{ - if (bundleName.empty()) { - ANS_LOGE("Bundle name is null."); - return false; - } - - if (groups.empty()) { - ANS_LOGE("Slot is empty."); - return false; - } - - bool result = true; - std::vector entries; - for (auto iter : groups) { - result = GroupToEntry(bundleName, bundleUid, iter, entries); - if (!result) { - ANS_LOGE("Group to entry is null."); - return result; - } - } - - if (!CheckKvStore()) { - ANS_LOGE("KvStore is nullptr."); - return false; - } - DistributedKv::Status status = kvStorePtr_->PutBatch(entries); + CloseKvStore(); return (status == DistributedKv::Status::SUCCESS); } @@ -455,6 +394,7 @@ bool NotificationPreferencesDatabase::PutBundlePropertyToDisturbeDB( break; } }); + CloseKvStore(); return result; } @@ -559,6 +499,7 @@ bool NotificationPreferencesDatabase::PutNotificationsEnabled(const int32_t &use DistributedKv::Key enableKey(typeKey); DistributedKv::Value enableValue(std::to_string(enabled)); DistributedKv::Status status = kvStorePtr_->Put(enableKey, enableValue); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("Store enable notification failed. %{public}d", status); return false; @@ -622,6 +563,7 @@ bool NotificationPreferencesDatabase::PutDoNotDisturbDate( }; DistributedKv::Status status = kvStorePtr_->PutBatch(entries); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("Store DoNotDisturbDate failed. %{public}d", status); return false; @@ -750,6 +692,7 @@ bool NotificationPreferencesDatabase::ParseFromDisturbeDB(NotificationPreference return false; } ParseBundleFromDistureDB(info, entries); + CloseKvStore(); return true; } @@ -760,7 +703,7 @@ bool NotificationPreferencesDatabase::RemoveAllDataFromDisturbeDB() ANS_LOGE("KvStore is nullptr."); return false; } - DistributedKv::Status status = dataManager_.DeleteKvStore(appId_, storeId_); + DistributedKv::Status status = dataManager_.DeleteKvStore(appId_, storeId_, KV_STORE_PATH); return (status == DistributedKv::Status::SUCCESS); } @@ -779,6 +722,7 @@ bool NotificationPreferencesDatabase::RemoveBundleFromDisturbeDB(const std::stri if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("Get Bundle Info failed."); + CloseKvStore(); return false; } @@ -790,6 +734,7 @@ bool NotificationPreferencesDatabase::RemoveBundleFromDisturbeDB(const std::stri DistributedKv::Key bundleDBKey(KEY_BUNDLE_LABEL + KEY_BUNDLE_NAME + KEY_UNDER_LINE + bundleKey); keys.push_back(bundleDBKey); status = kvStorePtr_->DeleteBatch(keys); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("delete bundle Info failed."); return false; @@ -818,6 +763,7 @@ bool NotificationPreferencesDatabase::RemoveSlotFromDisturbeDB( status = kvStorePtr_->GetEntries(DistributedKv::Key(GenerateSlotKey(bundleKey, slotType) + KEY_UNDER_LINE), slotentries); if (status != DistributedKv::Status::SUCCESS) { + CloseKvStore(); return false; } std::vector keys; @@ -826,6 +772,7 @@ bool NotificationPreferencesDatabase::RemoveSlotFromDisturbeDB( } status = kvStorePtr_->DeleteBatch(keys); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("delete bundle Info failed."); return false; @@ -852,6 +799,7 @@ bool NotificationPreferencesDatabase::RemoveAllSlotsFromDisturbeDB(const std::st std::vector slotsEntries; status = kvStorePtr_->GetEntries(DistributedKv::Key(GenerateSlotKey(bundleKey) + KEY_UNDER_LINE), slotsEntries); if (status != DistributedKv::Status::SUCCESS) { + CloseKvStore(); return false; } std::vector keys; @@ -860,64 +808,11 @@ bool NotificationPreferencesDatabase::RemoveAllSlotsFromDisturbeDB(const std::st } status = kvStorePtr_->DeleteBatch(keys); + CloseKvStore(); ANS_LOGD("%{public}s remove all slots status %{public}d", __FUNCTION__, status); return (status == DistributedKv::Status::SUCCESS); } -bool NotificationPreferencesDatabase::RemoveGroupsFromDisturbeDB( - const std::string &bundleKey, const std::vector &groupIds) -{ - if (bundleKey.empty()) { - ANS_LOGE("Bundle name is null."); - return false; - } - - if (groupIds.empty()) { - ANS_LOGE("Group id is empty."); - return false; - } - - if (!CheckKvStore()) { - ANS_LOGE("KvStore is nullptr."); - return false; - } - - std::vector keys; - bool result = true; - for (auto iter : groupIds) { - result = GetRemoveGroupKeysFromDisturbeDB(bundleKey, iter, keys); - if (!result) { - return result; - } - } - - DistributedKv::Status status = kvStorePtr_->DeleteBatch(keys); - ANS_LOGD("%{public}s remove groups status %{public}d", __FUNCTION__, status); - return (status == DistributedKv::Status::SUCCESS); -} - -bool NotificationPreferencesDatabase::GetRemoveGroupKeysFromDisturbeDB( - const std::string &bundleKey, const std::string &groupId, std::vector &keys) -{ - if (!CheckKvStore()) { - ANS_LOGE("KvStore is nullptr."); - return false; - } - - DistributedKv::Status status; - std::vector groupentries; - std::string slotKeyStr = GenerateGroupKey(bundleKey, groupId); - status = kvStorePtr_->GetEntries(DistributedKv::Key(slotKeyStr + KEY_UNDER_LINE), groupentries); - if (status != DistributedKv::Status::SUCCESS) { - return false; - } - for (auto iter : groupentries) { - keys.push_back(iter.key); - } - - return true; -} - bool NotificationPreferencesDatabase::StoreDeathRecipient() { ANS_LOGW("distribute remote died"); @@ -961,6 +856,7 @@ DistributedKv::Status NotificationPreferencesDatabase::PutBundlePropertyToDistur return DistributedKv::Status::ERROR; } DistributedKv::Status status = kvStorePtr_->Put(key, value); + CloseKvStore(); return status; } @@ -1002,7 +898,7 @@ bool NotificationPreferencesDatabase::SlotToEntry(const std::string &bundleName, const sptr &slot, std::vector &entries) { if (slot == nullptr) { - ANS_LOGE("Notification group is nullptr."); + ANS_LOGE("Notification slot is nullptr."); return false; } @@ -1021,7 +917,6 @@ void NotificationPreferencesDatabase::GenerateSlotEntry(const std::string &bundl std::string slotType = std::to_string(slot->GetType()); GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_TYPE), std::to_string(slot->GetType()), entries); GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_ID), slot->GetId(), entries); - GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_GROUPID), slot->GetSlotGroup(), entries); GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_NAME), slot->GetName(), entries); GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_DESCRIPTION), slot->GetDescription(), entries); GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_LEVEL), std::to_string(slot->GetLevel()), entries); @@ -1047,35 +942,6 @@ void NotificationPreferencesDatabase::GenerateSlotEntry(const std::string &bundl GenerateEntry(GenerateSlotKey(bundleKey, slotType, KEY_SLOT_ENABLED), std::to_string(slot->GetEnable()), entries); } -bool NotificationPreferencesDatabase::GroupToEntry(const std::string &bundleName, const int32_t &bundleUid, - const sptr &group, std::vector &entries) -{ - - if (group == nullptr) { - ANS_LOGE("Notification group is nullptr."); - return false; - } - - if (!CheckBundle(bundleName, bundleUid)) { - return false; - } - - std::string bundleKey = bundleName + std::to_string(bundleUid); - GenerateGroupEntry(bundleKey, group, entries); - return true; -} - -void NotificationPreferencesDatabase::GenerateGroupEntry(const std::string &bundleKey, - const sptr &group, std::vector &entries) const -{ - std::string groupLebal = group->GetId().append(KEY_UNDER_LINE); - GenerateEntry(GenerateGroupKey(bundleKey, groupLebal + KEY_GROUP_ID), group->GetId(), entries); - GenerateEntry(GenerateGroupKey(bundleKey, groupLebal + KEY_GROUP_NAME), group->GetName(), entries); - GenerateEntry(GenerateGroupKey(bundleKey, groupLebal + KEY_GROUP_DESCRIPTION), group->GetDescription(), entries); - GenerateEntry( - GenerateGroupKey(bundleKey, groupLebal + KEY_GROUP_DISABLE), std::to_string(group->IsDisabled()), entries); -} - void NotificationPreferencesDatabase::ParseBundleFromDistureDB( NotificationPreferencesInfo &info, const std::vector &entries) { @@ -1093,8 +959,6 @@ void NotificationPreferencesDatabase::ParseBundleFromDistureDB( for (auto bundleEntry : bundleEntries) { if (IsSlotKey(GenerateBundleKey(bundleKey), bundleEntry.key.ToString())) { ParseSlotFromDisturbeDB(bunldeInfo, bundleKey, bundleEntry); - } else if (IsGroupKey(GenerateBundleKey(bundleKey), bundleEntry.key.ToString())) { - ParseGroupFromDisturbeDB(bunldeInfo, bundleKey, bundleEntry); } else { ParseBundlePropertyFromDisturbeDB(bunldeInfo, bundleKey, bundleEntry); } @@ -1119,32 +983,6 @@ void NotificationPreferencesDatabase::ParseSlotFromDisturbeDB(NotificationPrefer bundleInfo.SetSlot(slot); } -void NotificationPreferencesDatabase::ParseGroupFromDisturbeDB(NotificationPreferencesInfo::BundleInfo &bundleInfo, - const std::string &bundleKey, const DistributedKv::Entry &entry) -{ - if (!CheckKvStore()) { - ANS_LOGE("KvStore is nullptr."); - return; - } - std::string groupKey = entry.key.ToString(); - std::string groupId = SubUniqueIdentifyFromString(GenerateGroupKey(bundleKey) + KEY_UNDER_LINE, groupKey); - sptr group; - if (!bundleInfo.GetGroup(groupId, group)) { - std::string groupName; - std::string groupNameKey = GenerateGroupKey(bundleKey, groupId + KEY_UNDER_LINE + KEY_GROUP_NAME); - GetValueFromDisturbeDB( - groupNameKey, [&groupName](DistributedKv::Value &value) { groupName = value.ToString(); }); - if (groupName.empty()) { - ANS_LOGE("Group name does not exsited."); - return; - } - group = new NotificationSlotGroup(groupId, groupName); - } - - ParseGroupDescription(bundleKey, group, entry); - bundleInfo.SetGroup(group); -} - void NotificationPreferencesDatabase::ParseBundlePropertyFromDisturbeDB( NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &bundleKey, const DistributedKv::Entry &entry) @@ -1246,20 +1084,6 @@ bool NotificationPreferencesDatabase::IsSlotKey(const std::string &bundleKey, co return false; } -bool NotificationPreferencesDatabase::IsGroupKey(const std::string &bundleKey, const std::string &key) const -{ - std::string tempStr = FindLastString(bundleKey, key); - size_t pos = tempStr.find_first_of(KEY_UNDER_LINE); - std::string slotStr; - if (pos != std::string::npos) { - slotStr = tempStr.substr(0, pos); - } - if (!slotStr.compare(KEY_GROUP)) { - return true; - } - return false; -} - std::string NotificationPreferencesDatabase::GenerateSlotKey( const std::string &bundleKey, const std::string &type, const std::string &subType) const { @@ -1282,24 +1106,6 @@ std::string NotificationPreferencesDatabase::GenerateSlotKey( return key; } -std::string NotificationPreferencesDatabase::GenerateGroupKey( - const std::string &bundleKey, const std::string &type) const -{ - /* group key - * - * KEY_ANS_BUNDLE_bundlename_group_id_id0_id: - * KEY_ANS_BUNDLE_bundlename_group_id_id0_name: - * KEY_ANS_BUNDLE_bundlename_group_id_id1_name - * - */ - std::string key = GenerateBundleKey(bundleKey).append(KEY_GROUP).append(KEY_UNDER_LINE).append(KEY_GROUP_ID); - if (!type.empty()) { - key.append(KEY_UNDER_LINE).append(type); - } - ANS_LOGD("Group key is %{public}s.", key.c_str()); - return key; -} - std::string NotificationPreferencesDatabase::GenerateBundleKey( const std::string &bundleKey, const std::string &type) const { @@ -1374,18 +1180,6 @@ void NotificationPreferencesDatabase::ParseEnableAllNotification(NotificationPre } } -void NotificationPreferencesDatabase::ParseGroupDescription( - const std::string &bundleKey, sptr &group, const DistributedKv::Entry &entry) -{ - std::string findStr = GenerateGroupKey(bundleKey, group->GetId()) + KEY_UNDER_LINE; - std::string typeStr = FindLastString(findStr, entry.key.ToString()); - std::string valueStr = entry.value.ToString(); - if (!typeStr.compare(KEY_GROUP_DESCRIPTION)) { - ANS_LOGD("SetGroupDescription is %{public}s.", valueStr.c_str()); - group->SetDescription(valueStr); - } -} - void NotificationPreferencesDatabase::ParseBundleName( NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const { @@ -1442,13 +1236,6 @@ void NotificationPreferencesDatabase::ParseBundleUid( bundleInfo.SetBundleUid(StringToInt(value)); } -void NotificationPreferencesDatabase::ParseSlotGroupId(sptr &slot, const std::string &value) const -{ - ANS_LOGD("ParseSlotGroupId slot group id is %{public}s.", value.c_str()); - std::string slotGroupId = value; - slot->SetSlotGroup(slotGroupId); -} - void NotificationPreferencesDatabase::ParseSlotDescription(sptr &slot, const std::string &value) const { ANS_LOGD("ParseSlotDescription slot des is %{public}s.", value.c_str()); @@ -1650,6 +1437,7 @@ bool NotificationPreferencesDatabase::RemoveNotificationEnable(const int32_t use std::string(KEY_ENABLE_ALL_NOTIFICATION).append(KEY_UNDER_LINE).append(std::to_string(userId)); DistributedKv::Key enableKey(key); DistributedKv::Status status = kvStorePtr_->Delete(enableKey); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("delete bundle Info failed."); return false; @@ -1681,6 +1469,7 @@ bool NotificationPreferencesDatabase::RemoveDoNotDisturbDate(const int32_t userI }; DistributedKv::Status status = kvStorePtr_->DeleteBatch(keys); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("delete DoNotDisturb date failed."); return false; diff --git a/services/ans/src/notification_preferences_info.cpp b/services/ans/src/notification_preferences_info.cpp index bd2788d8401e859a3dd934c4a235428018d7ef43..2ab4e39f8afd934ab52ce464e6a7a8e29cce8f86 100644 --- a/services/ans/src/notification_preferences_info.cpp +++ b/services/ans/src/notification_preferences_info.cpp @@ -124,84 +124,12 @@ uint32_t NotificationPreferencesInfo::BundleInfo::GetAllSlotsSize() return slots_.size(); } -bool NotificationPreferencesInfo::BundleInfo::GetAllSlotsInGroup( - const std::string &groupId, std::vector> &slots) -{ - std::for_each(slots_.begin(), - slots_.end(), - [&](std::map>::reference iter) { - if (!iter.second->GetSlotGroup().compare(groupId)) { - slots.emplace_back(iter.second); - } - }); - return true; -} - -bool NotificationPreferencesInfo::BundleInfo::GetAllSlotsInGroup( - const std::string &groupId, std::vector &slots) -{ - std::for_each(slots_.begin(), - slots_.end(), - [&](std::map>::reference &iter) { - if (!iter.second->GetSlotGroup().compare(groupId)) { - slots.emplace_back(*iter.second); - } - }); - return true; -} - -void NotificationPreferencesInfo::BundleInfo::SetGroup(const sptr &group) -{ - if (group) { - groups_.insert_or_assign(group->GetId(), group); - } -} - -bool NotificationPreferencesInfo::BundleInfo::GetGroup(const std::string &groupId, sptr &group) -{ - auto iter = groups_.find(groupId); - if (iter != groups_.end()) { - group = iter->second; - std::vector slots; - GetAllSlotsInGroup(groupId, slots); - group->SetSlots(slots); - return true; - } - return false; -} - -bool NotificationPreferencesInfo::BundleInfo::GetAllGroups(std::vector> &group) -{ - std::for_each( - groups_.begin(), groups_.end(), [&](std::map>::reference iter) { - std::vector slots; - GetAllSlotsInGroup(iter.second->GetId(), slots); - iter.second->SetSlots(slots); - group.emplace_back(iter.second); - }); - return true; -} - -size_t NotificationPreferencesInfo::BundleInfo::GetGroupSize() const -{ - return groups_.size(); -} - bool NotificationPreferencesInfo::BundleInfo::IsExsitSlot(const NotificationConstant::SlotType &type) const { auto iter = slots_.find(type); return (iter != slots_.end()); } -bool NotificationPreferencesInfo::BundleInfo::IsExsitSlotGroup(const std::string &groupId) const -{ - auto iter = groups_.find(groupId); - if (iter != groups_.end()) { - return true; - } - return false; -} - bool NotificationPreferencesInfo::BundleInfo::RemoveSlot(const NotificationConstant::SlotType &type) { auto iter = slots_.find(type); @@ -217,16 +145,6 @@ void NotificationPreferencesInfo::BundleInfo::RemoveAllSlots() slots_.clear(); } -bool NotificationPreferencesInfo::BundleInfo::RemoveSlotGroup(const std::string &groupId) -{ - auto iter = groups_.find(groupId); - if (iter != groups_.end()) { - groups_.erase(groupId); - return true; - } - return false; -} - void NotificationPreferencesInfo::BundleInfo::SetBundleUid(const int32_t &uid) { uid_ = uid; diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 98af315dc0b20f93f20a601fc9da6335efc7e98e..453f0c4e27b2766eae45f40e0de199db9b78aeb7 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -44,7 +44,6 @@ public: private: void TestAddSlot(NotificationConstant::SlotType type); - void TestAddSlotGroup(); private: static sptr advancedNotificationService_; @@ -114,14 +113,6 @@ void AdvancedNotificationServiceTest::TestAddSlot(NotificationConstant::SlotType EXPECT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_OK); } -void AdvancedNotificationServiceTest::TestAddSlotGroup() -{ - std::vector> groups; - sptr group = new NotificationSlotGroup("id0", "name0"); - groups.push_back(group); - advancedNotificationService_->AddSlotGroups(groups); -} - /** * @tc.number : ANS_Publish_00100 * @tc.name : ANSPublish00100 @@ -445,19 +436,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01300, SleepForFC(); } -/** - * @tc.number : ANS_Publish_01400 - * @tc.name : ANSPublish01400 - * @tc.desc : - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01400, Function | SmallTest | Level1) -{ - TestAddSlotGroup(); - std::vector groupIds; - groupIds.push_back("id0"); - EXPECT_EQ(advancedNotificationService_->RemoveSlotGroups(groupIds), (int)ERR_OK); -} - /** * @tc.number : AdvancedNotificationServiceTest_01600 * @tc.name : ANS_GetSlot_0200 @@ -477,25 +455,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01600, EXPECT_EQ((int)slotsResult.size(), 1); } -/** - * @tc.number : AdvancedNotificationServiceTest_01700 - * @tc.name : ANS_GetSlotGroup_0100 - * @tc.desc : Test GetSlotGroup function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01700, Function | SmallTest | Level1) -{ - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id2", "name2"); - group2->SetDescription("Description"); - groups.push_back(group2); - advancedNotificationService_->AddSlotGroups(groups); - sptr group = new NotificationSlotGroup(); - EXPECT_EQ(advancedNotificationService_->GetSlotGroup("id2", group), ERR_OK); - EXPECT_EQ(group2->GetId(), group->GetId()); - EXPECT_EQ(group2->GetName(), group->GetName()); - EXPECT_EQ(group2->GetDescription(), group->GetDescription()); -} - /** * @tc.number : AdvancedNotificationServiceTest_01800 * @tc.name : ANS_SetNotificationBadgeNum_0100 @@ -576,38 +535,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02300, (int)ERR_OK); } -/** - * @tc.number : AdvancedNotificationServiceTest_02400 - * @tc.name : ANS_UpdateSlotGroups_0100 - * @tc.desc : Test UpdateSlotGroups function when no group - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02400, Function | SmallTest | Level1) -{ - TestAddSlotGroup(); - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id1", "name1"); - groups.push_back(group2); - EXPECT_EQ((int)advancedNotificationService_->UpdateSlotGroups( - new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST); -} - -/** - * @tc.number : AdvancedNotificationServiceTest_02500 - * @tc.name : ANS_UpdateSlotGroups_0200 - * @tc.desc : Test UpdateSlotGroups function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02500, Function | SmallTest | Level1) -{ - TestAddSlotGroup(); - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id0", "name1"); - groups.push_back(group2); - EXPECT_EQ((int)advancedNotificationService_->UpdateSlotGroups( - new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), groups), - (int)ERR_OK); -} - /** * @tc.number : AdvancedNotificationServiceTest_02700 * @tc.name : ANS_SetShowBadgeEnabledForBundle_0100 @@ -853,34 +780,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05300, (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST); } -/** - * @tc.number : AdvancedNotificationServiceTest_05400 - * @tc.name : ANS_AddSlotGroups_0100 - * @tc.desc : Test AddSlotGroups function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05400, Function | SmallTest | Level1) -{ - std::vector> groups; - sptr group0 = new NotificationSlotGroup("id0", "name0"); - sptr group1 = new NotificationSlotGroup("id1", "name1"); - groups.push_back(group0); - groups.push_back(group1); - EXPECT_EQ(advancedNotificationService_->AddSlotGroups(groups), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationServiceTest_05500 - * @tc.name : ANS_RemoveSlotGroups_0100 - * @tc.desc : Test RemoveSlotGroups function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05500, Function | SmallTest | Level1) -{ - TestAddSlotGroup(); - std::vector groupIds; - groupIds.push_back("id0"); - EXPECT_EQ(advancedNotificationService_->RemoveSlotGroups(groupIds), (int)ERR_OK); -} - /** * @tc.number : AdvancedNotificationServiceTest_05600 * @tc.name : ANS_GetSlot_0100 @@ -899,25 +798,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05600, EXPECT_EQ(slot->GetLevel(), slot0->GetLevel()); } -/** - * @tc.number : AdvancedNotificationServiceTest_05800 - * @tc.name : ANS_GetSlotGroup_0100 - * @tc.desc : Test GetSlotGroup function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05800, Function | SmallTest | Level1) -{ - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id2", "name2"); - group2->SetDescription("Description"); - groups.push_back(group2); - advancedNotificationService_->AddSlotGroups(groups); - sptr group = new NotificationSlotGroup(); - EXPECT_EQ(advancedNotificationService_->GetSlotGroup("id2", group), ERR_OK); - EXPECT_EQ(group2->GetId(), group->GetId()); - EXPECT_EQ(group2->GetName(), group->GetName()); - EXPECT_EQ(group2->GetDescription(), group->GetDescription()); -} - /** * @tc.number : AdvancedNotificationServiceTest_05900 * @tc.name : ANS_SetNotificationBadgeNum_0100 @@ -998,38 +878,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06400, (int)ERR_OK); } -/** - * @tc.number : AdvancedNotificationServiceTest_06500 - * @tc.name : ANS_UpdateSlotGroups_0100 - * @tc.desc : Test UpdateSlotGroups function when no group - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06500, Function | SmallTest | Level1) -{ - TestAddSlot(NotificationConstant::SlotType::OTHER); - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id2", "name2"); - groups.push_back(group2); - EXPECT_EQ((int)advancedNotificationService_->UpdateSlotGroups( - new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST); -} - -/** - * @tc.number : AdvancedNotificationServiceTest_06600 - * @tc.name : ANS_UpdateSlotGroups_0200 - * @tc.desc : Test UpdateSlotGroups function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06600, Function | SmallTest | Level1) -{ - TestAddSlotGroup(); - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id0", "name2"); - groups.push_back(group2); - EXPECT_EQ((int)advancedNotificationService_->UpdateSlotGroups( - new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), groups), - (int)ERR_OK); -} - /** * @tc.number : AdvancedNotificationServiceTest_06800 * @tc.name : ANS_SetShowBadgeEnabledForBundle_0100 @@ -1144,23 +992,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_08700, EXPECT_EQ(slot->GetType(), NotificationConstant::SlotType::OTHER); } -/** - * @tc.number : AdvancedNotificationServiceTest_08900 - * @tc.name : ANS_GetSlotGroups_0100 - * @tc.desc : Test GetSlotGroups function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_08900, Function | SmallTest | Level1) -{ - std::vector> groups; - sptr group2 = new NotificationSlotGroup("id2", "name2"); - group2->SetDescription("Description"); - groups.push_back(group2); - advancedNotificationService_->AddSlotGroups(groups); - std::vector> group; - EXPECT_EQ(advancedNotificationService_->GetSlotGroups(group), ERR_OK); - EXPECT_EQ(groups.size(), group.size()); -} - /** * @tc.number : AdvancedNotificationServiceTest_09000 * @tc.name : ANS_GetAllActiveNotifications_0100 diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index e4857df84887d65b3e6b5bf94f2146cd7b9e7e28..392920628a83467da1eb4f924def30fb62ee0a24 100644 --- a/services/ans/test/unittest/notification_preferences_database_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_test.cpp @@ -76,44 +76,6 @@ HWTEST_F(NotificationPreferencesDatabaseTest, PutSlotsToDisturbeDB_00300, Functi EXPECT_FALSE(preferncesDB_->PutSlotsToDisturbeDB(bundleName_, bundleUid_, slots)); } -/** - * @tc.name : PutGroupsToDisturbeDB_00100 - * @tc.number : - * @tc.desc : Put slot group into disturbe DB, return is true. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, PutGroupsToDisturbeDB_00100, Function | SmallTest | Level1) -{ - sptr slotGroup = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(slotGroup); - - EXPECT_TRUE(preferncesDB_->PutGroupsToDisturbeDB(bundleName_, bundleUid_, groups)); -} - -/** - * @tc.name : PutGroupsToDisturbeDB_00200 - * @tc.number : - * @tc.desc : Put slot group into disturbe DB when bundle name is null, return is false. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, PutGroupsToDisturbeDB_00200, Function | SmallTest | Level1) -{ - sptr slotGroup = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(slotGroup); - EXPECT_FALSE(preferncesDB_->PutGroupsToDisturbeDB(std::string(), 0, groups)); -} - -/** - * @tc.number : PutGroupsToDisturbeDB_00300 - * @tc.name : - * @tc.desc : Put slot group into disturbe DB when groups is null, return is false. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, PutGroupsToDisturbeDB_00300, Function | SmallTest | Level1) -{ - std::vector> groups; - EXPECT_FALSE(preferncesDB_->PutGroupsToDisturbeDB(bundleName_, bundleUid_, groups)); -} - /** * @tc.name : PutShowBadge_00100 * @tc.number : @@ -415,47 +377,6 @@ HWTEST_F(NotificationPreferencesDatabaseTest, RemoveSlotFromDisturbeDB_00200, Fu std::string(), OHOS::Notification::NotificationConstant::SlotType::SOCIAL_COMMUNICATION)); } -/** - * @tc.name : RemoveGroupsFromDisturbeDB_00100 - * @tc.number : - * @tc.desc : Remove slot froup from disturbe DB, return is true. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, RemoveGroupsFromDisturbeDB_00100, Function | SmallTest | Level1) -{ - sptr slotGroup = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(slotGroup); - EXPECT_TRUE(preferncesDB_->PutGroupsToDisturbeDB(bundleName_, bundleUid_, groups)); - std::vector groupIds; - groupIds.push_back("id"); - EXPECT_TRUE(preferncesDB_->RemoveGroupsFromDisturbeDB(bundleName_, groupIds)); -} - -/** - * @tc.number : RemoveGroupsFromDisturbeDB_00200 - * @tc.name : - * @tc.desc : Remove slot froup from disturbe DB when bundle name is null, return is false. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, RemoveGroupsFromDisturbeDB_00200, Function | SmallTest | Level1) -{ - std::vector groupIds; - groupIds.push_back("group1"); - groupIds.push_back("group2"); - EXPECT_FALSE(preferncesDB_->RemoveGroupsFromDisturbeDB(std::string(), groupIds)); -} - -/** - * @tc.number : GetRemoveGroupKeys_00100 - * @tc.name : - * @tc.desc : Get remove group disturbe key, return is true. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, GetRemoveGroupKeys_00100, Function | SmallTest | Level1) -{ - std::string groupId = "id"; - std::vector keys; - EXPECT_TRUE(preferncesDB_->GetRemoveGroupKeysFromDisturbeDB(bundleName_, groupId, keys)); -} - /** * @tc.name : StoreDeathRecipient_00100 * @tc.number : @@ -509,19 +430,6 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ChangeSlotToEntry_00100, Function EXPECT_TRUE(preferncesDB_->SlotToEntry(bundleName_, bundleUid_, slot, entries)); } -/** - * @tc.name : ChangeGroupToEntry_00100 - * @tc.number : - * @tc.desc : Change slot group to entry. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, ChangeGroupToEntry_00100, Function | SmallTest | Level1) -{ - sptr slotGroup = new NotificationSlotGroup("id", "name"); - std::vector entries; - - EXPECT_TRUE(preferncesDB_->GroupToEntry(bundleName_, bundleUid_, slotGroup, entries)); -} - /** * @tc.name : CheckBundle_00100 * @tc.number : diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index ee84ca591a82c728b5d1a63b2124664cf37878af..0ffe922c44b75c6cca661735bded0862fb6d3d77 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -30,7 +30,6 @@ public: void TearDown(); void TestAddNotificationSlot(); - void TestAddNotificationSlotGroup(); static sptr bundleOption_; static sptr noExsitbundleOption_; @@ -57,14 +56,6 @@ void NotificationPreferencesTest::TestAddNotificationSlot() NotificationPreferences::GetInstance().AddNotificationSlots(bundleOption_, slots); } -void NotificationPreferencesTest::TestAddNotificationSlotGroup() -{ - sptr group = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(group); - NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups); -} - /** * @tc.number : AddNotificationSlots_00100 * @tc.name : @@ -136,85 +127,6 @@ HWTEST_F(NotificationPreferencesTest, AddNotificationSlots_00500, Function | Sma EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationSlots(bundleOption_, slots), (int)ERR_OK); } -/** - * @tc.number : AddNotificationSlotGroups_00100 - * @tc.name : - * @tc.desc : Add a notification groups into disturbe DB , return is ERR_OK - */ -HWTEST_F(NotificationPreferencesTest, AddNotificationSlotGroups_00100, Function | SmallTest | Level1) -{ - sptr group = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(group); - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups), (int)ERR_OK); -} - -/** - * @tc.number : AddNotificationSlotGroups_00200 - * @tc.name : - * @tc.desc : Add a notification groups into disturbe DB when bundle name is null, return is ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, AddNotificationSlotGroups_00200, Function | SmallTest | Level1) -{ - sptr group = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(group); - EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleEmptyOption_, groups), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : AddNotificationSlotGroups_00300 - * @tc.name : - * @tc.desc : Add a notification groups into disturbe DB when groups is null, return is ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, AddNotificationSlotGroups_00300, Function | SmallTest | Level1) -{ - std::vector> groups; - EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : AddNotificationSlotGroups_00400 - * @tc.name : - * @tc.desc : Add a notification groups into disturbe DB when group id is null, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID - */ -HWTEST_F(NotificationPreferencesTest, AddNotificationSlotGroups_00400, Function | SmallTest | Level1) -{ - sptr group = new NotificationSlotGroup("", "name"); - std::vector> groups; - groups.push_back(group); - EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID); -} - -/** - * @tc.number : AddNotificationSlotGroups_00500 - * @tc.name : - * @tc.desc : Add a notification groups into disturbe DB when add group exceed max num, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_EXCEED_MAX_NUM - */ -HWTEST_F(NotificationPreferencesTest, AddNotificationSlotGroups_00500, Function | SmallTest | Level1) -{ - sptr group1 = new NotificationSlotGroup("id1", "name1"); - sptr group2 = new NotificationSlotGroup("id2", "name1"); - sptr group3 = new NotificationSlotGroup("id3", "name1"); - sptr group4 = new NotificationSlotGroup("id4", "name1"); - sptr group5 = new NotificationSlotGroup("id5", "name1"); - std::vector> groups; - groups.push_back(group1); - groups.push_back(group2); - groups.push_back(group3); - groups.push_back(group4); - groups.push_back(group5); - - EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_EXCEED_MAX_NUM); -} - /** * @tc.number : RemoveNotificationSlot_00100 * @tc.name : @@ -268,79 +180,6 @@ HWTEST_F(NotificationPreferencesTest, RemoveNotificationSlot_00400, Function | S (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST); } -/** - * @tc.number : RemoveNotificationSlotGroups_00100 - * @tc.name : - * @tc.desc : Remove a notification group from disturbe DB , return is ERR_OK - */ -HWTEST_F(NotificationPreferencesTest, RemoveNotificationSlotGroups_00100, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - std::string groupId = "id"; - std::vector groupIds; - groupIds.push_back(groupId); - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().RemoveNotificationSlotGroups(bundleOption_, groupIds), (int)ERR_OK); -} - -/** - * @tc.number : RemoveNotificationSlotGroups_00200 - * @tc.name : - * @tc.desc : Remove a notification group from disturbe DB when bundleName is null, return is ERR_ANS_INVALID_PARAM - */ -HWTEST_F(NotificationPreferencesTest, RemoveNotificationSlotGroups_00200, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - std::string groupId("id"); - std::vector groupIds; - groupIds.push_back(groupId); - EXPECT_EQ((int)NotificationPreferences::GetInstance().RemoveNotificationSlotGroups(bundleEmptyOption_, groupIds), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : RemoveNotificationSlotGroups_00300 - * @tc.name : - * @tc.desc : Remove a notification group from disturbe DB when group id is null, return is ERR_ANS_INVALID_PARAM - */ -HWTEST_F(NotificationPreferencesTest, RemoveNotificationSlotGroups_00300, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - std::vector groupIds; - EXPECT_EQ((int)NotificationPreferences::GetInstance().RemoveNotificationSlotGroups(bundleOption_, groupIds), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : RemoveNotificationSlotGroups_00400 - * @tc.name : - * @tc.desc : Remove a notification group from disturbe DB when bundle name does not exsit, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST - */ -HWTEST_F(NotificationPreferencesTest, RemoveNotificationSlotGroups_00400, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - std::vector groupIds; - groupIds.push_back("id"); - EXPECT_EQ((int)NotificationPreferences::GetInstance().RemoveNotificationSlotGroups(noExsitbundleOption_, groupIds), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); -} - -/** - * @tc.number : RemoveNotificationSlotGroups_00500 - * @tc.name : - * @tc.desc : Remove a notification group from disturbe DB when group id does not exsit, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID - */ -HWTEST_F(NotificationPreferencesTest, RemoveNotificationSlotGroups_00500, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - std::string groupId = "id1"; - std::vector groupIds; - groupIds.push_back(groupId); - EXPECT_EQ((int)NotificationPreferences::GetInstance().RemoveNotificationSlotGroups(bundleOption_, groupIds), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_ID_INVALID); -} /** * @tc.number : RemoveNotificationForBundle_00100 * @tc.name : @@ -450,82 +289,6 @@ HWTEST_F(NotificationPreferencesTest, UpdateNotificationSlots_00500, Function | (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); } -/** - * @tc.number : UpdateNotificationSlotGroups_00100 - * @tc.name : - * @tc.desc : Update notification slot group into disturbe DB return is ERR_OK. - */ -HWTEST_F(NotificationPreferencesTest, UpdateNotificationSlotGroups_00100, Function | SmallTest | Level1) -{ - sptr group = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(group); - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups), (int)ERR_OK); - std::string des("This is a group description."); - group->SetDescription(des); - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().UpdateNotificationSlotGroups(bundleOption_, groups), (int)ERR_OK); -} - -/** - * @tc.number : UpdateNotificationSlotGroups_00200 - * @tc.name : - * @tc.desc : Update notification slot group into disturbe DB when bundle name is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, UpdateNotificationSlotGroups_00200, Function | SmallTest | Level1) -{ - sptr group = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(group); - EXPECT_EQ((int)NotificationPreferences::GetInstance().UpdateNotificationSlotGroups(bundleEmptyOption_, groups), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : UpdateNotificationSlotGroups_00300 - * @tc.name : - * @tc.desc : Update notification slot group into disturbe DB when groups is null, return is ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, UpdateNotificationSlotGroups_00300, Function | SmallTest | Level1) -{ - std::vector> groups; - EXPECT_EQ((int)NotificationPreferences::GetInstance().UpdateNotificationSlotGroups(bundleOption_, groups), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : UpdateNotificationSlotGroups_00400 - * @tc.name : - * @tc.desc : Update notification slot group into disturbe DB when bundle does not exsit, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. - */ -HWTEST_F(NotificationPreferencesTest, UpdateNotificationSlotGroups_00400, Function | SmallTest | Level1) -{ - sptr group = new NotificationSlotGroup("id", "name"); - std::vector> groups; - groups.push_back(group); - EXPECT_EQ((int)NotificationPreferences::GetInstance().UpdateNotificationSlotGroups(noExsitbundleOption_, groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); -} - -/** - * @tc.number : UpdateNotificationSlotGroups_00500 - * @tc.name : - * @tc.desc : Update notification slot group into disturbe DB when groupid is null, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST - */ -HWTEST_F(NotificationPreferencesTest, UpdateNotificationSlotGroups_00500, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - sptr spGroup = new NotificationSlotGroup("", "name"); - std::vector> groups; - groups.push_back(spGroup); - EXPECT_EQ((int)NotificationPreferences::GetInstance().UpdateNotificationSlotGroups(bundleOption_, groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOTGROUP_NOT_EXIST); -} - /** * @tc.number : GetNotificationSlot_00100 * @tc.name : @@ -648,120 +411,6 @@ HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlots_00400, Function | EXPECT_EQ((int)slotsResult.size(), 0); } -/** - * @tc.number : GetNotificationAllSlotGroups_00100 - * @tc.name : - * @tc.desc : Get all notification slots from disturbe DB, return is ERR_OK. - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotGroups_00100, Function | SmallTest | Level1) -{ - TestAddNotificationSlotGroup(); - std::vector> groups; - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().GetNotificationAllSlotGroups(bundleOption_, groups), (int)ERR_OK); - EXPECT_EQ((int)groups.size(), 1); -} - -/** - * @tc.number : GetNotificationAllSlotGroups_00200 - * @tc.name : - * @tc.desc : Get all notification slots from disturbe DB when bundle name is null, return is - * ERR_ANS_INVALID_PARAM - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotGroups_00200, Function | SmallTest | Level1) -{ - std::vector> groups; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationAllSlotGroups(bundleEmptyOption_, groups), - (int)ERR_ANS_INVALID_PARAM); - EXPECT_EQ((int)groups.size(), 0); -} - -/** - * @tc.number : GetNotificationAllSlotGroups_00300 - * @tc.name : - * @tc.desc : Get all notification slots from disturbe DB when bundle name does not exsit, return is - * ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotGroups_00300, Function | SmallTest | Level1) -{ - std::vector> groups; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationAllSlotGroups(noExsitbundleOption_, groups), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); - EXPECT_EQ((int)groups.size(), 0); -} - -/** - * @tc.number : GetNotificationAllSlotInSlotGroup_00100 - * @tc.name : - * @tc.desc : Get all notification slots in the same group from disturbe DB , return is ERR_OK. - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotInSlotGroup_00100, Function | SmallTest | Level1) -{ - std::string groupId = "groupId"; - sptr group = new NotificationSlotGroup("groupId", "name"); - std::vector> groups; - groups.push_back(group); - NotificationPreferences::GetInstance().AddNotificationSlotGroups(bundleOption_, groups); - - sptr slot = new NotificationSlot(NotificationConstant::SlotType::OTHER); - slot->SetSlotGroup(groupId); - std::vector> slots; - slots.push_back(slot); - NotificationPreferences::GetInstance().AddNotificationSlots(bundleOption_, slots); - std::vector> slotsReuslt; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationAllSlotInSlotGroup( - bundleOption_, groupId, slotsReuslt), - (int)ERR_OK); - EXPECT_EQ((int)slotsReuslt.size(), 1); -} - -/** - * @tc.number : GetNotificationAllSlotInSlotGroup_00200 - * @tc.name : - * @tc.desc : Get all notification slots in the same group from disturbe DB when bundle name is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotInSlotGroup_00200, Function | SmallTest | Level1) -{ - std::string groupId = "groupId"; - std::vector> slotsReuslt; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationAllSlotInSlotGroup( - bundleEmptyOption_, groupId, slotsReuslt), - (int)ERR_ANS_INVALID_PARAM); - EXPECT_EQ((int)slotsReuslt.size(), 0); -} - -/** - * @tc.number : GetNotificationAllSlotInSlotGroup_00300 - * @tc.name : - * @tc.desc : Get all notification slots in the same group from disturbe DB when group id is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotInSlotGroup_00300, Function | SmallTest | Level1) -{ - std::vector> slotsReuslt; - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().GetNotificationAllSlotInSlotGroup(bundleOption_, "", slotsReuslt), - (int)ERR_ANS_INVALID_PARAM); - EXPECT_EQ((int)slotsReuslt.size(), 0); -} - -/** - * @tc.number : GetNotificationAllSlotInSlotGroup_00400 - * @tc.name : - * @tc.desc : Get all notification slots in the same group from disturbe DB when bundle name does not exsit, return - * is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. - */ -HWTEST_F(NotificationPreferencesTest, GetNotificationAllSlotInSlotGroup_00400, Function | SmallTest | Level1) -{ - std::string groupId = "groupId"; - std::vector> slotsReuslt; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationAllSlotInSlotGroup( - noExsitbundleOption_, groupId, slotsReuslt), - (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); - EXPECT_EQ((int)slotsReuslt.size(), 0); -} - /** * @tc.number : SetShowBadge_00100 * @tc.name : diff --git a/services/distributed/include/distributed_database.h b/services/distributed/include/distributed_database.h index 4bde7adab9117676f51840a0ad0794f11e9cb310..dca37c7b152ef52522c85b8d2a23a139c27f86b0 100644 --- a/services/distributed/include/distributed_database.h +++ b/services/distributed/include/distributed_database.h @@ -123,6 +123,8 @@ public: */ bool RecreateDistributedDB(); + bool OnDeviceConnected(); + private: void GetKvDataManager(void); bool CheckKvDataManager(void); diff --git a/services/distributed/include/distributed_preferences_database.h b/services/distributed/include/distributed_preferences_database.h index 6248c6d0f84312226e83e9960f2e5b3540c5dd8f..1fc06ba15189fe78cd17709b5a40df5bf3bf9bde 100644 --- a/services/distributed/include/distributed_preferences_database.h +++ b/services/distributed/include/distributed_preferences_database.h @@ -83,6 +83,7 @@ private: bool CheckKvDataManager(void); void GetKvStore(void); bool CheckKvStore(void); + void CloseKvStore(); private: std::mutex mutex_; diff --git a/services/distributed/src/distributed_database.cpp b/services/distributed/src/distributed_database.cpp index 8dccefc9b6fa53d5b99ce9c42f327eb4667e12f5..8beb201103a6cf102f3ea22e3b9c48feb315e511 100644 --- a/services/distributed/src/distributed_database.cpp +++ b/services/distributed/src/distributed_database.cpp @@ -20,8 +20,9 @@ namespace OHOS { namespace Notification { namespace { -const std::string APP_ID = "advanced_notification_service"; +const std::string APP_ID = "notification_service"; const std::string STORE_ID = "distributed_notification"; +constexpr char KV_STORE_PATH[] = "/data/service/el1/public/database/notification_service"; } // namespace DistributedDatabase::DistributedDatabase( @@ -29,7 +30,6 @@ DistributedDatabase::DistributedDatabase( : DistributedFlowControl(), databaseCb_(databaseCb), deviceCb_(deviceCb) { GetKvDataManager(); - GetKvStore(); } DistributedDatabase::~DistributedDatabase() @@ -66,12 +66,15 @@ void DistributedDatabase::GetKvStore(void) if (!CheckKvDataManager()) { return; } - - DistributedKv::Options options; - options.createIfMissing = true; - options.securityLevel = DistributedKv::SecurityLevel::S1; - options.autoSync = true; - options.kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION; + DistributedKv::Options options { + .createIfMissing = true, + .securityLevel = DistributedKv::SecurityLevel::S1, + .autoSync = true, + .encrypt = false, + .area = DistributedKv::EL1, + .kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION, + .baseDir = KV_STORE_PATH + }; DistributedKv::AppId appId = {.appId = APP_ID}; DistributedKv::StoreId storeId = {.storeId = STORE_ID}; DistributedKv::Status status = kvDataManager_->GetSingleKvStore(options, appId, storeId, kvStore_); @@ -96,6 +99,7 @@ void DistributedDatabase::GetKvStore(void) bool DistributedDatabase::CheckKvStore(void) { + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { GetKvStore(); } @@ -106,11 +110,17 @@ bool DistributedDatabase::CheckKvStore(void) return true; } +bool DistributedDatabase::OnDeviceConnected() +{ + return CheckKvStore(); +} + bool DistributedDatabase::PutToDistributedDB(const std::string &key, const std::string &value) { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { + if (kvStore_ == nullptr) { + ANS_LOGE("kvStore is nullptr."); return false; } @@ -134,7 +144,8 @@ bool DistributedDatabase::GetFromDistributedDB(const std::string &key, std::stri { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { + if (kvStore_ == nullptr) { + ANS_LOGE("kvStore is nullptr."); return false; } @@ -160,7 +171,8 @@ bool DistributedDatabase::GetEntriesFromDistributedDB(const std::string &prefixK { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { + if (kvStore_ == nullptr) { + ANS_LOGE("kvStore is nullptr."); return false; } @@ -183,7 +195,8 @@ bool DistributedDatabase::DeleteToDistributedDB(const std::string &key) { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { + if (kvStore_ == nullptr) { + ANS_LOGE("kvStore is nullptr."); return false; } @@ -206,7 +219,8 @@ bool DistributedDatabase::ClearDataByDevice(const std::string &deviceId) { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { + if (kvStore_ == nullptr) { + ANS_LOGE("kvStore is nullptr."); return false; } @@ -305,18 +319,15 @@ bool DistributedDatabase::RecreateDistributedDB() ANS_LOGE("KvManager flow control."); return false; } - kvStore_.reset(); - DistributedKv::AppId appId = {.appId = APP_ID}; DistributedKv::StoreId storeId = {.storeId = STORE_ID}; - DistributedKv::Status status = kvDataManager_->DeleteKvStore(appId, storeId); + DistributedKv::Status status = kvDataManager_->DeleteKvStore(appId, storeId, KV_STORE_PATH); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvDataManager DeleteKvStore() failed ret = 0x%{public}x", status); return false; } - GetKvStore(); return true; } } // namespace Notification diff --git a/services/distributed/src/distributed_notification_manager.cpp b/services/distributed/src/distributed_notification_manager.cpp index 5aa3e53adf48c497c4a0e871eb320a53ee8c1b27..460405aab844b1f73adb020fd81cb0ac3187a42c 100644 --- a/services/distributed/src/distributed_notification_manager.cpp +++ b/services/distributed/src/distributed_notification_manager.cpp @@ -202,8 +202,15 @@ void DistributedNotificationManager::OnDatabaseDelete( void DistributedNotificationManager::OnDeviceConnected(const std::string &deviceId) { ANS_LOGD("%{public}s", __FUNCTION__); - handler_->PostTask(std::bind([=]() {})); - return; + handler_->PostTask(std::bind([=]() { + if (database_ == nullptr) { + ANS_LOGE("OnDeviceConnected failed: database is null"); + return; + } + if (!database_->OnDeviceConnected()) { + ANS_LOGE("OnDeviceConnected failed."); + } + })); } void DistributedNotificationManager::OnDeviceDisconnected(const std::string &deviceId) diff --git a/services/distributed/src/distributed_preferences_database.cpp b/services/distributed/src/distributed_preferences_database.cpp index 535bcda40e9d7cb726310ff5383d2a3175bccfd8..4ee3a39c5b42b817991b0f35fd76c2c30dbb7c4a 100644 --- a/services/distributed/src/distributed_preferences_database.cpp +++ b/services/distributed/src/distributed_preferences_database.cpp @@ -20,14 +20,14 @@ namespace OHOS { namespace Notification { namespace { -const std::string APP_ID = "advanced_notification_service"; +const std::string APP_ID = "notification_service"; const std::string STORE_ID = "distributed_preferences"; +constexpr char KV_STORE_PATH[] = "/data/service/el1/public/database/notification_service"; } // namespace DistributedPreferencesDatabase::DistributedPreferencesDatabase() : DistributedFlowControl() { GetKvDataManager(); - GetKvStore(); } DistributedPreferencesDatabase::~DistributedPreferencesDatabase() @@ -57,15 +57,16 @@ void DistributedPreferencesDatabase::GetKvStore(void) return; } - DistributedKv::Status status; - DistributedKv::Options options; - options.createIfMissing = true; - options.autoSync = false; - options.kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION; - + DistributedKv::Options options = { + .createIfMissing = true, + .autoSync = false, + .area = DistributedKv::EL1, + .kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION, + .baseDir = KV_STORE_PATH + }; DistributedKv::AppId appId = {.appId = APP_ID}; DistributedKv::StoreId storeId = {.storeId = STORE_ID}; - status = kvDataManager_->GetSingleKvStore(options, appId, storeId, kvStore_); + DistributedKv::Status status = kvDataManager_->GetSingleKvStore(options, appId, storeId, kvStore_); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvDataManager GetSingleKvStore failed ret = 0x%{public}x", status); kvStore_.reset(); @@ -96,12 +97,14 @@ bool DistributedPreferencesDatabase::PutToDistributedDB(const std::string &key, if (!KvStoreFlowControl()) { ANS_LOGE("kvStore flow control."); + CloseKvStore(); return false; } DistributedKv::Key kvStoreKey(key); DistributedKv::Value kvStoreValue(value); DistributedKv::Status status = kvStore_->Put(kvStoreKey, kvStoreValue); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvStore Put() failed ret = 0x%{public}x", status); return false; @@ -113,26 +116,24 @@ bool DistributedPreferencesDatabase::PutToDistributedDB(const std::string &key, bool DistributedPreferencesDatabase::GetFromDistributedDB(const std::string &key, std::string &value) { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { return false; } if (!KvStoreFlowControl()) { ANS_LOGE("kvStore flow control."); + CloseKvStore(); return false; } - DistributedKv::Key kvStoreKey(key); DistributedKv::Value kvStoreValue; DistributedKv::Status status = kvStore_->Get(kvStoreKey, kvStoreValue); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvStore Get() failed ret = 0x%{public}x", status); return false; } - value = kvStoreValue.ToString(); - return true; } @@ -140,23 +141,21 @@ bool DistributedPreferencesDatabase::GetEntriesFromDistributedDB( const std::string &prefixKey, std::vector &entries) { std::lock_guard lock(mutex_); - if (!CheckKvStore()) { return false; } - if (!KvStoreFlowControl()) { ANS_LOGE("kvStore flow control."); + CloseKvStore(); return false; } - DistributedKv::Key kvStoreKey(prefixKey); DistributedKv::Status status = kvStore_->GetEntries(kvStoreKey, entries); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvStore GetEntries() failed ret = 0x%{public}x", status); return false; } - return true; } @@ -167,15 +166,15 @@ bool DistributedPreferencesDatabase::DeleteToDistributedDB(const std::string &ke if (!CheckKvStore()) { return false; } - if (!KvStoreFlowControl()) { ANS_LOGE("kvStore flow control."); + CloseKvStore(); return false; } - DistributedKv::Key kvStoreKey(key); DistributedKv::Value kvStoreValue; DistributedKv::Status status = kvStore_->Delete(kvStoreKey); + CloseKvStore(); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvStore Delete() failed ret = 0x%{public}x", status); return false; @@ -204,12 +203,18 @@ bool DistributedPreferencesDatabase::ClearDatabase(void) return false; } - status = kvDataManager_->DeleteKvStore(appId, storeId); + status = kvDataManager_->DeleteKvStore(appId, storeId, KV_STORE_PATH); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvDataManager DeleteKvStore() failed ret = 0x%{public}x", status); return false; } return true; } + +void DistributedPreferencesDatabase::CloseKvStore() +{ + DistributedKv::AppId appId = {.appId = APP_ID}; + kvDataManager_->CloseKvStore(appId, kvStore_); +} } // namespace Notification } // namespace OHOS \ No newline at end of file diff --git a/services/distributed/src/distributed_screen_status_manager.cpp b/services/distributed/src/distributed_screen_status_manager.cpp index dfd721e4175856fb6a0f3ad2ba504f95a67d3e98..d8b0bd5bc3781aae55760dddf3d7cf8b27bfe8c3 100644 --- a/services/distributed/src/distributed_screen_status_manager.cpp +++ b/services/distributed/src/distributed_screen_status_manager.cpp @@ -21,12 +21,13 @@ namespace OHOS { namespace Notification { namespace { -const std::string APP_ID = "advanced_notification_service"; +const std::string APP_ID = "notification_service"; const std::string STORE_ID = "distributed_screen_status"; const std::string DELIMITER = "|"; const std::string SCREEN_STATUS_LABEL = "screen_status"; const std::string SCREEN_STATUS_VALUE_ON = "on"; const std::string SCREEN_STATUS_VALUE_OFF = "off"; +constexpr char KV_STORE_PATH[] = "/data/service/el1/public/database/notification_service"; } // namespace DistributedScreenStatusManager::DistributedScreenStatusManager() : DistributedFlowControl() @@ -37,7 +38,6 @@ DistributedScreenStatusManager::DistributedScreenStatusManager() : DistributedFl }; deviceCb_ = std::make_shared(callback); GetKvDataManager(); - GetKvStore(); } DistributedScreenStatusManager::~DistributedScreenStatusManager() @@ -46,6 +46,8 @@ DistributedScreenStatusManager::~DistributedScreenStatusManager() void DistributedScreenStatusManager::OnDeviceConnected(const std::string &deviceId) { ANS_LOGI("deviceId:%{public}s", deviceId.c_str()); + std::lock_guard lock(mutex_); + CheckKvStore(); } void DistributedScreenStatusManager::OnDeviceDisconnected(const std::string &deviceId) @@ -72,7 +74,7 @@ void DistributedScreenStatusManager::OnDeviceDisconnected(const std::string &dev DistributedKv::AppId appId = {.appId = APP_ID}; DistributedKv::StoreId storeId = {.storeId = STORE_ID}; - kvDataManager_->DeleteKvStore(appId, storeId); + kvDataManager_->DeleteKvStore(appId, storeId, KV_STORE_PATH); if (!CheckKvStore()) { return; @@ -112,16 +114,16 @@ void DistributedScreenStatusManager::GetKvStore(void) if (!CheckKvDataManager()) { return; } - - DistributedKv::Status status; - DistributedKv::Options options; - options.createIfMissing = true; - options.autoSync = true; - options.kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION; - + DistributedKv::Options options = { + .createIfMissing = true, + .autoSync = true, + .area = DistributedKv::EL1, + .kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION, + .baseDir = KV_STORE_PATH + }; DistributedKv::AppId appId = {.appId = APP_ID}; DistributedKv::StoreId storeId = {.storeId = STORE_ID}; - status = kvDataManager_->GetSingleKvStore(options, appId, storeId, kvStore_); + DistributedKv::Status status = kvDataManager_->GetSingleKvStore(options, appId, storeId, kvStore_); if (status != DistributedKv::Status::SUCCESS) { ANS_LOGE("kvDataManager GetSingleKvStore failed ret = 0x%{public}x", status); kvStore_.reset(); @@ -153,7 +155,7 @@ std::string DistributedScreenStatusManager::GenerateDistributedKey(const std::st ErrCode DistributedScreenStatusManager::CheckRemoteDevicesIsUsing(bool &isUsing) { std::lock_guard lock(mutex_); - if (!CheckKvDataManager() || !CheckKvStore()) { + if (!CheckKvDataManager() || kvStore_ == nullptr) { return ERR_ANS_DISTRIBUTED_OPERATION_FAILED; } @@ -204,7 +206,7 @@ ErrCode DistributedScreenStatusManager::SetLocalScreenStatus(bool screenOn) std::lock_guard lock(mutex_); ANS_LOGI("%{public}s, screenOn:%{public}s", __FUNCTION__, screenOn ? "true" : "false"); localScreenOn_ = screenOn; - if (!CheckKvStore()) { + if (kvStore_ == nullptr) { return ERR_ANS_DISTRIBUTED_OPERATION_FAILED; } diff --git a/services/distributed/test/unittest/distributed_database_test.cpp b/services/distributed/test/unittest/distributed_database_test.cpp index 329297a7335c448291022c70584a8394ee20b4c3..c6c6dcfcb1798358fc57012dbf584e5f7b3e88ee 100644 --- a/services/distributed/test/unittest/distributed_database_test.cpp +++ b/services/distributed/test/unittest/distributed_database_test.cpp @@ -17,6 +17,7 @@ #include "gtest/gtest.h" +#define private public #include "distributed_database.h" using namespace testing::ext; @@ -67,6 +68,7 @@ void DistributedDatabaseTest::SetUp() databaseCallback_ = std::make_shared(databaseCallback); deviceCallback_ = std::make_shared(deviceCallback); database_ = std::make_shared(databaseCallback_, deviceCallback_); + database_->OnDeviceConnected(); } void DistributedDatabaseTest::TearDown() diff --git a/services/distributed/test/unittest/distributed_notification_manager_test.cpp b/services/distributed/test/unittest/distributed_notification_manager_test.cpp index e4ab49cf0028b9dae973cc471fe5faf479f53c01..70d832fb11133c094d4b57447c3e3e388005913f 100644 --- a/services/distributed/test/unittest/distributed_notification_manager_test.cpp +++ b/services/distributed/test/unittest/distributed_notification_manager_test.cpp @@ -16,7 +16,7 @@ #include #include "gtest/gtest.h" - +#define private public #include "distributed_notification_manager.h" using namespace testing::ext; @@ -42,6 +42,7 @@ protected: void DistributedNotificationManagerTest::SetUp() { distributedManager_ = DistributedNotificationManager::GetInstance(); + distributedManager_->OnDeviceConnected("test"); } void DistributedNotificationManagerTest::TearDown() diff --git a/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp b/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp index e1b68b00bb66e8ded3395bc05e11a00e6b27c666..5c4b85d6353e1c2c58dd69b6ce62885080525c66 100644 --- a/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp +++ b/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp @@ -16,7 +16,7 @@ #include #include "gtest/gtest.h" - +#define private public #include "distributed_screen_status_manager.h" using namespace testing::ext; @@ -27,17 +27,18 @@ public: void SetUp() override; void TearDown() override; protected: - std::shared_ptr DistributedScreenStatusManager_; + std::shared_ptr distributedScreenStatusManager_; }; void DistributedScreenStatusManagerTest::SetUp() { - DistributedScreenStatusManager_ = DistributedScreenStatusManager::GetInstance(); + distributedScreenStatusManager_ = DistributedScreenStatusManager::GetInstance(); + distributedScreenStatusManager_->OnDeviceConnected("test"); } void DistributedScreenStatusManagerTest::TearDown() { - DistributedScreenStatusManager_ = nullptr; + distributedScreenStatusManager_ = nullptr; DistributedScreenStatusManager::DestroyInstance(); } @@ -50,7 +51,7 @@ HWTEST_F(DistributedScreenStatusManagerTest, CheckRemoteDevicesIsUsing_00100, Fu { bool isUsing = true; - EXPECT_EQ(DistributedScreenStatusManager_->CheckRemoteDevicesIsUsing(isUsing), ERR_OK); + EXPECT_EQ(distributedScreenStatusManager_->CheckRemoteDevicesIsUsing(isUsing), ERR_OK); } /** @@ -62,7 +63,7 @@ HWTEST_F(DistributedScreenStatusManagerTest, SetLocalScreenStatus_00100, Functio { bool screenOn = false; - EXPECT_EQ(DistributedScreenStatusManager_->SetLocalScreenStatus(screenOn), ERR_OK); + EXPECT_EQ(distributedScreenStatusManager_->SetLocalScreenStatus(screenOn), ERR_OK); } } // namespace Notification } // namespace OHOS \ No newline at end of file diff --git a/services/test/moduletest/ans_module_test.cpp b/services/test/moduletest/ans_module_test.cpp index 6822d4e820981510321e06c92989a463b7f08362..fef7b49d4982373e1f57047f7c82aa63b8dabc7b 100644 --- a/services/test/moduletest/ans_module_test.cpp +++ b/services/test/moduletest/ans_module_test.cpp @@ -1151,20 +1151,10 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0054, Function | SmallTest | Level1) { // add slot std::vector> slots; - sptr group = new NotificationSlotGroup("id", "name"); sptr socialSlot = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); sptr reminderSlot = new NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER); sptr contentSlot = new NotificationSlot(NotificationConstant::SlotType::CONTENT_INFORMATION); sptr otherSlot = new NotificationSlot(NotificationConstant::SlotType::OTHER); - socialSlot->SetSlotGroup(group->GetId()); - reminderSlot->SetSlotGroup(group->GetId()); - contentSlot->SetSlotGroup(group->GetId()); - otherSlot->SetSlotGroup(group->GetId()); - - // add slot group - std::vector> slotGroups; - slotGroups.push_back(group); - g_advancedNotificationService->AddSlotGroups(slotGroups); slots.push_back(socialSlot); slots.push_back(reminderSlot); @@ -1183,9 +1173,7 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0055, Function | SmallTest | Level1) { // add slot std::vector> slots; - sptr group = new NotificationSlotGroup("id", "name"); sptr socialSlot = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); - socialSlot->SetSlotGroup(group->GetId()); slots.push_back(socialSlot); EXPECT_EQ(g_advancedNotificationService->AddSlots(slots), 0); @@ -1201,17 +1189,9 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0056, Function | SmallTest | Level1) { // add slot std::vector> slots; - sptr group = new NotificationSlotGroup("id", "name"); sptr socialSlot = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); - socialSlot->SetSlotGroup(group->GetId()); slots.push_back(socialSlot); EXPECT_EQ(g_advancedNotificationService->AddSlots(slots), 0); - - // get slot group by groupId - group = nullptr; - g_advancedNotificationService->GetSlotGroup("id", group); - EXPECT_FALSE(group != nullptr); - // remove slot group EXPECT_EQ(g_advancedNotificationService->RemoveSlotByType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION), 0); } @@ -2439,20 +2419,13 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0127, Function | SmallTest | Level1) sortingMap) { ret++; }; // add slot - sptr group = new NotificationSlotGroup("id", "name"); std::vector> slots; sptr slot = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); sptr slot1 = new NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER); slots.push_back(slot); slots.push_back(slot1); - slot->SetSlotGroup(group->GetId()); g_advancedNotificationService->AddSlots(slots); - // add slot group - std::vector> slotGroups; - slotGroups.push_back(group); - g_advancedNotificationService->AddSlotGroups(slotGroups); - // create content std::shared_ptr contentImpl = std::make_shared(); contentImpl->SetText("1"); @@ -2500,20 +2473,13 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0128, Function | SmallTest | Level1) sortingMap) { ret++; }; // add slot - sptr group = new NotificationSlotGroup("id", "name"); std::vector> slots; sptr slot = new NotificationSlot(NotificationConstant::SlotType::CONTENT_INFORMATION); sptr slot1 = new NotificationSlot(NotificationConstant::SlotType::OTHER); slots.push_back(slot); slots.push_back(slot1); - slot->SetSlotGroup(group->GetId()); g_advancedNotificationService->AddSlots(slots); - // add slot group - std::vector> slotGroups; - slotGroups.push_back(group); - g_advancedNotificationService->AddSlotGroups(slotGroups); - // create content std::shared_ptr contentImpl = std::make_shared(); contentImpl->SetText("1"); diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 4968862a29fb87c41ea3b061bb76b9637222cd90..0f3c6001e324bcee632c4f202044640441d77bef 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -127,52 +127,6 @@ BENCHMARK_F(BenchmarkNotificationService, RemoveSlotByTypeTestCase)(benchmark::S } } -/** - * @tc.name: AddSlotGroupTestCase - * @tc.desc: AddSlotGroup - * @tc.type: FUNC - * @tc.require: - */ -BENCHMARK_F(BenchmarkNotificationService, AddSlotGroupTestCase)(benchmark::State &state) -{ - std::vector> groups; - sptr group = new NotificationSlotGroup("id0", "name0"); - groups.push_back(group); - while (state.KeepRunning()) { - ErrCode errCode = advancedNotificationService_->AddSlotGroups(groups); - if (errCode != ERR_OK) { - state.SkipWithError("AddSlotGroupTestCase failed."); - } - } -} - -/** - * @tc.name: RemoveSlotGroupsTestCase - * @tc.desc: RemoveSlotGroups - * @tc.type: FUNC - * @tc.require: - */ -BENCHMARK_F(BenchmarkNotificationService, RemoveSlotGroupsTestCase)(benchmark::State &state) -{ - std::vector> groups; - sptr group = new NotificationSlotGroup("id0", "name0"); - groups.push_back(group); - std::vector groupIds; - groupIds.push_back("id0"); - - while (state.KeepRunning()) { - ErrCode errCode = advancedNotificationService_->AddSlotGroups(groups); - if (errCode != ERR_OK) { - state.SkipWithError("RemoveSlotGroupsTestCase add failed."); - } - - errCode = advancedNotificationService_->RemoveSlotGroups(groupIds); - if (errCode != ERR_OK) { - state.SkipWithError("RemoveSlotGroupsTestCase remove failed."); - } - } -} - /** * @tc.name: SubscribeTestCase * @tc.desc: Subscribe diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 558518d3a2b1d8017fc527ca7d622b3356d25cee..be7f24d4af399fec940d0d4bd7c6721ec1bf1b42 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -15,17 +15,14 @@ group("fuzztest") { testonly = true deps = [ - "addnotificationslotgroups_fuzzer:AddNotificationSlotGroupsFuzzTest", "addnotificationslots_fuzzer:AddNotificationSlotsFuzzTest", "addslotbytype_fuzzer:AddSlotByTypeFuzzTest", "cancelnotification_fuzzer:CancelNotificationFuzzTest", "getnotificationslot_fuzzer:GetNotificationSlotFuzzTest", - "getnotificationslotgroup_fuzzer:GetNotificationSlotGroupFuzzTest", "getnotificationslotnumasbundle_fuzzer:GetNotificationSlotNumAsBundleFuzzTest", "publishnotification_fuzzer:PublishNotificationFuzzTest", "removenotification_fuzzer:RemoveNotificationFuzzTest", "removenotificationslot_fuzzer:RemoveNotificationSlotFuzzTest", - "removenotificationslotgroup_fuzzer:RemoveNotificationSlotGroupFuzzTest", "setnotificationbadgenum_fuzzer:SetNotificationBadgeNumFuzzTest", ] } diff --git a/test/fuzztest/addnotificationslotgroups_fuzzer/BUILD.gn b/test/fuzztest/addnotificationslotgroups_fuzzer/BUILD.gn deleted file mode 100644 index c03d4364f2cb5009e160516d647c1aaf27afd264..0000000000000000000000000000000000000000 --- a/test/fuzztest/addnotificationslotgroups_fuzzer/BUILD.gn +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("AddNotificationSlotGroupsFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "${component_path}/test/fuzztest/addnotificationslotgroups_fuzzer" - - include_dirs = [] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "addnotificationslotgroups_fuzzer.cpp" ] - - deps = [ "${frameworks_module_ans_path}:ans_innerkits" ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_standard:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AddNotificationSlotGroupsFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/addnotificationslotgroups_fuzzer/addnotificationslotgroups_fuzzer.cpp b/test/fuzztest/addnotificationslotgroups_fuzzer/addnotificationslotgroups_fuzzer.cpp deleted file mode 100644 index 49af1e97c6399ccd8f4d706b44647469bb63ae77..0000000000000000000000000000000000000000 --- a/test/fuzztest/addnotificationslotgroups_fuzzer/addnotificationslotgroups_fuzzer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "addnotificationslotgroups_fuzzer.h" - -#define private public -#include "notification_helper.h" -#undef private - -namespace OHOS { - bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) - { - std::string description = reinterpret_cast(data); - Notification::NotificationSlotGroup group; - group.SetDescription(description); - - Notification::NotificationSlot slot; - std::vector slots; - slots.emplace_back(slot); - group.SetSlots(slots); - - std::vector groups; - groups.emplace_back(group); - return Notification::NotificationHelper::AddNotificationSlotGroups(groups) == ERR_OK; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DoSomethingInterestingWithMyAPI(data, size); - return 0; -} diff --git a/test/fuzztest/addnotificationslotgroups_fuzzer/addnotificationslotgroups_fuzzer.h b/test/fuzztest/addnotificationslotgroups_fuzzer/addnotificationslotgroups_fuzzer.h deleted file mode 100644 index ff2c49f89ab1080e9b15a705079d77b1f3d32cf3..0000000000000000000000000000000000000000 --- a/test/fuzztest/addnotificationslotgroups_fuzzer/addnotificationslotgroups_fuzzer.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_ADDNOTIFICATIONSLOTGROUPS_FUZZER_ADDNOTIFICATIONSLOTGROUPS_FUZZER_H -#define TEST_FUZZTEST_ADDNOTIFICATIONSLOTGROUPS_FUZZER_ADDNOTIFICATIONSLOTGROUPS_FUZZER_H - -#define FUZZ_PROJECT_NAME "addnotificationslotgroups_fuzzer" - -#include - -uint32_t U32_AT(const uint8_t *ptr) -{ - // convert fuzz input data to an integer - return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3]; -} - -#endif // TEST_FUZZTEST_ADDNOTIFICATIONSLOTGROUPS_FUZZER_ADDNOTIFICATIONSLOTGROUPS_FUZZER_H diff --git a/test/fuzztest/addnotificationslotgroups_fuzzer/corpus/init b/test/fuzztest/addnotificationslotgroups_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/addnotificationslotgroups_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/addnotificationslotgroups_fuzzer/project.xml b/test/fuzztest/addnotificationslotgroups_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/addnotificationslotgroups_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/addnotificationslots_fuzzer/addnotificationslots_fuzzer.cpp b/test/fuzztest/addnotificationslots_fuzzer/addnotificationslots_fuzzer.cpp index 30aa44aad3dcd3e8c08301bd052c4b10c1ad3d86..652be8a9ce2af2f77a1990fd3d56f24df8eb5213 100644 --- a/test/fuzztest/addnotificationslots_fuzzer/addnotificationslots_fuzzer.cpp +++ b/test/fuzztest/addnotificationslots_fuzzer/addnotificationslots_fuzzer.cpp @@ -43,8 +43,6 @@ namespace OHOS { Notification::NotificationConstant::VisiblenessType(visibleness); slot.SetLockscreenVisibleness(visiblenessType); - slot.SetSlotGroup(stringData); - uint8_t type = *data % SLOT_TYPE_NUM; Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType(type); slot.SetType(slotType); diff --git a/test/fuzztest/getnotificationslotgroup_fuzzer/BUILD.gn b/test/fuzztest/getnotificationslotgroup_fuzzer/BUILD.gn deleted file mode 100644 index caa0f2b1f8fc57cbe2558efe322f41fee059cd92..0000000000000000000000000000000000000000 --- a/test/fuzztest/getnotificationslotgroup_fuzzer/BUILD.gn +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("GetNotificationSlotGroupFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "${component_path}/test/fuzztest/getnotificationslotgroup_fuzzer" - - include_dirs = [] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "getnotificationslotgroup_fuzzer.cpp" ] - - deps = [ "${frameworks_module_ans_path}:ans_innerkits" ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_standard:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetNotificationSlotGroupFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/getnotificationslotgroup_fuzzer/corpus/init b/test/fuzztest/getnotificationslotgroup_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/getnotificationslotgroup_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/getnotificationslotgroup_fuzzer/getnotificationslotgroup_fuzzer.cpp b/test/fuzztest/getnotificationslotgroup_fuzzer/getnotificationslotgroup_fuzzer.cpp deleted file mode 100644 index 8529f71dd225cabfa0f365789e881c08ba8c8f2c..0000000000000000000000000000000000000000 --- a/test/fuzztest/getnotificationslotgroup_fuzzer/getnotificationslotgroup_fuzzer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "getnotificationslotgroup_fuzzer.h" - -#include "notification_helper.h" - -namespace OHOS { - bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) - { - std::string groupId = reinterpret_cast(data); - sptr group = nullptr; - return Notification::NotificationHelper::GetNotificationSlotGroup(groupId, group) == ERR_OK; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DoSomethingInterestingWithMyAPI(data, size); - return 0; -} diff --git a/test/fuzztest/getnotificationslotgroup_fuzzer/getnotificationslotgroup_fuzzer.h b/test/fuzztest/getnotificationslotgroup_fuzzer/getnotificationslotgroup_fuzzer.h deleted file mode 100644 index 529d8be3c3f3804c3fab595ff21632801cf3d93f..0000000000000000000000000000000000000000 --- a/test/fuzztest/getnotificationslotgroup_fuzzer/getnotificationslotgroup_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_GETNOTIFICATIONSLOTGROUP_FUZZER_GETNOTIFICATIONSLOTGROUP_FUZZER_H -#define TEST_FUZZTEST_GETNOTIFICATIONSLOTGROUP_FUZZER_GETNOTIFICATIONSLOTGROUP_FUZZER_H - -#define FUZZ_PROJECT_NAME "getnotificationslotgroups_fuzzer" - -#endif // TEST_FUZZTEST_GETNOTIFICATIONSLOTGROUP_FUZZER_GETNOTIFICATIONSLOTGROUP_FUZZER_H diff --git a/test/fuzztest/getnotificationslotgroup_fuzzer/project.xml b/test/fuzztest/getnotificationslotgroup_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/getnotificationslotgroup_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/removenotificationslotgroup_fuzzer/BUILD.gn b/test/fuzztest/removenotificationslotgroup_fuzzer/BUILD.gn deleted file mode 100644 index d4b2558ff25b713fcd443d0b7bf865b4052c5991..0000000000000000000000000000000000000000 --- a/test/fuzztest/removenotificationslotgroup_fuzzer/BUILD.gn +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("RemoveNotificationSlotGroupFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "${component_path}/test/fuzztest/removenotificationslotgroup_fuzzer" - - include_dirs = [] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "removenotificationslotgroup_fuzzer.cpp" ] - - deps = [ "${frameworks_module_ans_path}:ans_innerkits" ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_standard:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":RemoveNotificationSlotGroupFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/removenotificationslotgroup_fuzzer/corpus/init b/test/fuzztest/removenotificationslotgroup_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/removenotificationslotgroup_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/removenotificationslotgroup_fuzzer/project.xml b/test/fuzztest/removenotificationslotgroup_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/removenotificationslotgroup_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/removenotificationslotgroup_fuzzer/removenotificationslotgroup_fuzzer.cpp b/test/fuzztest/removenotificationslotgroup_fuzzer/removenotificationslotgroup_fuzzer.cpp deleted file mode 100644 index 50b4ede4bea9d7b84f9f62028a9f79e5b63763fe..0000000000000000000000000000000000000000 --- a/test/fuzztest/removenotificationslotgroup_fuzzer/removenotificationslotgroup_fuzzer.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "removenotificationslotgroup_fuzzer.h" - -#include "notification_helper.h" - -namespace OHOS { - bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) - { - std::string slotGroupId = reinterpret_cast(data); - return Notification::NotificationHelper::RemoveNotificationSlotGroup(slotGroupId) == ERR_OK; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DoSomethingInterestingWithMyAPI(data, size); - return 0; -} diff --git a/test/fuzztest/removenotificationslotgroup_fuzzer/removenotificationslotgroup_fuzzer.h b/test/fuzztest/removenotificationslotgroup_fuzzer/removenotificationslotgroup_fuzzer.h deleted file mode 100644 index 2b1fd85bc9b702c58edc1af3575c6aae67d10389..0000000000000000000000000000000000000000 --- a/test/fuzztest/removenotificationslotgroup_fuzzer/removenotificationslotgroup_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_REMOVENOTIFICATIONSLOTGROUP_FUZZER_REMOVENOTIFICATIONSLOTGROUP_FUZZER_H -#define TEST_FUZZTEST_REMOVENOTIFICATIONSLOTGROUP_FUZZER_REMOVENOTIFICATIONSLOTGROUP_FUZZER_H - -#define FUZZ_PROJECT_NAME "removenotificationslotgroup_fuzzer" - -#endif // TEST_FUZZTEST_REMOVENOTIFICATIONSLOTGROUP_FUZZER_REMOVENOTIFICATIONSLOTGROUP_FUZZER_H diff --git a/test/resource/ansSTSlotGroupTest/BUILD.gn b/test/resource/ansSTSlotGroupTest/BUILD.gn deleted file mode 100644 index d0b5b333f79df36d6c82c98542ec2db0b48abb71..0000000000000000000000000000000000000000 --- a/test/resource/ansSTSlotGroupTest/BUILD.gn +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/ohos.gni") -import("//build/test.gni") - -SUBDEMOSYSTEM_DIR = "${component_path}/test/resource/ansSTSlotGroupTest" - -group("ansSTSlotGroupTest") { - deps = [ ":libraryAnsSTSlotGroupTest" ] -} - -config("ansSTSlotGroupTestConfig") { - visibility = [ ":*" ] - - include_dirs = [ - "${SUBDEMOSYSTEM_DIR}/include", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "${ability_runtime_services_path}/abilitymgr/include", - "${inner_api_path}", - ] -} - -ohos_shared_library("libraryAnsSTSlotGroupTest") { - sources = [ "${SUBDEMOSYSTEM_DIR}/src/ans_slotgroup_test.cpp" ] - - configs = [ ":ansSTSlotGroupTestConfig" ] - - deps = [ - "${ability_runtime_path}/frameworks/native/appkit:appkit_native", - "${core_path}:ans_core", - "${frameworks_module_ans_path}:ans_innerkits", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:abilitykit_native", - "ability_runtime:wantagent_innerkits", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "c_utils:utilsbase", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - subsystem_name = "${subsystem_name}" - part_name = "${subsystem_name}" -} diff --git a/test/resource/ansSTSlotGroupTest/config.json b/test/resource/ansSTSlotGroupTest/config.json deleted file mode 100644 index 9228a94af690e366f17630db89cd5a0cd7eb190d..0000000000000000000000000000000000000000 --- a/test/resource/ansSTSlotGroupTest/config.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "app":{ - "bundleName": "com.ohos.ansst.ansSTSlotGroup", - "vendor": "ix", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 3, - "target": 3 - } - }, - "deviceConfig": { - "default": { - } - }, - "module": { - "package":"com.hos.AnsSlotGroupSystemTest.src", - "name":"AnsSlotGroupSystemTest", - "deviceType": [ - "tv", - "car" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "testability", - "moduleType": "entry" - }, - "abilities": [{ - "name": "AnsSlotGroupSystemTest", - "icon": "$media:snowball", - "srcLanguage": "c++", - "label": "AnsSlotGroupSystemTest Ability zofa label", - "launchType": "singletop", - "orientation": "unspecified", - "type": "page", - "visible": true - }] - } -} \ No newline at end of file diff --git a/test/resource/ansSTSlotGroupTest/include/ans_slotgroup_test.h b/test/resource/ansSTSlotGroupTest/include/ans_slotgroup_test.h deleted file mode 100644 index 4e20ffb27f05cd9239d22d905b0fa60cddb9a6e3..0000000000000000000000000000000000000000 --- a/test/resource/ansSTSlotGroupTest/include/ans_slotgroup_test.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _ans_st_slotgroup_ -#define _ans_st_slotgroup_ - -#include -#include "ability_loader.h" -#include "notification_helper.h" -#ifdef PRINT_LOG -#undef PRINT_LOG -#endif -#include "app_log_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -class AnsSlotGroupSystemTest : public Ability { -protected: - virtual void OnStart(const Want &want) override; - virtual void OnStop() override; - virtual void OnActive() override; - virtual void OnInactive() override; - virtual void OnBackground() override; - virtual void OnForeground(const Want &want) override; - virtual void OnNewWant(const Want &want) override; - -private: - void Clear(); - void GetWantInfo(const Want &want); - - std::string shouldReturn; - std::string targetBundle; - std::string targetAbility; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif \ No newline at end of file diff --git a/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp b/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp deleted file mode 100644 index ac933f8011044b179392e5577fb42e19bc2c19c3..0000000000000000000000000000000000000000 --- a/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ans_slotgroup_test.h" -#include "notification_slot_group.h" - -namespace OHOS { -namespace AppExecFwk { -void AnsSlotGroupSystemTest::OnStart(const Want &want) -{ - APP_LOGI("====>Ans SlotGroup test start:====>"); - Notification::NotificationSlotGroup slotGroupTest("id_test", "name_test"); - if (slotGroupTest.GetId().empty()) { - ANS_LOGI("====>Notification slot group id is invalid====>"); - } else { - ANS_LOGI("====>Notification slot group id is====> %{public}s", slotGroupTest.GetId().c_str()); - } - ErrCode errAddGroupTest = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupTest); - APP_LOGI("====>add a SlotGroup with id name id_test, ErrCode is====> %{public}d", errAddGroupTest); - - Notification::NotificationSlot slotFirst(Notification::NotificationConstant::SlotType::SOCIAL_COMMUNICATION); - Notification::NotificationSlot slotSecond(Notification::NotificationConstant::SlotType::SERVICE_REMINDER); - Notification::NotificationSlot slotThird(Notification::NotificationConstant::SlotType::CONTENT_INFORMATION); - Notification::NotificationSlot slotFourth(Notification::NotificationConstant::SlotType::OTHER); - Notification::NotificationSlot slotFifth(Notification::NotificationConstant::SlotType::CUSTOM); - - slotFirst.SetSlotGroup("id_test"); - slotSecond.SetSlotGroup("id_test"); - slotThird.SetSlotGroup("id_test"); - slotFourth.SetSlotGroup("id_test"); - slotFifth.SetSlotGroup("id_test"); - - ErrCode errAddSlotFirst = Notification::NotificationHelper::AddNotificationSlot(slotFirst); - ErrCode errAddSlotSecond = Notification::NotificationHelper::AddNotificationSlot(slotSecond); - ErrCode errAddSlotThird = Notification::NotificationHelper::AddNotificationSlot(slotThird); - ErrCode errAddSlotFourth = Notification::NotificationHelper::AddNotificationSlot(slotFourth); - ErrCode errAddSlotFifth = Notification::NotificationHelper::AddNotificationSlot(slotFifth); - - APP_LOGI("====>add SOCIAL_COMMUNICATION type slot, ErrCode is====> %{public}d", errAddSlotFirst); - APP_LOGI("====>add SERVICE_REMINDER type slot, ErrCode is====> %{public}d", errAddSlotSecond); - APP_LOGI("====>add CONTENT_INFORMATION type slot, ErrCode is====> %{public}d", errAddSlotThird); - APP_LOGI("====>add OTHER type slot, ErrCode is====> %{public}d", errAddSlotFourth); - APP_LOGI("====>add CUSTOM type slot, ErrCode is====> %{public}d", errAddSlotFifth); - - sptr group; - ErrCode errcodeGet = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", group); - APP_LOGI("====>get SlotGroup after adding SlotGroup and slots, ErrCode is====> %{public}d", errcodeGet); - if (group != nullptr) { - std::string dumpGroupStr = group->Dump(); - APP_LOGI("====>obtained group dump====> %{public}s", dumpGroupStr.c_str()); - APP_LOGI("====>the number of slots in the obtained group====> %{public}zu", group->GetSlots().size()); - - ErrCode errcodeRem = Notification::NotificationHelper::RemoveNotificationSlotGroup("id_test"); - APP_LOGI("====>remove the group whose id is id_test, ErrCode is====> %{public}d", errcodeRem); - sptr groupTwo; - ErrCode errcodeGetTwo = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", groupTwo); - APP_LOGI("====>get SlotGroup after removing SlotGroup, ErrCode is====> %{public}d", errcodeGetTwo); - - ErrCode errAddGroupTestSecond = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupTest); - APP_LOGI("====>add SlotGroup again with id name id_test, ErrCode is====> %{public}d", errAddGroupTestSecond); - sptr groupSecond; - ErrCode errcodeGetSecond = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", groupSecond); - APP_LOGI("====>get SlotGroup again after adding SlotGroup again, ErrCode is: %{public}d", errcodeGetSecond); - if (groupSecond != nullptr) { - dumpGroupStr = groupSecond->Dump(); - APP_LOGI("====>the second time obtained group dump====> %{public}s", dumpGroupStr.c_str()); - APP_LOGI("====>the number of slots in second obtained group: %{public}zu", groupSecond->GetSlots().size()); - - Notification::NotificationSlotGroup slotGroupFirst("id_first", "name_first"); - ErrCode errAddGroupFirst = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupFirst); - APP_LOGI("====>add SlotGroup with id name id_first, ErrCode is====> %{public}d", errAddGroupFirst); - - Notification::NotificationSlotGroup slotGroupSecond("id_second", "name_second"); - ErrCode errAddGroupSecond = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupSecond); - APP_LOGI("====>add SlotGroup with id name id_second, ErrCode is====> %{public}d", errAddGroupSecond); - - Notification::NotificationSlotGroup slotGroupThird("id_third", "name_third"); - ErrCode errAddGroupThird = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupThird); - APP_LOGI("====>add SlotGroup with id name id_third, ErrCode is====> %{public}d", errAddGroupThird); - - Notification::NotificationSlotGroup slotGroupFourth("id_fourth", "name_fourth"); - ErrCode errAddGroupFourth = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupFourth); - APP_LOGI("====>add SlotGroup with id name id_fourth, ErrCode is====> %{public}d", errAddGroupFourth); - - Notification::NotificationSlotGroup slotGroupFifth("id_fifth", "name_fifth"); - ErrCode errAddGroupFifth = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupFifth); - APP_LOGI("====>add SlotGroup with id name id_fifth, ErrCode is====> %{public}d", errAddGroupFifth); - } else { - ANS_LOGI("====>fail to get group after adding SlotGroup for the second time====>"); - } - } else { - ANS_LOGI("====>fail to get group after adding SlotGroup and slots for the first time====>"); - } - - Ability::OnStart(want); -} - -void AnsSlotGroupSystemTest::OnNewWant(const Want &want) -{ - GetWantInfo(want); - Ability::OnNewWant(want); -} - -void AnsSlotGroupSystemTest::OnForeground(const Want &want) -{ - GetWantInfo(want); - Ability::OnForeground(want); -} - -void AnsSlotGroupSystemTest::OnStop() -{ - Ability::OnStop(); -} - -void AnsSlotGroupSystemTest::OnActive() -{ - Ability::OnActive(); - if (std::string::npos != shouldReturn.find(GetAbilityName())) { - TerminateAbility(); - } - Clear(); -} - -void AnsSlotGroupSystemTest::OnInactive() -{ - Ability::OnInactive(); -} - -void AnsSlotGroupSystemTest::OnBackground() -{ - Ability::OnBackground(); -} - -void AnsSlotGroupSystemTest::Clear() -{ - shouldReturn = ""; - targetBundle = ""; - targetAbility = ""; -} - -void AnsSlotGroupSystemTest::GetWantInfo(const Want &want) -{ - Want mWant(want); - shouldReturn = mWant.GetStringParam("shouldReturn"); - targetBundle = mWant.GetStringParam("targetBundle"); - targetAbility = mWant.GetStringParam("targetAbility"); -} - -REGISTER_AA(AnsSlotGroupSystemTest) -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap b/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap deleted file mode 100644 index 0132daeec68f4c4e81ce4f02e6352cec88a7be96..0000000000000000000000000000000000000000 Binary files a/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap and /dev/null differ diff --git a/test/resource/notificationfuzztest/include/notificationgetparam.h b/test/resource/notificationfuzztest/include/notificationgetparam.h index 873d64e3adec0db685a4c1ef282469f3a81a38e1..e083a2b268ffdfcb1d0579156b896f03ce8da9e2 100644 --- a/test/resource/notificationfuzztest/include/notificationgetparam.h +++ b/test/resource/notificationfuzztest/include/notificationgetparam.h @@ -96,9 +96,6 @@ sptr GetParamNotificationSlotSptr(); OHOS::Notification::NotificationConstant::SlotType GetParamSlotType(); std::vector> GetParamNotificationSlotSptrVector(); std::vector GetParamNotificationSlotVector(); -std::vector GetParamNotificationSlotGroupVector(); -sptr GetParamNotificationSlotGroup(); -std::vector> GetParamNotificationSlotGroupSptrVector(); std::shared_ptr GetParamNotificationBundleOption(); std::shared_ptr GetParamNotificationRequest(); std::vector> GetParamNotificationRequestVector(); diff --git a/test/resource/notificationfuzztest/notificationfuzzconfig/config.json b/test/resource/notificationfuzztest/notificationfuzzconfig/config.json index a7fc3f8c8d7405e286dc7bdae935ca3ab86a2ffc..446dcbb6cf7e08edd31e0829be3082d83b204d08 100644 --- a/test/resource/notificationfuzztest/notificationfuzzconfig/config.json +++ b/test/resource/notificationfuzztest/notificationfuzzconfig/config.json @@ -37,11 +37,6 @@ "RemoveAllSlots": [], "GetNotificationSlot": [], "GetNotificationSlots": [], - "AddNotificationSlotGroup": [], - "AddNotificationSlotGroups": [], - "RemoveNotificationSlotGroup": [], - "GetNotificationSlotGroup": [], - "GetNotificationSlotGroups": [], "GetNotificationSlotNumAsBundle": [], "PublishNotificationNotificationRequest": [], "PublishNotificationstringNotificationRequest": [], @@ -73,7 +68,6 @@ "RemoveNotifications": [], "GetNotificationSlotsForBundle": [], "UpdateNotificationSlots": [], - "UpdateNotificationSlotGroups": [], "GetAllActiveNotificationsNotification": [], "GetAllActiveNotificationsstringNotification": [], "IsAllowedNotify": [], diff --git a/test/resource/notificationfuzztest/src/notificationfuzztestmanager.cpp b/test/resource/notificationfuzztest/src/notificationfuzztestmanager.cpp index bb4702414a4edd93b96243d9bcdf2a43c0aec941..09ac942341b3af708d5594118c57aee652c350cb 100644 --- a/test/resource/notificationfuzztest/src/notificationfuzztestmanager.cpp +++ b/test/resource/notificationfuzztest/src/notificationfuzztestmanager.cpp @@ -51,26 +51,6 @@ void NotificationFuzzTestManager::RegisterNotificationHelper() OHOS::Notification::NotificationHelper::GetNotificationSlots(param); }); - callFunctionMap_.emplace("NotificationHelperAddNotificationSlotGroup", - []() { OHOS::Notification::NotificationHelper::AddNotificationSlotGroup(*GetParamNotificationSlotGroup()); }); - - callFunctionMap_.emplace("NotificationHelperAddNotificationSlotGroups", []() { - OHOS::Notification::NotificationHelper::AddNotificationSlotGroups(GetParamNotificationSlotGroupVector()); - }); - - callFunctionMap_.emplace("NotificationHelperRemoveNotificationSlotGroup", - []() { OHOS::Notification::NotificationHelper::RemoveNotificationSlotGroup(GetStringParam()); }); - - callFunctionMap_.emplace("NotificationHelperGetNotificationSlotGroup", []() { - sptr param = GetParamNotificationSlotGroup(); - OHOS::Notification::NotificationHelper::GetNotificationSlotGroup(GetStringParam(), param); - }); - - callFunctionMap_.emplace("NotificationHelperGetNotificationSlotGroups", []() { - std::vector> param = GetParamNotificationSlotGroupSptrVector(); - OHOS::Notification::NotificationHelper::GetNotificationSlotGroups(param); - }); - callFunctionMap_.emplace("NotificationHelperGetNotificationSlotNumAsBundle", []() { int param = GetIntParam(); OHOS::Notification::NotificationHelper::GetNotificationSlotNumAsBundle( @@ -309,11 +289,6 @@ void NotificationFuzzTestManager::RegisterNotificationHelper() *GetParamNotificationBundleOption(), GetParamNotificationSlotSptrVector()); }); - callFunctionMap_.emplace("NotificationHelperUpdateNotificationSlotGroups", []() { - OHOS::Notification::NotificationHelper::UpdateNotificationSlotGroups( - *GetParamNotificationBundleOption(), GetParamNotificationSlotGroupSptrVector()); - }); - callFunctionMap_.emplace("NotificationHelperGetAllActiveNotificationsvectorsptrNotification", []() { std::vector> notification = GetParamNotificationSptrVector(); OHOS::Notification::NotificationHelper::GetAllActiveNotifications(notification); diff --git a/test/resource/notificationfuzztest/src/notificationgetparam.cpp b/test/resource/notificationfuzztest/src/notificationgetparam.cpp index ce9232bca912cb4ec157d01cdc1f2f13f806140e..0ff4906fb253e45048dc973100ecf2fa00f04166 100644 --- a/test/resource/notificationfuzztest/src/notificationgetparam.cpp +++ b/test/resource/notificationfuzztest/src/notificationgetparam.cpp @@ -559,32 +559,6 @@ std::vector GetParamNotificationSlotVector return param; } -std::vector GetParamNotificationSlotGroupVector() -{ - vector param; - size_t len = GenRandom(0, MAX_LENGTH); - while (len--) { - OHOS::Notification::NotificationSlotGroup t = *GetParamNotificationSlotGroup(); - param.push_back(t); - } - return param; -} -sptr GetParamNotificationSlotGroup() -{ - sptr param = - new OHOS::Notification::NotificationSlotGroup(GetStringParam(), GetStringParam()); - return param; -} -std::vector> GetParamNotificationSlotGroupSptrVector() -{ - vector> param; - size_t len = GenRandom(0, MAX_LENGTH); - while (len--) { - sptr t = GetParamNotificationSlotGroup(); - param.push_back(t); - } - return param; -} std::shared_ptr GetParamNotificationBundleOption() { if (GetBoolParam()) {