/* * Copyright (c) 2021-2024 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_SERVICES_ANS_INCLUDE_ADVANCED_NOTIFICATION_SERVICE_H #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_ADVANCED_NOTIFICATION_SERVICE_H #include #include #include #include #include #include "event_handler.h" #include "event_runner.h" #include "ffrt.h" #include "refbase.h" #include "ans_const_define.h" #include "ans_manager_stub.h" #include "common_notification_publish_process.h" #include "distributed_kv_data_manager.h" #include "distributed_kvstore_death_recipient.h" #include "live_publish_process.h" #include "notification.h" #include "notification_bundle_option.h" #include "notification_dialog_manager.h" #include "notification_do_not_disturb_profile.h" #include "notification_record.h" #include "notification_slot_filter.h" #include "notification_sorting_map.h" #include "permission_filter.h" #include "push_callback_interface.h" #include "system_event_observer.h" #include "notification_subscriber_manager.h" #include "distributed_device_status.h" #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED #include "reminder_swing_decision_center.h" #endif namespace OHOS { namespace Notification { static const uint32_t DEFAULT_SLOT_FLAGS = 59; // 0b111011 class AdvancedNotificationService final : public AnsManagerStub { public: struct NotificationRequestDb { sptr request {nullptr}; sptr bundleOption {nullptr}; }; struct RecentNotification { sptr notification = nullptr; bool isActive = false; int32_t deleteReason = 0; int64_t deleteTime = 0; }; ~AdvancedNotificationService() override; DISALLOW_COPY_AND_MOVE(AdvancedNotificationService); /** * @brief Get the instance of service. * * @return Returns the instance. */ static sptr GetInstance(); static std::map& GetDefaultSlotConfig(); void SelfClean(); /** * @brief Get notification_svr_queue of service. * * @return Returns the queue. */ std::shared_ptr GetNotificationSvrQueue(); // AnsManagerStub /** * @brief Publishes a notification with a specified label. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * * @param label Indicates the label of the notification to publish. * @param notification Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. * @return Returns ERR_OK on success, others on failure. */ ErrCode Publish(const std::string &label, const sptr &request) override; /** * @brief Publishes a notification. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * * @param notification Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. * @return Returns ERR_OK on success, others on failure. */ ErrCode PublishNotificationForIndirectProxy(const sptr &request) override; /** * @brief Cancels a published notification matching the specified label and notificationId. * * @param notificationId Indicates the ID of the notification to cancel. * @param label Indicates the label of the notification to cancel. * @param instanceKey Indicates the application instance key. * @return Returns cancel notification result. */ ErrCode Cancel(int32_t notificationId, const std::string &label, int32_t instanceKey) override; /** * @brief Cancels all the published notifications. * * @param instanceKey Indicates the application instance key. * @return Returns ERR_OK on success, others on failure. */ ErrCode CancelAll(int32_t instanceKey) override; /** * @brief Cancels a published agent notification. * * @param notificationId Indicates the unique notification ID in the application. * The value must be the ID of a published notification. * Otherwise, this method does not take effect. * @param representativeBundle Indicates the name of application bundle your application is representing. * @param userId Indicates the specific user. * @return Returns cancel notification result. */ ErrCode CancelAsBundle( int32_t notificationId, const std::string &representativeBundle, int32_t userId) override; /** * @brief Cancels a published agent notification. * * @param bundleOption Indicates the bundle of application bundle your application is representing. * @param notificationId Indicates the unique notification ID in the application. * The value must be the ID of a published notification. * Otherwise, this method does not take effect. * @return Returns cancel notification result. */ ErrCode CancelAsBundle(const sptr &bundleOption, int32_t notificationId) override; /** * @brief Cancels a published agent notification. * * @param bundleOption Indicates the bundle of application bundle your application is representing. * @param notificationId Indicates the unique notification ID in the application. * The value must be the ID of a published notification. * Otherwise, this method does not take effect. * @param userId Indicates the specific user. * @return Returns cancel notification result. */ ErrCode CancelAsBundle( const sptr &bundleOption, int32_t notificationId, int32_t userId) override; /** * @brief Adds a notification slot by type. * * @param slotType Indicates the notification slot type to be added. * @return Returns ERR_OK on success, others on failure. */ ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; /** * @brief Creates multiple notification slots. * * @param slots Indicates the notification slots to create. * @return Returns ERR_OK on success, others on failure. */ ErrCode AddSlots(const std::vector> &slots) override; /** * @brief Deletes a created notification slot based on the slot ID. * * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot * This parameter must be specified. * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; /** * @brief Deletes all notification slots. * * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveAllSlots() override; /** * @brief Queries a created notification slot. * * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This * parameter must be specified. * @param slot Indicates the created NotificationSlot. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) override; /** * @brief Obtains all notification slots of this application. * * @param slots Indicates the created NotificationSlot. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSlots(std::vector> &slots) override; /** * @brief Obtains the number of slot. * * @param bundleOption Indicates the bundle name and uid of the application. * @param num Indicates the number of slot. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; /** * @brief Obtains active notifications of the current application in the system. * * @param notifications Indicates active NotificationRequest objects of the current application. * @param instanceKey Indicates the application instance key. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetActiveNotifications(std::vector> ¬ifications, int32_t instanceKey) override; /** * @brief Obtains the number of active notifications of the current application in the system. * * @param num Indicates the number of active notifications of the current application. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetActiveNotificationNums(uint64_t &num) override; /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to * call this method. * * @param notifications Indicates all active notifications of this application. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override; /** * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method * to obtain particular active notifications, you must have received the notifications and obtained the key * via {Notification::GetKey()}. * * @param key Indicates the key array for querying corresponding active notifications. * If this parameter is null, this method returns all active notifications in the system. * @param notification Indicates the set of active notifications corresponding to the specified key. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSpecialActiveNotifications( const std::vector &key, std::vector> ¬ifications) override; ErrCode GetActiveNotificationByFilter( const sptr &bundleOption, const int32_t notificationId, const std::string &label, const std::vector extraInfoKeys, sptr &request) override; /** * @brief Allows another application to act as an agent to publish notifications in the name of your application * bundle. * * @param agent Indicates the name of the application bundle that can publish notifications for your application. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetNotificationAgent(const std::string &agent) override; /** * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. * * @param agent Indicates the name of the application bundle that can publish notifications for your application if * any; returns null otherwise. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetNotificationAgent(std::string &agent) override; /** * @brief Checks whether your application has permission to publish notifications by calling * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the * given representativeBundle. * * @param representativeBundle Indicates the name of application bundle your application is representing. * @param canPublish Indicates whether your application has permission to publish notifications. * @return Returns ERR_OK on success, others on failure. */ ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; /** * @brief Publishes a notification in the name of a specified application bundle. * @note If the notification to be published has the same ID as a published notification that has not been canceled, * the existing notification will be replaced by the new one. * * @param notification Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. * @param representativeBundle Indicates the name of the application bundle that allows your application to publish * notifications for it by calling setNotificationAgent. * @return Returns ERR_OK on success, others on failure. */ ErrCode PublishAsBundle( const sptr notification, const std::string &representativeBundle) override; /** * @brief Sets the number of active notifications of the current application as the number to be displayed on the * notification badge. * * @param num Indicates the badge number. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetNotificationBadgeNum(int32_t num) override; /** * @brief Obtains the importance level of this application. * * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetBundleImportance(int32_t &importance) override; /** * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. * * @param granted True if the application has permission; false for otherwise. * @return Returns ERR_OK on success, others on failure. */ ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; /** * @brief Trigger the local live view after the button has been clicked. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. * @param notificationId Indicates the id of the notification. * @param buttonOption Indicates which button has been clicked. * @return Returns trigger localLiveView result. */ ErrCode TriggerLocalLiveView(const sptr &bundleOption, const int32_t notificationId, const sptr &buttonOption) override; /** * @brief Delete notification. * * @param bundleOption Indicates the NotificationBundleOption of the notification. * @param notificationId Indicates the id of the notification. * @param label Indicates the label of the notification. * @param removeReason Indicates the reason of remove notification. * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveNotification(const sptr &bundleOption, int32_t notificationId, const std::string &label, int32_t removeReason) override; /** * @brief Delete all notifications. * * @param bundleOption Indicates the NotificationBundleOption of notifications. * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveAllNotifications(const sptr &bundleOption) override; ErrCode RemoveAllNotificationsForDisable(const sptr &bundleOption); ErrCode RemoveNotifications(const std::vector &keys, int32_t removeReason) override; ErrCode GetUnifiedGroupInfoFromDb(std::string &enable); /** * @brief Delete notification based on key. * * @param key Indicates the key to delete notification. * @param removeReason Indicates the reason of remove notification. * @return Returns ERR_OK on success, others on failure. */ ErrCode Delete(const std::string &key, int32_t removeReason) override; /** * @brief Remove notifications based on bundle. * * @param bundleOption Indicates the NotificationBundleOption of notifications. * @return Returns ERR_OK on success, others on failure. */ ErrCode DeleteByBundle(const sptr &bundleOption) override; /** * @brief Remove all notifications. * * @return Returns ERR_OK on success, others on failure. */ ErrCode DeleteAll() override; /** * @brief Get all the slots corresponding to the bundle. * * @param bundleOption Indicates the NotificationBundleOption object. * @param slots Indicates the notification slots. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSlotsByBundle( const sptr &bundleOption, std::vector> &slots) override; /** * @brief Get the specified slot corresponding to the bundle. * * @param bundleOption Indicates the NotificationBundleOption object. * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This * parameter must be specified. * @param slot Indicates the notification slot. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSlotByBundle( const sptr &bundleOption, const NotificationConstant::SlotType &slotType, sptr &slot) override; /** * @brief Update slots according to bundle. * * @param bundleOption Indicates the NotificationBundleOption object. * @param slots Indicates the notification slots to be updated. * @return Returns ERR_OK on success, others on failure. */ ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; /** * @brief Allow notifications to be sent based on the deviceId. * * @param deviceId Indicates the device Id. * @return Returns ERR_OK on success, others on failure. */ ErrCode RequestEnableNotification(const std::string &deviceId, const sptr &callback, const sptr &callerToken) override; /** * @brief Set whether to allow the specified deviceId to send notifications for current bundle. * * @param deviceId Indicates the device Id. * @param enabled Indicates the flag that allows notification to be pulished. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; /** * @brief Set whether to allow the specified deviceId to send notifications for all bundles. * * @param deviceId Indicates the device Id. * @param enabled Indicates the flag that allows notification to be pulished. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; /** * @brief Set whether to allow the specified bundle to send notifications. * * @param bundleOption Indicates the NotificationBundleOption object. * @param enabled Indicates the flag that allows notification to be pulished. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetNotificationsEnabledForSpecialBundle( const std::string &deviceId, const sptr &bundleOption, bool enabled) override; /** * @brief Sets whether the bundle allows the banner to display notification. * * @param bundleOption Indicates the NotificationBundleOption object. * @param enabled Indicates the flag that allows badge to be shown. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) override; /** * @brief Gets whether the bundle allows the badge to display the status of notifications. * * @param bundleOption Indicates the NotificationBundleOption object. * @param enabled Indicates the flag that allows badge to be shown. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) override; /** * @brief Gets whether allows the badge to display the status of notifications. * * @param enabled Indicates the flag that allows badge to be shown. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetShowBadgeEnabled(bool &enabled) override; /** * @brief Subscribes notifications. * * @param subscriber Indicates the subscriber. * @param info Indicates the NotificationSubscribeInfo object. * @return Returns ERR_OK on success, others on failure. */ ErrCode Subscribe(const sptr &subscriber, const sptr &info) override; /** * @brief Subscribes notifications self. * * @param subscriber Indicates the subscriber. * @return Returns ERR_OK on success, others on failure. */ ErrCode SubscribeSelf(const sptr &subscriber) override; /** * @brief Subscribes notifications. * * @param subscriber Indicates the subscriber. * @param info Indicates the NotificationSubscribeInfo object. * @return Returns ERR_OK on success, others on failure. */ ErrCode SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) override; /** * @brief Unsubscribes notifications. * * @param subscriber Indicates the subscriber. * @param info Indicates the NotificationSubscribeInfo object. * @return Returns ERR_OK on success, others on failure. */ ErrCode Unsubscribe(const sptr &subscriber, const sptr &info) override; /** * @brief Checks whether this device is allowed to publish notifications. * * @param allowed Indicates the flag that allows notification. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsAllowedNotify(bool &allowed) override; /** * @brief Checks whether this application is allowed to publish notifications. * * @param allowed Indicates the flag that allows notification. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsAllowedNotifySelf(bool &allowed) override; /** * @brief Checks whether this application can pop enable notification dialog. * * @param canPop True if can pop enable notification dialog * @return Returns is canPop result. */ ErrCode CanPopEnableNotificationDialog(const sptr &callback, bool &canPop, std::string &bundleName) override; /** * @brief remove enable notification dialog. * * @return Returns remove dialog result. */ ErrCode RemoveEnableNotificationDialog() override; ErrCode RemoveEnableNotificationDialog(const sptr &bundleOption); /** * @brief Checks whether notifications are allowed for a specific bundle. * * @param bundleOption Indicates the NotificationBundleOption object. * @param allowed Indicates the flag that allows notification. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) override; /** * @brief Set do not disturb date. * * @param date Indicates the NotificationDoNotDisturbDate object. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetDoNotDisturbDate(const sptr &date) override; /** * @brief Get do not disturb date. * * @param date Indicates the NotificationDoNotDisturbDate object. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetDoNotDisturbDate(sptr &date) override; /** * @brief Add Do Not Disturb profiles. * * @param profiles Indicates the list of NotificationDoNotDisturbProfile objects to add. * @return Returns ERR_OK on success, others on failure. */ ErrCode AddDoNotDisturbProfiles(const std::vector> &profiles) override; /** * @brief Remove Do Not Disturb profiles. * * @param profiles Indicates the list of NotificationDoNotDisturbProfile objects to remove. * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveDoNotDisturbProfiles(const std::vector> &profiles) override; /** * @brief Get whether Do Not Disturb mode is supported. * * @param doesSupport Indicates the flag that supports DND mode. * @return Returns ERR_OK on success, others on failure. */ ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; /** * @brief Is coming call need silent in do not disturb mode. * * @param phoneNumber the calling format number. * @return Returns silent in do not disturb mode. */ ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) override; /** * @brief Cancel notifications according to group. * * @param groupName Indicates the group name. * @param instanceKey Indicates the application instance key. * @return Returns ERR_OK on success, others on failure. */ ErrCode CancelGroup(const std::string &groupName, int32_t instanceKey) override; /** * @brief Delete notifications according to bundle and group. * * @param bundleOption Indicates the NotificationBundleOption object. * @param groupName Indicates the group name. * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveGroupByBundle( const sptr &bundleOption, const std::string &groupName) override; /** * @brief Gets whether distributed notification is enabled. * * @param enabled Indicates the enabled flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsDistributedEnabled(bool &enabled) override; /** * @brief Sets distributed notification enabled or disabled. * * @param enabled Indicates the enabled flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode EnableDistributed(bool enabled) override; /** * @brief Sets distributed notification enabled or disabled for specific bundle. * * @param bundleOption Indicates the NotificationBundleOption object. * @param enabled Indicates the enabled flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) override; /** * @brief Sets distributed notification enabled or disabled for current bundle. * * @param enabled Indicates the enabled flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode EnableDistributedSelf(bool enabled) override; /** * @brief Gets whether distributed notification is enabled for specific bundle. * * @param bundleOption Indicates the NotificationBundleOption object. * @param enabled Indicates the enabled flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) override; /** * @brief Get the reminder type of the current device. * * @param remindType Reminder type for the device. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; /** * @brief Publishes a continuous notification. * * @param request Notification requests that need to be posted. * @return Returns ERR_OK on success, others on failure. */ ErrCode PublishContinuousTaskNotification(const sptr &request) override; /** * @brief Cancels a continuous notification. * * @param label Identifies the label of the specified notification. * @param notificationId Identifies the id of the specified notification. * @return Returns ERR_OK on success, others on failure. */ ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; /** * @brief Check reminder permission */ bool CheckReminderPermission(); /** * @brief Publishes a reminder notification. * * @param reminder Identifies the reminder notification request that needs to be published. * @return Returns ERR_OK on success, others on failure. */ ErrCode PublishReminder(sptr &reminder) override; /** * @brief Cancel a reminder notifications. * * @param reminderId Identifies the reminders id that needs to be canceled. * @return Returns ERR_OK on success, others on failure. */ ErrCode CancelReminder(const int32_t reminderId) override; /** * @brief Get all valid reminder notifications. * * @param reminders Identifies the list of all valid notifications. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetValidReminders(std::vector> &reminders) override; /** * @brief Cancel all reminder notifications. * * @return Returns ERR_OK on success, others on failure. */ ErrCode CancelAllReminders() override; /** * @brief Add exclude date for reminder * * @param reminderId Identifies the reminders id. * @param date exclude date * @return Returns ERR_OK on success, others on failure. */ ErrCode AddExcludeDate(const int32_t reminderId, const uint64_t date) override; /** * @brief Clear exclude date for reminder * * @param reminderId Identifies the reminders id. * @return Returns ERR_OK on success, others on failure. */ ErrCode DelExcludeDates(const int32_t reminderId) override; /** * @brief Get exclude date for reminder * * @param reminderId Identifies the reminders id. * @param dates exclude dates * @return Returns ERR_OK on success, others on failure. */ ErrCode GetExcludeDates(const int32_t reminderId, std::vector& dates) override; /** * @brief Checks whether this device is support template. * * @param templateName Identifies the template name for searching as a condition. * @param support Identifies the support flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; /** * @brief Checks Whether the specified users is allowed to publish notifications. * * @param userId Identifies the user's id. * @param allowed Identifies the allowed flag. * @return Returns ERR_OK on success, others on failure. */ ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; /** * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must * have system permissions to call this method. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only * be null or an empty string, indicating the current device. * @param enabled Specifies whether to allow all applications to publish notifications. The value true * indicates that notifications are allowed, and the value false indicates that notifications * are not allowed. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override; /** * @brief Delete all notifications by user. * * @param userId Indicates the user id. * @return Returns ERR_OK on success, others on failure. */ ErrCode DeleteAllByUser(const int32_t &userId) override; /** * @brief Set do not disturb date by user. * * @param userId Indicates the user id. * @param date Indicates NotificationDoNotDisturbDate object. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; /** * @brief Get the do not disturb date by user. * * @param userId Indicates the user id. * @param date Indicates the NotificationDoNotDisturbDate object. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) override; ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled) override; ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) override; // SystemEvent /** * @brief Obtains the event of bundle removed. * * @param bundleOption Indicates the bundle info. */ void OnBundleRemoved(const sptr &bundleOption); /** * @brief Obtains the event of bundle batch removed. * * @param notifications Notification vector. */ void ExecBatchCancel(std::vector> ¬ifications, int32_t &reason); /** * @brief Obtains the event of user removed. * * @param userId Indicates the user. */ void OnUserRemoved(const int32_t &userId); /** * @brief Set whether to sync notifications to devices that do not have the app installed. * * @param userId Indicates the specific user. * @param enabled Allow or disallow sync notifications. * @return Returns set enabled result. */ ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) override; /** * @brief Obtains whether to sync notifications to devices that do not have the app installed. * * @param userId Indicates the specific user. * @param enabled Allow or disallow sync notifications. * @return Returns get enabled result. */ ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) override; /** * @brief Obtains the number of slotFlags. * * @param bundleOption Indicates the bundle name and uid of the application. * @param slot Indicates the specified slot object * @param slotFlags Indicates the slogFlags of slot. * @return Returns ERR_OK on success, others on failure. */ virtual ErrCode GetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t &slotFlags) override; /** * @brief Set the slotFlags of slot. * * @param bundleOption Indicates the bundle name and uid of the application. * @param slot Indicates the specified slot object * @param slotFlags Indicates the slogFlags of slot to set. * @return Returns ERR_OK on success, others on failure. */ virtual ErrCode SetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t slotFlags) override; #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED /** * @brief Obtains the event of turn on screen. */ void OnScreenOn(); /** * @brief Obtains the event of turn off screen. */ void OnScreenOff(); #endif void OnResourceRemove(int32_t userId); void OnBundleDataCleared(const sptr &bundleOption); /** * @brief Obtains the event of bundle install. * * @param bundleOption Indicates the bundle info. */ void OnBundleDataAdd(const sptr &bundleOption); /** * @brief Obtains the event of bundle update. * * @param bundleOption Indicates the bundle info. */ void OnBundleDataUpdate(const sptr &bundleOption); /** * @brief Boot system completed event callback. */ void OnBootSystemCompleted(); // Distributed KvStore /** * @brief Obtains the death event of the Distributed KvStore service. */ void OnDistributedKvStoreDeathRecipient(); ErrCode CancelPreparedNotification(int32_t notificationId, const std::string &label, const sptr &bundleOption, const int32_t reason); ErrCode PrepareNotificationInfo( const sptr &request, sptr &bundleOption); ErrCode PublishPreparedNotification(const sptr &request, const sptr &bundleOption, bool isUpdateByOwner = false); /** * @brief Dump current running status for debuging. * * @param cmd Indicates the specified dump command. * @param bundle Indicates the specified bundle name. * @param userId Indicates the specified userId. * @param dumpInfo Indicates the container containing datas. * @return Returns ERR_OK on success, others on failure. */ ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, std::vector &dumpInfo) override; /** * @brief Set badge number. * * @param badgeNumber The badge number. * @param instanceKey The application instance key. * @return Returns set badge number result. */ ErrCode SetBadgeNumber(int32_t badgeNumber, int32_t instanceKey) override; /** * @brief Set badge number by bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param badgeNumber The badge number. * @return Returns set badge number by bundle result. */ ErrCode SetBadgeNumberByBundle(const sptr &bundleOption, int32_t badgeNumber) override; /** * @brief Obtains allow notification application list. * * @param bundleOption Indicates the bundle bundleOption. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetAllNotificationEnabledBundles(std::vector &bundleOption) override; /** * @brief Register Push Callback. * * @param pushCallback PushCallBack. * @param notificationCheckRequest Filter conditions for push check * @return Returns register push Callback result. */ ErrCode RegisterPushCallback(const sptr& pushCallback, const sptr ¬ificationCheckRequest) override; /** * @brief Unregister Push Callback. * * @return Returns unregister push Callback result. */ ErrCode UnregisterPushCallback() override; /** * @brief Sets whether to allow a specified application to publish notifications cross * device collaboration. The caller must have system permissions to call this method. * * @param bundleOption Indicates the bundle name and uid of the application. * @param deviceType Indicates the type of the device running the application. * @param enabled Specifies whether to allow the given application to publish notifications. The value * true indicates that notifications are allowed, and the value false indicates that * notifications are not allowed. * @return Returns set notifications enabled for specified bundle result. */ ErrCode SetDistributedEnabledByBundle(const sptr &bundleOption, const std::string &deviceType, const bool enabled) override; /* * @brief Get whether to allow a specified application to publish notifications cross * device collaboration. The caller must have system permissions to call this method. * * @param bundleOption Indicates the bundle name and uid of the application. * @param deviceType Indicates the type of the device running the application. * @param enabled Specifies whether to allow the given application to publish notifications. The value * true indicates that notifications are allowed, and the value false indicates that * notifications are not allowed. * @return Returns set notifications enabled for specified bundle result. */ ErrCode IsDistributedEnabledByBundle(const sptr &bundleOption, const std::string &deviceType, bool &enabled) override; /** * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders * * @param deviceType Indicates the type of the device running the application. * @param enabled Specifies whether to allow the given device to publish notifications. * The value true indicates that notifications are allowed, and the value * false indicates that notifications are not allowed. * @return Returns set notifications enabled for specified bundle result. */ ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) override; /** * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders * * @param deviceType Indicates the type of the device running the application. * @param enabled Specifies whether to allow the given device to publish notifications. * The value true indicates that notifications are allowed, and the value * false indicates that notifications are not allowed. * @return Returns set notifications enabled for specified bundle result. */ ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) override; /** * @brief Set the status of the target device. * * @param deviceType Type of the device whose status you want to set. * @param status The status. * @return Returns set result. */ ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status) override; /** * @brief clear notification when aggregate local switch close. */ void ClearAllNotificationGroupInfo(std::string localSwitch); /** * @brief Reset pushcallback proxy */ void ResetPushCallbackProxy(); /** * @brief Set the notification SlotFlags whitelist. */ void SetSlotFlagsTrustlistsAsBundle(const sptr &bundleOption); /** * @brief Init The Default Installation Package Notification Enabled. */ void InitNotificationEnableList(); /** * @brief Remove Local Live Notifications */ ErrCode RemoveSystemLiveViewNotifications(const std::string& bundleName, const int32_t uid); /** * @brief Remove Local Live Notifications created by sa. */ ErrCode RemoveSystemLiveViewNotificationsOfSa(int32_t uid); /** * @brief Set the notification flags by soltType. */ void SetRequestBySlotType(const sptr &request, const sptr &bundleOption); // Might fail if ces subscribe failed, if failed, dialogManager_ will be set nullptr bool CreateDialogManager(); /** * @brief Set agent relationship. * * @param key Indicates storing agent relationship if the value is "PROXY_PKG". * @param value Indicates key-value pair of agent relationship. * @return Returns set result. */ ErrCode SetAdditionConfig(const std::string &key, const std::string &value) override; /** * @brief Cancels a published agent notification. * * @param bundleOption Indicates the bundle name and uid of the application. * @param id Indicates the unique notification ID in the application. * @return Returns cancel result. */ ErrCode CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) override; /** * @brief Init publish process. */ bool InitPublishProcess(); /** * @brief Recover LiveView from DB. */ void RecoverLiveViewFromDb(int32_t userId = -1); #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED /** * @brief Register Swing Callback. * * @param swingCallback SwingCallBack. * @return Returns register swing Callback result. */ ErrCode RegisterSwingCallback(const sptr& swingCallback) override; #endif /** * @brief update unified group info. */ void UpdateUnifiedGroupInfo(const std::string &key, std::shared_ptr &groupInfo); /** * @brief Whether reminders are allowed. */ bool AllowUseReminder(const std::string& bundleName); /** * @brief Get do not disturb profile by id. * * @param id Profile id. * @param status Indicates the NotificationDoNotDisturbProfile object. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetDoNotDisturbProfile(int32_t id, sptr &profile) override; int32_t OnBackup(MessageParcel& data, MessageParcel& reply); int32_t OnRestore(MessageParcel& data, MessageParcel& reply); void ResetDistributedEnabled(); /** * @brief Update notification timer by uid * * @param uid uid. * @param isPaused if paused * @return Returns ERR_OK on success, others on failure. */ ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override; protected: /** * @brief Query whether there is a agent relationship between the two apps. * * @param agentBundleName The bundleName of the agent app. * @param sourceBundleName The bundleName of the source app. * @return Returns true if There is an agent relationship; returns false otherwise. */ bool IsAgentRelationship(const std::string &agentBundleName, const std::string &sourceBundleName); private: struct RecentInfo { std::list> list; size_t recentCount = 16; }; enum UploadStatus { CREATE, FIRST_UPDATE_TIME_OUT, CONTINUOUS_UPDATE_TIME_OUT, END, FINISH }; struct SoundPermissionInfo { std::set bundleName_; std::atomic needUpdateCache_ = true; bool allPackage_ = false; std::mutex dbMutex_; }; enum ContactPolicy { FORBID_EVERYONE = 1, ALLOW_EVERYONE = 2, ALLOW_EXISTING_CONTACTS = 3, ALLOW_FAVORITE_CONTACTS = 4, ALLOW_SPECIFIED_CONTACTS = 5, }; AdvancedNotificationService(); void StartFilters(); void StopFilters(); ErrCode Filter(const std::shared_ptr &record, bool isRecover = false); void ChangeNotificationByControlFlags(const std::shared_ptr &record, const bool isAgentController); ErrCode CheckPublishPreparedNotification(const std::shared_ptr &record, bool isSystemApp); void AddToNotificationList(const std::shared_ptr &record); void AddToDelayNotificationList(const std::shared_ptr &record); ErrCode UpdateInNotificationList(const std::shared_ptr &record); void UpdateInDelayNotificationList(const std::shared_ptr &record); ErrCode AssignToNotificationList(const std::shared_ptr &record); ErrCode RemoveFromNotificationList(const sptr &bundleOption, const std::string &label, int32_t notificationId, sptr ¬ification, bool isCancel = false); ErrCode RemoveFromNotificationList(const std::string &key, sptr ¬ification, bool isCancel, int32_t removeReason); ErrCode RemoveFromNotificationListForDeleteAll(const std::string &key, const int32_t &userId, sptr ¬ification); bool RemoveFromDelayedNotificationList(const std::string &key); std::shared_ptr GetFromNotificationList(const std::string &key); std::shared_ptr GetFromNotificationList(const int32_t ownerUid, const int32_t notificationId); std::shared_ptr GetFromDelayedNotificationList( const int32_t ownerUid, const int32_t notificationId); std::vector GetNotificationKeys(const sptr &bundleOption); bool IsNotificationExists(const std::string &key); void SortNotificationList(); static bool NotificationCompare( const std::shared_ptr &first, const std::shared_ptr &second); ErrCode PublishInNotificationList(const std::shared_ptr &record); ErrCode RemoveNotificationBySlot(const sptr &bundleOption, const sptr &slot, const int reason); sptr GenerateSortingMap(); static sptr GenerateBundleOption(); static sptr GenerateValidBundleOption(const sptr &bundleOption); std::string TimeToString(int64_t time); int64_t GetNowSysTime(); ErrCode ActiveNotificationDump(const std::string& bundle, int32_t userId, int32_t recvUserId, std::vector &dumpInfo); ErrCode RecentNotificationDump(const std::string& bundle, int32_t userId, int32_t recvUserId, std::vector &dumpInfo); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED ErrCode DistributedNotificationDump(const std::string& bundle, int32_t userId, int32_t recvUserId, std::vector &dumpInfo); #endif ErrCode SetRecentNotificationCount(const std::string arg); void UpdateRecentNotification(sptr ¬ification, bool isDelete, int32_t reason); void AdjustDateForDndTypeOnce(int64_t &beginDate, int64_t &endDate); ErrCode PrepareNotificationRequest(const sptr &request); ErrCode PrepareContinuousTaskNotificationRequest(const sptr &request, const int32_t &uid); void TriggerRemoveWantAgent(const sptr &request); bool CheckApiCompatibility(const sptr &bundleOption); ErrCode IsAllowedNotifySelf(const sptr &bundleOption, bool &allowed); ErrCode SetNotificationRemindType(sptr notification, bool isLocal); #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED std::vector GetLocalNotificationKeys(const sptr &bundleOption); NotificationConstant::RemindType GetRemindType(); ErrCode DoDistributedPublish( const sptr bundleOption, const std::shared_ptr record); ErrCode DoDistributedDelete( const std::string deviceId, const std::string bundleName, const sptr notification); void GetDistributedInfo(const std::string &key, std::string &deviceId, std::string &bundleName); bool CheckDistributedNotificationType(const sptr &request); void OnDistributedPublish( const std::string &deviceId, const std::string &bundleName, sptr &request); void OnDistributedUpdate( const std::string &deviceId, const std::string &bundleName, sptr &request); void OnDistributedDelete( const std::string &deviceId, const std::string &bundleName, const std::string &label, int32_t id); static ErrCode GetDistributedEnableInApplicationInfo( const sptr bundleOption, bool &enable); bool CheckPublishWithoutApp(const int32_t userId, const sptr &request); void InitDistributeCallBack(); #endif ErrCode SetDoNotDisturbDateByUser(const int32_t &userId, const sptr &date); ErrCode GetDoNotDisturbDateByUser(const int32_t &userId, sptr &date); ErrCode GetHasPoppedDialog(const sptr bundleOption, bool &hasPopped); static ErrCode GetAppTargetBundle(const sptr &bundleOption, sptr &targetBundle); bool PublishSlotChangeCommonEvent(const sptr &bundleOption); void ReportInfoToResourceSchedule(const int32_t userId, const std::string &bundleName); int Dump(int fd, const std::vector &args) override; void GetDumpInfo(const std::vector &args, std::string &result); static void SendSubscribeHiSysEvent(int32_t pid, int32_t uid, const sptr &info, ErrCode errCode); static void SendUnSubscribeHiSysEvent(int32_t pid, int32_t uid, const sptr &info); void SendPublishHiSysEvent(const sptr &request, ErrCode errCode); void SendCancelHiSysEvent(int32_t notificationId, const std::string &label, const sptr &bundleOption, ErrCode errCode); void SendRemoveHiSysEvent(int32_t notificationId, const std::string &label, const sptr &bundleOption, ErrCode errCode); void SendEnableNotificationHiSysEvent(const sptr &bundleOption, bool enabled, ErrCode errCode); void SendEnableNotificationSlotHiSysEvent(const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool enabled, ErrCode errCode); void SendFlowControlOccurHiSysEvent(const std::shared_ptr &record); void SendLiveViewUploadHiSysEvent(const std::shared_ptr &record, int32_t uploadStatus); ErrCode SetRequestBundleInfo(const sptr &request, int32_t uid, std::string &bundle); ErrCode PrePublishNotificationBySa(const sptr &request, int32_t uid, std::string &bundle); ErrCode PrePublishRequest(const sptr &request); ErrCode PublishNotificationBySa(const sptr &request); bool IsNeedPushCheck(const sptr &request); void FillExtraInfoToJson(const sptr &request, sptr &checkRequest, nlohmann::json &jsonObject); ErrCode PushCheck(const sptr &request); uint64_t StartAutoDelete(const std::shared_ptr &record, int64_t deleteTimePoint, int32_t reason); void TriggerAutoDelete(const std::string &hashCode, int32_t reason); void SendNotificationsOnCanceled(std::vector> ¬ifications, const sptr ¬ificationMap, int32_t deleteReason); void SetAgentNotification(sptr& notificationRequest, std::string& bundleName); ErrCode SetDefaultNotificationEnabled( const sptr &bundleOption, bool enabled); ErrCode IsAllowedNotifyForBundle(const sptr &bundleOption, bool &allowed); void AddLiveViewSubscriber(); void EraseLiveViewSubsciber(const std::string &bundleName); bool GetLiveViewSubscribeState(const std::string &bundleName); bool CheckLocalLiveViewSubscribed(const sptr &request); bool CheckLocalLiveViewAllowed(const sptr &request); static bool GetBundleInfoByNotificationBundleOption( const sptr &bundleOption, AppExecFwk::BundleInfo &bundleInfo); ErrCode GetTargetRecordList(const int32_t uid, NotificationConstant::SlotType slotType, NotificationContent::Type contentType, std::vector>& recordList); ErrCode GetCommonTargetRecordList(const int32_t uid, NotificationConstant::SlotType slotType, NotificationContent::Type contentType, std::vector>& recordList); ErrCode RemoveNotificationFromRecordList(const std::vector>& recordList); void OnSubscriberAdd(const std::shared_ptr &record); void OnSubscriberAddInffrt(const std::shared_ptr &record); bool IsLiveViewCanRecover(const sptr request); ErrCode FillNotificationRecord(const NotificationRequestDb &requestdbObj, std::shared_ptr record); static int32_t SetNotificationRequestToDb(const NotificationRequestDb &requestDb); static int32_t GetNotificationRequestFromDb(const std::string &key, NotificationRequestDb &requestDb); static int32_t GetBatchNotificationRequestsFromDb(std::vector &requests, int32_t userId = -1); static int32_t DoubleDeleteNotificationFromDb(const std::string &key, const std::string &secureKey, const int32_t userId); static int32_t DeleteNotificationRequestFromDb(const std::string &key, const int32_t userId); void CancelTimer(uint64_t timerId); void BatchCancelTimer(std::vector timerIds); ErrCode UpdateNotificationTimerInfo(const std::shared_ptr &record); ErrCode SetFinishTimer(const std::shared_ptr &record); ErrCode StartFinishTimer(const std::shared_ptr &record, int64_t expireTimePoint, const int32_t reason); void CancelFinishTimer(const std::shared_ptr &record); ErrCode SetUpdateTimer(const std::shared_ptr &record); ErrCode StartUpdateTimer(const std::shared_ptr &record, int64_t expireTimePoint, const int32_t reason); void CancelUpdateTimer(const std::shared_ptr &record); void StartArchiveTimer(const std::shared_ptr &record); void CancelArchiveTimer(const std::shared_ptr &record); ErrCode StartAutoDeletedTimer(const std::shared_ptr &record); void ProcForDeleteLiveView(const std::shared_ptr &record); ErrCode IsAllowedGetNotificationByFilter(const std::shared_ptr &record); void QueryDoNotDisturbProfile(const int32_t &userId, std::string &enable, std::string &profileId); void CheckDoNotDisturbProfile(const std::shared_ptr &record); void ReportDoNotDisturbModeChanged(const int32_t &userId, std::string &enable); void DoNotDisturbUpdataReminderFlags(const std::shared_ptr &record); ErrCode CheckCommonParams(); std::shared_ptr GetRecordFromNotificationList( int32_t notificationId, int32_t uid, const std::string &label, const std::string &bundleName); std::shared_ptr MakeNotificationRecord( const sptr &request, const sptr &bundleOption); void FillActionButtons(const sptr &request); ErrCode IsAllowedGetNotificationByFilter(const std::shared_ptr &record, const sptr &bundleOption); ErrCode FillRequestByKeys(const sptr &oldRequest, const std::vector extraInfoKeys, sptr &newRequest); ErrCode IsAllowedRemoveSlot(const sptr &bundleOption, const NotificationConstant::SlotType &slotType); void HandleBadgeEnabledChanged(const sptr &bundleOption, bool &enabled); ErrCode CheckBundleOptionValid(sptr &bundleOption); bool IsNeedNotifyConsumed(const sptr &request); ErrCode AddRecordToMemory(const std::shared_ptr &record, bool isSystemApp, bool isUpdateByOwner, const bool isAgentController); ErrCode DuplicateMsgControl(const sptr &request); void RemoveExpiredUniqueKey(); bool IsDuplicateMsg(const std::string &uniqueKey); void DeleteDuplicateMsgs(const sptr &bundleOption); ErrCode PublishRemoveDuplicateEvent(const std::shared_ptr &record); std::vector GetBundlesOfActiveUser(); ErrCode UpdateSlotAuthInfo(const std::shared_ptr &record); void FillLockScreenPicture(const sptr &newRequest, const sptr &oldRequest); ErrCode CancelAsBundleWithAgent( const sptr &bundleOption, const int32_t id, const std::string &label, int32_t userId); static ErrCode SetLockScreenPictureToDb(const sptr &request); static ErrCode GetLockScreenPictureFromDb(NotificationRequest *request); void RemoveDoNotDisturbProfileTrustList(const sptr &bundleOption); ErrCode AssignValidNotificationSlot(const std::shared_ptr &record, const sptr &bundleOption); ErrCode UpdateSlotReminderModeBySlotFlags(const sptr &bundle, uint32_t slotFlags); ErrCode CheckSoundPermission(const sptr &request, std::string bundleName); void GenerateSlotReminderMode(const sptr &slot, const sptr &bundle, bool isSpecifiedSlot = false, uint32_t defaultSlotFlags = DEFAULT_SLOT_FLAGS); static void CloseAlert(const std::shared_ptr &record); bool IsUpdateSystemLiveviewByOwner(const sptr &request); bool IsSaCreateSystemLiveViewAsBundle(const std::shared_ptr &record, int32_t ipcUid); ErrCode SaPublishSystemLiveViewAsBundle(const std::shared_ptr &record); bool IsNotificationExistsInDelayList(const std::string &key); uint64_t StartDelayPublishTimer(const int32_t ownerUid, const int32_t notificationId, const uint32_t delayTime); ErrCode StartPublishDelayedNotification(const std::shared_ptr &record); void StartPublishDelayedNotificationTimeOut(const int32_t ownerUid, const int32_t notificationId); void UpdateRecordByOwner(const std::shared_ptr &record, bool isSystemApp); ErrCode DeleteAllByUserInner(const int32_t &userId, int32_t reason, bool isAsync = false); ErrCode RemoveAllNotificationsInner(const sptr &bundleOption, int32_t reason); void RemoveNotificationList(const std::shared_ptr &record); void StartFinishTimerForUpdate(const std::shared_ptr &record, uint64_t process); ErrCode CheckLongTermLiveView(const sptr &request, const std::string &key); void ExcuteCancelGroupCancel(const sptr& bundleOption, const std::string &groupName, const int32_t reason); ErrCode ExcuteCancelAll(const sptr& bundleOption, const int32_t reason); ErrCode ExcuteDelete(const std::string &key, const int32_t removeReason); ErrCode CheckNeedSilent(const std::string &phoneNumber, int32_t callerType, int32_t userId); uint32_t GetDefaultSlotFlags(const sptr &request); bool IsSystemUser(int32_t userId); ErrCode OnRecoverLiveView(const std::vector &keys); void HandleUpdateLiveViewNotificationTimer(const int32_t uid, const bool isPaused); void CancelWantAgent(const sptr ¬ification); void CancelOnceWantAgent(const std::shared_ptr &wantAgent); private: static sptr instance_; static std::mutex instanceMutex_; static std::mutex pushMutex_; static std::map> pushCallBacks_; static std::map> checkRequests_; bool aggregateLocalSwitch_ = false; std::shared_ptr runner_ = nullptr; std::shared_ptr handler_ = nullptr; std::list> notificationList_; std::shared_ptr recentInfo_ = nullptr; std::shared_ptr distributedKvStoreDeathRecipient_ = nullptr; std::shared_ptr systemEventObserver_ = nullptr; DistributedKv::DistributedKvDataManager dataManager_; sptr pushRecipient_ = nullptr; std::shared_ptr notificationSvrQueue_ = nullptr; std::map> publishProcess_; #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED NotificationConstant::DistributedReminderPolicy distributedReminderPolicy_ = DEFAULT_DISTRIBUTED_REMINDER_POLICY; bool localScreenOn_ = true; #endif std::shared_ptr soundPermissionInfo_ = nullptr; std::shared_ptr permissonFilter_ = nullptr; std::shared_ptr notificationSlotFilter_ = nullptr; std::shared_ptr dialogManager_ = nullptr; std::list> uniqueKeyList_; std::list, uint64_t>> delayNotificationList_; std::mutex delayNotificationMutext_; static std::mutex doNotDisturbMutex_; std::map doNotDisturbEnableRecord_; }; /** * @class PushCallbackRecipient * PushCallbackRecipient notices IRemoteBroker died. */ class PushCallbackRecipient : public IRemoteObject::DeathRecipient { public: PushCallbackRecipient(); virtual ~PushCallbackRecipient(); void OnRemoteDied(const wptr &remote); }; } // namespace Notification } // namespace OHOS #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_ADVANCED_NOTIFICATION_SERVICE_H