196279301Sopenharmony_ci/* 296279301Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 496279301Sopenharmony_ci * you may not use this file except in compliance with the License. 596279301Sopenharmony_ci * You may obtain a copy of the License at 696279301Sopenharmony_ci * 796279301Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 896279301Sopenharmony_ci * 996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1296279301Sopenharmony_ci * See the License for the specific language governing permissions and 1396279301Sopenharmony_ci * limitations under the License. 1496279301Sopenharmony_ci */ 1596279301Sopenharmony_ci 1696279301Sopenharmony_ci#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H 1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H 1896279301Sopenharmony_ci 1996279301Sopenharmony_ci#include "ans_dialog_host_client.h" 2096279301Sopenharmony_ci#include "notification_bundle_option.h" 2196279301Sopenharmony_ci#include "notification_button_option.h" 2296279301Sopenharmony_ci#include "notification_do_not_disturb_date.h" 2396279301Sopenharmony_ci#include "notification_do_not_disturb_profile.h" 2496279301Sopenharmony_ci#include "enabled_notification_callback_data.h" 2596279301Sopenharmony_ci#include "notification_request.h" 2696279301Sopenharmony_ci#include "notification_slot.h" 2796279301Sopenharmony_ci#include "notification_sorting_map.h" 2896279301Sopenharmony_ci#include "notification_subscriber.h" 2996279301Sopenharmony_ci#include "notification_local_live_view_subscriber.h" 3096279301Sopenharmony_ci#include "want_params.h" 3196279301Sopenharmony_ci 3296279301Sopenharmony_cinamespace OHOS { 3396279301Sopenharmony_cinamespace Notification { 3496279301Sopenharmony_ciclass NotificationHelper { 3596279301Sopenharmony_cipublic: 3696279301Sopenharmony_ci /** 3796279301Sopenharmony_ci * @brief Creates a notification slot. 3896279301Sopenharmony_ci * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot 3996279301Sopenharmony_ci * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to 4096279301Sopenharmony_ci * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the 4196279301Sopenharmony_ci * notification published can have all the characteristics set in the NotificationSlot. After a notification slot is 4296279301Sopenharmony_ci * created by using this method, only the name and description of the notification slot can be changed. Changes to 4396279301Sopenharmony_ci * the other attributes, such as the vibration status and notification tone, will no longer take effect. 4496279301Sopenharmony_ci * 4596279301Sopenharmony_ci * @param slot Indicates the notification slot to be created, which is set by NotificationSlot. 4696279301Sopenharmony_ci * This parameter must be specified. 4796279301Sopenharmony_ci * @return Returns add notification slot result. 4896279301Sopenharmony_ci */ 4996279301Sopenharmony_ci static ErrCode AddNotificationSlot(const NotificationSlot &slot); 5096279301Sopenharmony_ci 5196279301Sopenharmony_ci /** 5296279301Sopenharmony_ci * @brief Adds a notification slot by type. 5396279301Sopenharmony_ci * 5496279301Sopenharmony_ci * @param slotType Indicates the notification slot type to be added. 5596279301Sopenharmony_ci * @return Returns add notification slot result. 5696279301Sopenharmony_ci */ 5796279301Sopenharmony_ci static ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType); 5896279301Sopenharmony_ci 5996279301Sopenharmony_ci /** 6096279301Sopenharmony_ci * @brief Creates multiple notification slots. 6196279301Sopenharmony_ci * 6296279301Sopenharmony_ci * @param slots Indicates the notification slots to create. 6396279301Sopenharmony_ci * @return Returns add notification slots result. 6496279301Sopenharmony_ci */ 6596279301Sopenharmony_ci static ErrCode AddNotificationSlots(const std::vector<NotificationSlot> &slots); 6696279301Sopenharmony_ci 6796279301Sopenharmony_ci /** 6896279301Sopenharmony_ci * @brief Deletes a created notification slot based on the slot ID. 6996279301Sopenharmony_ci * 7096279301Sopenharmony_ci * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot 7196279301Sopenharmony_ci * This parameter must be specified. 7296279301Sopenharmony_ci * @return Returns remove notification slot result. 7396279301Sopenharmony_ci */ 7496279301Sopenharmony_ci static ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType); 7596279301Sopenharmony_ci 7696279301Sopenharmony_ci /** 7796279301Sopenharmony_ci * @brief Deletes all notification slots. 7896279301Sopenharmony_ci * 7996279301Sopenharmony_ci * @return Returns remove all slots result. 8096279301Sopenharmony_ci */ 8196279301Sopenharmony_ci static ErrCode RemoveAllSlots(); 8296279301Sopenharmony_ci 8396279301Sopenharmony_ci /** 8496279301Sopenharmony_ci * @brief Update all notification slots for the specified bundle. 8596279301Sopenharmony_ci * 8696279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 8796279301Sopenharmony_ci * @param slots Indicates a list of new notification slots. 8896279301Sopenharmony_ci * @return Returns update notification slots for bundle result. 8996279301Sopenharmony_ci */ 9096279301Sopenharmony_ci static ErrCode UpdateNotificationSlots( 9196279301Sopenharmony_ci const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots); 9296279301Sopenharmony_ci 9396279301Sopenharmony_ci /** 9496279301Sopenharmony_ci * @brief Queries a created notification slot. 9596279301Sopenharmony_ci * 9696279301Sopenharmony_ci * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This 9796279301Sopenharmony_ci * parameter must be specified. 9896279301Sopenharmony_ci * @param slot Indicates the created NotificationSlot. 9996279301Sopenharmony_ci * @return Returns the get notification slot result. 10096279301Sopenharmony_ci */ 10196279301Sopenharmony_ci static ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot); 10296279301Sopenharmony_ci 10396279301Sopenharmony_ci /** 10496279301Sopenharmony_ci * @brief Obtains all notification slots of this application. 10596279301Sopenharmony_ci * @param slots Indicates the created NotificationSlot. 10696279301Sopenharmony_ci * @return Returns all notification slots of this application. 10796279301Sopenharmony_ci */ 10896279301Sopenharmony_ci static ErrCode GetNotificationSlots(std::vector<sptr<NotificationSlot>> &slots); 10996279301Sopenharmony_ci 11096279301Sopenharmony_ci /** 11196279301Sopenharmony_ci * @brief Obtains number of slot. 11296279301Sopenharmony_ci * 11396279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 11496279301Sopenharmony_ci * @param num Indicates number of slot. 11596279301Sopenharmony_ci * @return Returns get slot number by bundle result. 11696279301Sopenharmony_ci */ 11796279301Sopenharmony_ci static ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num); 11896279301Sopenharmony_ci 11996279301Sopenharmony_ci /** 12096279301Sopenharmony_ci * @brief Obtains all notification slots belonging to the specified bundle. 12196279301Sopenharmony_ci * 12296279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 12396279301Sopenharmony_ci * @param slots Indicates a list of notification slots. 12496279301Sopenharmony_ci * @return Returns get notification slots for bundle result. 12596279301Sopenharmony_ci */ 12696279301Sopenharmony_ci static ErrCode GetNotificationSlotsForBundle( 12796279301Sopenharmony_ci 12896279301Sopenharmony_ci const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots); 12996279301Sopenharmony_ci 13096279301Sopenharmony_ci /** 13196279301Sopenharmony_ci * @brief Obtains all notification slots belonging to the specified bundle. 13296279301Sopenharmony_ci * 13396279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 13496279301Sopenharmony_ci * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot. 13596279301Sopenharmony_ci * @param slot Indicates a notification slot. 13696279301Sopenharmony_ci * @return Returns get notification slots for bundle result. 13796279301Sopenharmony_ci */ 13896279301Sopenharmony_ci static ErrCode GetNotificationSlotForBundle( 13996279301Sopenharmony_ci const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, 14096279301Sopenharmony_ci sptr<NotificationSlot> &slot); 14196279301Sopenharmony_ci 14296279301Sopenharmony_ci /** 14396279301Sopenharmony_ci * Set whether the application slot is enabled. 14496279301Sopenharmony_ci * 14596279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 14696279301Sopenharmony_ci * @param slotType Indicates type of slot. 14796279301Sopenharmony_ci * @param enabled the type of slot enabled. 14896279301Sopenharmony_ci * @param isForceControl Indicates whether the slot is affected by the notification switch. 14996279301Sopenharmony_ci * @return Returns get slot number by bundle result. 15096279301Sopenharmony_ci */ 15196279301Sopenharmony_ci static ErrCode SetEnabledForBundleSlot(const NotificationBundleOption &bundleOption, 15296279301Sopenharmony_ci const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl); 15396279301Sopenharmony_ci 15496279301Sopenharmony_ci /** 15596279301Sopenharmony_ci * Obtains whether the application slot is enabled. 15696279301Sopenharmony_ci * 15796279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 15896279301Sopenharmony_ci * @param slotType Indicates type of slot. 15996279301Sopenharmony_ci * @param enabled the type of slot enabled to get. 16096279301Sopenharmony_ci * @return Returns get slot number by bundle result. 16196279301Sopenharmony_ci */ 16296279301Sopenharmony_ci static ErrCode GetEnabledForBundleSlot( 16396279301Sopenharmony_ci const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled); 16496279301Sopenharmony_ci 16596279301Sopenharmony_ci /** 16696279301Sopenharmony_ci * Obtains whether the current application slot is enabled. 16796279301Sopenharmony_ci * 16896279301Sopenharmony_ci * @param slotType Indicates type of slot. 16996279301Sopenharmony_ci * @param enabled the type of slot enabled to get. 17096279301Sopenharmony_ci * @return Returns get enabled result. 17196279301Sopenharmony_ci */ 17296279301Sopenharmony_ci static ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled); 17396279301Sopenharmony_ci 17496279301Sopenharmony_ci /** 17596279301Sopenharmony_ci * @brief Obtains slotflags of bundle. 17696279301Sopenharmony_ci * 17796279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 17896279301Sopenharmony_ci * @param slotFlags Indicates slotFlags of bundle. 17996279301Sopenharmony_ci * @return Returns get slotFlags by bundle result. 18096279301Sopenharmony_ci */ 18196279301Sopenharmony_ci static ErrCode GetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t &slotFlags); 18296279301Sopenharmony_ci 18396279301Sopenharmony_ci /** 18496279301Sopenharmony_ci * @brief set slotflags of bundle. 18596279301Sopenharmony_ci * 18696279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 18796279301Sopenharmony_ci * @param slotFlags Indicates slotFlags of bundle. 18896279301Sopenharmony_ci * @return Returns get slotFlags by bundle result. 18996279301Sopenharmony_ci */ 19096279301Sopenharmony_ci static ErrCode SetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t slotFlags); 19196279301Sopenharmony_ci 19296279301Sopenharmony_ci /** 19396279301Sopenharmony_ci * @brief Publishes a notification. 19496279301Sopenharmony_ci * @note If a notification with the same ID has been published by the current application and has not been deleted, 19596279301Sopenharmony_ci * this method will update the notification. 19696279301Sopenharmony_ci * 19796279301Sopenharmony_ci * @param request Indicates the NotificationRequest object for setting the notification content. 19896279301Sopenharmony_ci * This parameter must be specified. 19996279301Sopenharmony_ci * @return Returns publish notification result. 20096279301Sopenharmony_ci */ 20196279301Sopenharmony_ci static ErrCode PublishNotification(const NotificationRequest &request); 20296279301Sopenharmony_ci 20396279301Sopenharmony_ci /** 20496279301Sopenharmony_ci * @brief Publishes a notification. 20596279301Sopenharmony_ci * @note If a notification with the same ID has been published by the current application and has not been deleted, 20696279301Sopenharmony_ci * this method will update the notification. 20796279301Sopenharmony_ci * 20896279301Sopenharmony_ci * @param request Indicates the NotificationRequest object for setting the notification content. 20996279301Sopenharmony_ci * This parameter must be specified. 21096279301Sopenharmony_ci * @return Returns publish notification result. 21196279301Sopenharmony_ci */ 21296279301Sopenharmony_ci static ErrCode PublishNotificationForIndirectProxy(const NotificationRequest &request); 21396279301Sopenharmony_ci 21496279301Sopenharmony_ci /** 21596279301Sopenharmony_ci * @brief Publishes a notification with a specified label. 21696279301Sopenharmony_ci * @note If a notification with the same ID has been published by the current application and has not been deleted, 21796279301Sopenharmony_ci * this method will update the notification. 21896279301Sopenharmony_ci * 21996279301Sopenharmony_ci * @param label Indicates the label of the notification to publish. 22096279301Sopenharmony_ci * @param request Indicates the NotificationRequest object for setting the notification content. 22196279301Sopenharmony_ci * This parameter must be specified. 22296279301Sopenharmony_ci * @return Returns publish notification result. 22396279301Sopenharmony_ci */ 22496279301Sopenharmony_ci static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request); 22596279301Sopenharmony_ci 22696279301Sopenharmony_ci /** 22796279301Sopenharmony_ci * @brief Cancels a published notification. 22896279301Sopenharmony_ci * 22996279301Sopenharmony_ci * @param notificationId Indicates the unique notification ID in the application. 23096279301Sopenharmony_ci * The value must be the ID of a published notification. 23196279301Sopenharmony_ci * Otherwise, this method does not take effect. 23296279301Sopenharmony_ci * @return Returns cancel notification result. 23396279301Sopenharmony_ci */ 23496279301Sopenharmony_ci static ErrCode CancelNotification(int32_t notificationId); 23596279301Sopenharmony_ci 23696279301Sopenharmony_ci /** 23796279301Sopenharmony_ci * @brief Cancels a published notification matching the specified label and notificationId. 23896279301Sopenharmony_ci * 23996279301Sopenharmony_ci * @param label Indicates the label of the notification to cancel. 24096279301Sopenharmony_ci * @param notificationId Indicates the ID of the notification to cancel. 24196279301Sopenharmony_ci * @return Returns cancel notification result. 24296279301Sopenharmony_ci */ 24396279301Sopenharmony_ci static ErrCode CancelNotification(const std::string &label, int32_t notificationId); 24496279301Sopenharmony_ci 24596279301Sopenharmony_ci /** 24696279301Sopenharmony_ci * @brief Cancels all the published notifications. 24796279301Sopenharmony_ci * 24896279301Sopenharmony_ci * @note To cancel a specified notification, see CancelNotification(int32_t). 24996279301Sopenharmony_ci * @return Returns cancel all notifications result. 25096279301Sopenharmony_ci */ 25196279301Sopenharmony_ci static ErrCode CancelAllNotifications(); 25296279301Sopenharmony_ci 25396279301Sopenharmony_ci /** 25496279301Sopenharmony_ci * @brief Cancels a published agent notification. 25596279301Sopenharmony_ci * 25696279301Sopenharmony_ci * @param notificationId Indicates the unique notification ID in the application. 25796279301Sopenharmony_ci * The value must be the ID of a published notification. 25896279301Sopenharmony_ci * Otherwise, this method does not take effect. 25996279301Sopenharmony_ci * @param representativeBundle Indicates the name of application bundle your application is representing. 26096279301Sopenharmony_ci * @param userId Indicates the specific user. 26196279301Sopenharmony_ci * @return Returns cancel notification result. 26296279301Sopenharmony_ci */ 26396279301Sopenharmony_ci static ErrCode CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId); 26496279301Sopenharmony_ci 26596279301Sopenharmony_ci /** 26696279301Sopenharmony_ci * @brief Cancels a published agent notification. 26796279301Sopenharmony_ci * 26896279301Sopenharmony_ci * @param bundleOption Indicates the bundle of application bundle your application is representing. 26996279301Sopenharmony_ci * @param notificationId Indicates the unique notification ID in the application. 27096279301Sopenharmony_ci * The value must be the ID of a published notification. 27196279301Sopenharmony_ci * Otherwise, this method does not take effect. 27296279301Sopenharmony_ci * @return Returns cancel notification result. 27396279301Sopenharmony_ci */ 27496279301Sopenharmony_ci static ErrCode CancelAsBundle(const NotificationBundleOption &bundleOption, int32_t notificationId); 27596279301Sopenharmony_ci 27696279301Sopenharmony_ci /** 27796279301Sopenharmony_ci * @brief Obtains the number of active notifications of the current application in the system. 27896279301Sopenharmony_ci * 27996279301Sopenharmony_ci * @param nums Indicates the number of active notifications of the current application. 28096279301Sopenharmony_ci * @return Returns get active notification nums result. 28196279301Sopenharmony_ci */ 28296279301Sopenharmony_ci static ErrCode GetActiveNotificationNums(uint64_t &num); 28396279301Sopenharmony_ci 28496279301Sopenharmony_ci /** 28596279301Sopenharmony_ci * @brief Obtains active notifications of the current application in the system. 28696279301Sopenharmony_ci * 28796279301Sopenharmony_ci * @param request Indicates active NotificationRequest objects of the current application. 28896279301Sopenharmony_ci * @return Returns get active notifications result. 28996279301Sopenharmony_ci */ 29096279301Sopenharmony_ci static ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &request); 29196279301Sopenharmony_ci 29296279301Sopenharmony_ci /** 29396279301Sopenharmony_ci * @brief Allows another application to act as an agent to publish notifications in the name of your application 29496279301Sopenharmony_ci * bundle. 29596279301Sopenharmony_ci * 29696279301Sopenharmony_ci * @param agent Indicates the name of the application bundle that can publish notifications for your application. 29796279301Sopenharmony_ci * @return Returns set notification agent result. 29896279301Sopenharmony_ci */ 29996279301Sopenharmony_ci static ErrCode SetNotificationAgent(const std::string &agent); 30096279301Sopenharmony_ci 30196279301Sopenharmony_ci /** 30296279301Sopenharmony_ci * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. 30396279301Sopenharmony_ci * 30496279301Sopenharmony_ci * @param agent Indicates the name of the application bundle that can publish notifications for your application if 30596279301Sopenharmony_ci * any; returns null otherwise. 30696279301Sopenharmony_ci * @return Returns get notification agent result. 30796279301Sopenharmony_ci */ 30896279301Sopenharmony_ci static ErrCode GetNotificationAgent(std::string &agent); 30996279301Sopenharmony_ci 31096279301Sopenharmony_ci /** 31196279301Sopenharmony_ci * @brief Checks whether your application has permission to publish notifications by calling 31296279301Sopenharmony_ci * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the 31396279301Sopenharmony_ci * given representativeBundle. 31496279301Sopenharmony_ci * 31596279301Sopenharmony_ci * @param representativeBundle Indicates the name of application bundle your application is representing. 31696279301Sopenharmony_ci * @param canPublish Indicates whether your application has permission to publish notifications. 31796279301Sopenharmony_ci * @return Returns can publish notification as bundle result. 31896279301Sopenharmony_ci */ 31996279301Sopenharmony_ci static ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish); 32096279301Sopenharmony_ci 32196279301Sopenharmony_ci /** 32296279301Sopenharmony_ci * @brief Publishes a notification in the name of a specified application bundle. 32396279301Sopenharmony_ci * @note If the notification to be published has the same ID as a published notification that has not been canceled, 32496279301Sopenharmony_ci * the existing notification will be replaced by the new one. 32596279301Sopenharmony_ci * 32696279301Sopenharmony_ci * @param request Indicates the NotificationRequest object for setting the notification content. 32796279301Sopenharmony_ci * This parameter must be specified. 32896279301Sopenharmony_ci * @param representativeBundle Indicates the name of the application bundle that allows your application to publish 32996279301Sopenharmony_ci * notifications for it by calling setNotificationAgent. 33096279301Sopenharmony_ci * @return Returns publish notification as bundle result. 33196279301Sopenharmony_ci */ 33296279301Sopenharmony_ci static ErrCode PublishNotificationAsBundle( 33396279301Sopenharmony_ci const std::string &representativeBundle, const NotificationRequest &request); 33496279301Sopenharmony_ci 33596279301Sopenharmony_ci /** 33696279301Sopenharmony_ci * @brief Sets the number of active notifications of the current application as the number to be displayed on the 33796279301Sopenharmony_ci * notification badge. 33896279301Sopenharmony_ci * 33996279301Sopenharmony_ci * @return Returns set notification badge num result. 34096279301Sopenharmony_ci */ 34196279301Sopenharmony_ci static ErrCode SetNotificationBadgeNum(); 34296279301Sopenharmony_ci 34396279301Sopenharmony_ci /** 34496279301Sopenharmony_ci * @brief Sets the number to be displayed on the notification badge of the application. 34596279301Sopenharmony_ci * 34696279301Sopenharmony_ci * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged. 34796279301Sopenharmony_ci * The value 0 indicates that no badge is displayed on the application icon. 34896279301Sopenharmony_ci * If the value is greater than 99, 99+ will be displayed. 34996279301Sopenharmony_ci * @return Returns set notification badge num result. 35096279301Sopenharmony_ci */ 35196279301Sopenharmony_ci static ErrCode SetNotificationBadgeNum(int32_t num); 35296279301Sopenharmony_ci 35396279301Sopenharmony_ci /** 35496279301Sopenharmony_ci * @brief Checks whether this application has permission to publish notifications. The caller must have 35596279301Sopenharmony_ci * system permissions to call this method. 35696279301Sopenharmony_ci * 35796279301Sopenharmony_ci * @param allowed True if this application has the permission; returns false otherwise 35896279301Sopenharmony_ci * @return Returns is allowed notify result. 35996279301Sopenharmony_ci */ 36096279301Sopenharmony_ci static ErrCode IsAllowedNotify(bool &allowed); 36196279301Sopenharmony_ci 36296279301Sopenharmony_ci /** 36396279301Sopenharmony_ci * @brief Checks whether this application has permission to publish notifications. 36496279301Sopenharmony_ci * 36596279301Sopenharmony_ci * @param allowed True if this application has the permission; returns false otherwise 36696279301Sopenharmony_ci * @return Returns is allowed notify result. 36796279301Sopenharmony_ci */ 36896279301Sopenharmony_ci static ErrCode IsAllowedNotifySelf(bool &allowed); 36996279301Sopenharmony_ci 37096279301Sopenharmony_ci /** 37196279301Sopenharmony_ci * @brief Checks whether this application can pop enable notification dialog. 37296279301Sopenharmony_ci * 37396279301Sopenharmony_ci * @param canPop True if can pop enable notification dialog 37496279301Sopenharmony_ci * @return Returns is canPop result. 37596279301Sopenharmony_ci */ 37696279301Sopenharmony_ci static ErrCode CanPopEnableNotificationDialog(sptr<AnsDialogHostClient> &hostClient, 37796279301Sopenharmony_ci bool &canPop, std::string &bundleName); 37896279301Sopenharmony_ci 37996279301Sopenharmony_ci /** 38096279301Sopenharmony_ci * @brief remove enable notification dialog. 38196279301Sopenharmony_ci * 38296279301Sopenharmony_ci * @return Returns remove dialog result. 38396279301Sopenharmony_ci */ 38496279301Sopenharmony_ci static ErrCode RemoveEnableNotificationDialog(); 38596279301Sopenharmony_ci 38696279301Sopenharmony_ci /** 38796279301Sopenharmony_ci * @brief Allow the current application to publish notifications on a specified device. 38896279301Sopenharmony_ci * 38996279301Sopenharmony_ci * @param deviceId Indicates the ID of the device running the application. At present, this parameter can 39096279301Sopenharmony_ci * only be null or an empty string, indicating the current device. 39196279301Sopenharmony_ci * @return Returns set notifications enabled for default bundle result. 39296279301Sopenharmony_ci */ 39396279301Sopenharmony_ci static ErrCode RequestEnableNotification(std::string &deviceId, 39496279301Sopenharmony_ci sptr<AnsDialogHostClient> &hostClient, 39596279301Sopenharmony_ci sptr<IRemoteObject> &callerToken); 39696279301Sopenharmony_ci 39796279301Sopenharmony_ci /** 39896279301Sopenharmony_ci * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. 39996279301Sopenharmony_ci * 40096279301Sopenharmony_ci * @param hasPermission True if this application is suspended; false otherwise. 40196279301Sopenharmony_ci * @return Returns has notification policy access permission. 40296279301Sopenharmony_ci */ 40396279301Sopenharmony_ci static ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission); 40496279301Sopenharmony_ci 40596279301Sopenharmony_ci /** 40696279301Sopenharmony_ci * @brief Obtains the importance level of this application. 40796279301Sopenharmony_ci * 40896279301Sopenharmony_ci * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, 40996279301Sopenharmony_ci LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. 41096279301Sopenharmony_ci * @return Returns get bundle importance result 41196279301Sopenharmony_ci */ 41296279301Sopenharmony_ci static ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance); 41396279301Sopenharmony_ci 41496279301Sopenharmony_ci /** 41596279301Sopenharmony_ci * @brief Subscribes to notifications from all applications. This method can be called only by applications 41696279301Sopenharmony_ci * with required system permissions. 41796279301Sopenharmony_ci * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 41896279301Sopenharmony_ci * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 41996279301Sopenharmony_ci * After the notification is published, subscribers that meet the filter criteria can receive the 42096279301Sopenharmony_ci * notification. To subscribe to notifications published only by specified sources, for example, 42196279301Sopenharmony_ci * notifications from certain applications, 42296279301Sopenharmony_ci * call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method. 42396279301Sopenharmony_ci * 42496279301Sopenharmony_ci * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 42596279301Sopenharmony_ci * This parameter must be specified. 42696279301Sopenharmony_ci * @return Returns unsubscribe notification result. 42796279301Sopenharmony_ci */ 42896279301Sopenharmony_ci static ErrCode SubscribeNotification(const NotificationSubscriber &subscriber); 42996279301Sopenharmony_ci 43096279301Sopenharmony_ci /** 43196279301Sopenharmony_ci * @brief Subscribes to notifications from the appliaction self. 43296279301Sopenharmony_ci * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 43396279301Sopenharmony_ci * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 43496279301Sopenharmony_ci * After the notification is published, subscribers that meet the filter criteria can receive the 43596279301Sopenharmony_ci * notification. 43696279301Sopenharmony_ci * 43796279301Sopenharmony_ci * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 43896279301Sopenharmony_ci * This parameter must be specified. 43996279301Sopenharmony_ci * @return Returns unsubscribe notification result. 44096279301Sopenharmony_ci */ 44196279301Sopenharmony_ci static ErrCode SubscribeNotificationSelf(const NotificationSubscriber &subscriber); 44296279301Sopenharmony_ci 44396279301Sopenharmony_ci /** 44496279301Sopenharmony_ci * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only 44596279301Sopenharmony_ci * by applications with required system permissions. 44696279301Sopenharmony_ci * @note After {subscribeInfo} is specified, a subscriber receives only the notifications that 44796279301Sopenharmony_ci * meet the filter criteria specified by {subscribeInfo}. 44896279301Sopenharmony_ci * To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 44996279301Sopenharmony_ci * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 45096279301Sopenharmony_ci * After the notification is published, subscribers that meet the filter criteria can receive the 45196279301Sopenharmony_ci * notification. To subscribe to and receive all notifications, call the 45296279301Sopenharmony_ci * {SubscribeNotification(NotificationSubscriber)} method. 45396279301Sopenharmony_ci * 45496279301Sopenharmony_ci * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified. 45596279301Sopenharmony_ci * For details, see {NotificationSubscriber}. 45696279301Sopenharmony_ci * @param subscribeInfo Indicates the filters for specified notification sources, including application name, 45796279301Sopenharmony_ci * user ID, or device name. This parameter is optional. 45896279301Sopenharmony_ci * @return Returns subscribe notification result. 45996279301Sopenharmony_ci */ 46096279301Sopenharmony_ci static ErrCode SubscribeNotification( 46196279301Sopenharmony_ci const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo); 46296279301Sopenharmony_ci 46396279301Sopenharmony_ci /** 46496279301Sopenharmony_ci * @brief Subscribes the localLiveView button click. This method can be called only 46596279301Sopenharmony_ci * by applications with required system permissions. 46696279301Sopenharmony_ci * @note To subscribe to a button click, inherit the {NotificationLocalLiveViewSubscriber} class, override its 46796279301Sopenharmony_ci * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 46896279301Sopenharmony_ci * After the button is clicked, subscribers that meet the filter criteria can receive the response 46996279301Sopenharmony_ci * 47096279301Sopenharmony_ci * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified. 47196279301Sopenharmony_ci * For details, see {NotificationSubscriber}. 47296279301Sopenharmony_ci * @return Returns subscribe notification result. 47396279301Sopenharmony_ci */ 47496279301Sopenharmony_ci static ErrCode SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber, 47596279301Sopenharmony_ci const bool isNative = true); 47696279301Sopenharmony_ci 47796279301Sopenharmony_ci /** 47896279301Sopenharmony_ci * @brief Unsubscribes from all notifications. This method can be called only by applications with required 47996279301Sopenharmony_ci * system permissions. 48096279301Sopenharmony_ci * @note Generally, you subscribe to a notification by calling the 48196279301Sopenharmony_ci * {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application 48296279301Sopenharmony_ci * to receive a notification any longer, unsubscribe from that notification using this method. 48396279301Sopenharmony_ci * You can unsubscribe from only those notifications that your application has subscribed to. 48496279301Sopenharmony_ci * To unsubscribe from notifications published only by specified sources, for example, 48596279301Sopenharmony_ci * notifications from certain applications, call the 48696279301Sopenharmony_ci * {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method. 48796279301Sopenharmony_ci * 48896279301Sopenharmony_ci * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 48996279301Sopenharmony_ci * This parameter must be specified. 49096279301Sopenharmony_ci * @return Returns unsubscribe notification result. 49196279301Sopenharmony_ci */ 49296279301Sopenharmony_ci static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber); 49396279301Sopenharmony_ci 49496279301Sopenharmony_ci /** 49596279301Sopenharmony_ci * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called 49696279301Sopenharmony_ci * only by applications with required system permissions. 49796279301Sopenharmony_ci * @note A subscriber will no longer receive the notifications from specified notification sources. 49896279301Sopenharmony_ci * 49996279301Sopenharmony_ci * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 50096279301Sopenharmony_ci * This parameter must be specified. 50196279301Sopenharmony_ci * @param subscribeInfo Indicates the filters for , including application name, 50296279301Sopenharmony_ci * user ID, or device name. This parameter is optional. 50396279301Sopenharmony_ci * @return Returns unsubscribe notification result. 50496279301Sopenharmony_ci */ 50596279301Sopenharmony_ci static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo); 50696279301Sopenharmony_ci 50796279301Sopenharmony_ci /** 50896279301Sopenharmony_ci * @brief Trigger the local live view after the button has been clicked. 50996279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 51096279301Sopenharmony_ci * 51196279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. 51296279301Sopenharmony_ci * @param notificationId Indicates the id of the notification. 51396279301Sopenharmony_ci * @param buttonOption Indicates which button has been clicked. 51496279301Sopenharmony_ci * @return Returns trigger localLiveView result. 51596279301Sopenharmony_ci */ 51696279301Sopenharmony_ci static ErrCode TriggerLocalLiveView(const NotificationBundleOption &bundleOption, 51796279301Sopenharmony_ci const int32_t notificationId, const NotificationButtonOption &buttonOption); 51896279301Sopenharmony_ci 51996279301Sopenharmony_ci /** 52096279301Sopenharmony_ci * @brief Removes a specified removable notification of other applications. 52196279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 52296279301Sopenharmony_ci * 52396279301Sopenharmony_ci * @param key Indicates the key of the notification to remove. 52496279301Sopenharmony_ci * @param removeReason Indicates the reason of remove notification. 52596279301Sopenharmony_ci * @return Returns remove notification result. 52696279301Sopenharmony_ci */ 52796279301Sopenharmony_ci static ErrCode RemoveNotification(const std::string &key, int32_t removeReason); 52896279301Sopenharmony_ci 52996279301Sopenharmony_ci /** 53096279301Sopenharmony_ci * @brief Removes a specified removable notification of other applications. 53196279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 53296279301Sopenharmony_ci * 53396279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. 53496279301Sopenharmony_ci * @param notificationId Indicates the id of the notification to remove. 53596279301Sopenharmony_ci * @param label Indicates the label of the notification to remove. 53696279301Sopenharmony_ci * @param removeReason Indicates the reason of remove notification. 53796279301Sopenharmony_ci * @return Returns remove notification result. 53896279301Sopenharmony_ci */ 53996279301Sopenharmony_ci static ErrCode RemoveNotification(const NotificationBundleOption &bundleOption, 54096279301Sopenharmony_ci const int32_t notificationId, const std::string &label, int32_t removeReason); 54196279301Sopenharmony_ci 54296279301Sopenharmony_ci /** 54396279301Sopenharmony_ci * @brief Removes a specified removable notification of other applications. 54496279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 54596279301Sopenharmony_ci * 54696279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. 54796279301Sopenharmony_ci * @return Returns remove notification result. 54896279301Sopenharmony_ci */ 54996279301Sopenharmony_ci static ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption); 55096279301Sopenharmony_ci 55196279301Sopenharmony_ci static ErrCode RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason); 55296279301Sopenharmony_ci 55396279301Sopenharmony_ci /** 55496279301Sopenharmony_ci * @brief Removes all removable notifications of a specified bundle. 55596279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 55696279301Sopenharmony_ci * 55796279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. 55896279301Sopenharmony_ci * @return Returns remove notifications result. 55996279301Sopenharmony_ci */ 56096279301Sopenharmony_ci static ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption); 56196279301Sopenharmony_ci 56296279301Sopenharmony_ci /** 56396279301Sopenharmony_ci * @brief Removes all removable notifications in the system. 56496279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 56596279301Sopenharmony_ci * @return Returns remove notifications result. 56696279301Sopenharmony_ci */ 56796279301Sopenharmony_ci static ErrCode RemoveNotifications(); 56896279301Sopenharmony_ci 56996279301Sopenharmony_ci /** 57096279301Sopenharmony_ci * @brief Obtains all active notifications in the current system. The caller must have system permissions to 57196279301Sopenharmony_ci * call this method. 57296279301Sopenharmony_ci * 57396279301Sopenharmony_ci * @param notification Indicates all active notifications of this application. 57496279301Sopenharmony_ci * @return Returns get all active notifications 57596279301Sopenharmony_ci */ 57696279301Sopenharmony_ci static ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ification); 57796279301Sopenharmony_ci 57896279301Sopenharmony_ci /** 57996279301Sopenharmony_ci * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method 58096279301Sopenharmony_ci * to obtain particular active notifications, you must have received the notifications and obtained the key 58196279301Sopenharmony_ci * via {Notification::GetKey()}. 58296279301Sopenharmony_ci * 58396279301Sopenharmony_ci * @param key Indicates the key array for querying corresponding active notifications. 58496279301Sopenharmony_ci * If this parameter is null, this method returns all active notifications in the system. 58596279301Sopenharmony_ci * @param notification Indicates the set of active notifications corresponding to the specified key. 58696279301Sopenharmony_ci * @return Returns get all active notifications. 58796279301Sopenharmony_ci */ 58896279301Sopenharmony_ci static ErrCode GetAllActiveNotifications( 58996279301Sopenharmony_ci const std::vector<std::string> key, std::vector<sptr<Notification>> ¬ification); 59096279301Sopenharmony_ci 59196279301Sopenharmony_ci /** 59296279301Sopenharmony_ci * @brief Obtains the active notifications by filter. 59396279301Sopenharmony_ci * @param filter 59496279301Sopenharmony_ci * @param extraInfo 59596279301Sopenharmony_ci * @return 59696279301Sopenharmony_ci */ 59796279301Sopenharmony_ci static ErrCode GetActiveNotificationByFilter( 59896279301Sopenharmony_ci const LiveViewFilter &filter, sptr<NotificationRequest> &request); 59996279301Sopenharmony_ci 60096279301Sopenharmony_ci /** 60196279301Sopenharmony_ci * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies 60296279301Sopenharmony_ci * the current application, no permission is required for calling this method. If bundle specifies another 60396279301Sopenharmony_ci * application, the caller must have system permissions. 60496279301Sopenharmony_ci * 60596279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 60696279301Sopenharmony_ci * @param allowed True if the application has permissions; false otherwise. 60796279301Sopenharmony_ci * @return Returns is allowed notify result. 60896279301Sopenharmony_ci */ 60996279301Sopenharmony_ci static ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed); 61096279301Sopenharmony_ci 61196279301Sopenharmony_ci /** 61296279301Sopenharmony_ci * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must 61396279301Sopenharmony_ci * have system permissions to call this method. 61496279301Sopenharmony_ci * 61596279301Sopenharmony_ci * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only 61696279301Sopenharmony_ci * be null or an empty string, indicating the current device. 61796279301Sopenharmony_ci * @param enabled Specifies whether to allow all applications to publish notifications. The value true 61896279301Sopenharmony_ci * indicates that notifications are allowed, and the value false indicates that notifications 61996279301Sopenharmony_ci * are not allowed. 62096279301Sopenharmony_ci * @return Returns set notifications enabled for all bundles result. 62196279301Sopenharmony_ci */ 62296279301Sopenharmony_ci static ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled); 62396279301Sopenharmony_ci 62496279301Sopenharmony_ci /** 62596279301Sopenharmony_ci * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller 62696279301Sopenharmony_ci * must have system permissions to call this method. 62796279301Sopenharmony_ci * 62896279301Sopenharmony_ci * @param deviceId Indicates the ID of the device running the application. At present, this parameter can 62996279301Sopenharmony_ci * only be null or an empty string, indicating the current device. 63096279301Sopenharmony_ci * @param enabled Specifies whether to allow the current application to publish notifications. The value 63196279301Sopenharmony_ci * true indicates that notifications are allowed, and the value false indicates that 63296279301Sopenharmony_ci * notifications are not allowed. 63396279301Sopenharmony_ci * @return Returns set notifications enabled for default bundle result. 63496279301Sopenharmony_ci */ 63596279301Sopenharmony_ci static ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled); 63696279301Sopenharmony_ci 63796279301Sopenharmony_ci /** 63896279301Sopenharmony_ci * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller 63996279301Sopenharmony_ci * must have system permissions to call this method. 64096279301Sopenharmony_ci * 64196279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 64296279301Sopenharmony_ci * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only 64396279301Sopenharmony_ci * be null or an empty string, indicating the current device. 64496279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to publish notifications. The value 64596279301Sopenharmony_ci * true indicates that notifications are allowed, and the value false indicates that notifications 64696279301Sopenharmony_ci * are not allowed. 64796279301Sopenharmony_ci * @return Returns set notifications enabled for specified bundle result. 64896279301Sopenharmony_ci */ 64996279301Sopenharmony_ci static ErrCode SetNotificationsEnabledForSpecifiedBundle( 65096279301Sopenharmony_ci const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled); 65196279301Sopenharmony_ci 65296279301Sopenharmony_ci /** 65396279301Sopenharmony_ci * @brief Sets whether to allow a specified application to show badge. 65496279301Sopenharmony_ci * 65596279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 65696279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to show badge. 65796279301Sopenharmony_ci * @return Returns set result. 65896279301Sopenharmony_ci */ 65996279301Sopenharmony_ci static ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled); 66096279301Sopenharmony_ci 66196279301Sopenharmony_ci /** 66296279301Sopenharmony_ci * @brief Obtains the flag that whether to allow a specified application to show badge. 66396279301Sopenharmony_ci * 66496279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 66596279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to show badge. 66696279301Sopenharmony_ci * @return Returns get result. 66796279301Sopenharmony_ci */ 66896279301Sopenharmony_ci static ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled); 66996279301Sopenharmony_ci 67096279301Sopenharmony_ci /** 67196279301Sopenharmony_ci * @brief Obtains the flag that whether to allow the current application to show badge. 67296279301Sopenharmony_ci * 67396279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to show badge. 67496279301Sopenharmony_ci * @return Returns get result. 67596279301Sopenharmony_ci */ 67696279301Sopenharmony_ci static ErrCode GetShowBadgeEnabled(bool &enabled); 67796279301Sopenharmony_ci 67896279301Sopenharmony_ci /** 67996279301Sopenharmony_ci * @brief Cancel the notification of the specified group of this application. 68096279301Sopenharmony_ci * 68196279301Sopenharmony_ci * @param groupName Indicates the specified group name. 68296279301Sopenharmony_ci * @return Returns cancel group result. 68396279301Sopenharmony_ci */ 68496279301Sopenharmony_ci static ErrCode CancelGroup(const std::string &groupName); 68596279301Sopenharmony_ci 68696279301Sopenharmony_ci /** 68796279301Sopenharmony_ci * @brief Remove the notification of the specified group of the specified application. 68896279301Sopenharmony_ci * 68996279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the specified application. 69096279301Sopenharmony_ci * @param groupName Indicates the specified group name. 69196279301Sopenharmony_ci * @return Returns remove group by bundle result. 69296279301Sopenharmony_ci */ 69396279301Sopenharmony_ci static ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName); 69496279301Sopenharmony_ci 69596279301Sopenharmony_ci /** 69696279301Sopenharmony_ci * @brief Sets the do not disturb time. 69796279301Sopenharmony_ci * @note Your application must have system signature to call this method. 69896279301Sopenharmony_ci * 69996279301Sopenharmony_ci * @param doNotDisturbDate Indicates the do not disturb time to set. 70096279301Sopenharmony_ci * @return Returns set do not disturb time result. 70196279301Sopenharmony_ci */ 70296279301Sopenharmony_ci static ErrCode SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate); 70396279301Sopenharmony_ci 70496279301Sopenharmony_ci /** 70596279301Sopenharmony_ci * @brief Obtains the do not disturb time. 70696279301Sopenharmony_ci * @note Your application must have system signature to call this method. 70796279301Sopenharmony_ci * 70896279301Sopenharmony_ci * @param doNotDisturbDate Indicates the do not disturb time to get. 70996279301Sopenharmony_ci * @return Returns set do not disturb time result. 71096279301Sopenharmony_ci */ 71196279301Sopenharmony_ci static ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate); 71296279301Sopenharmony_ci 71396279301Sopenharmony_ci /** 71496279301Sopenharmony_ci * @brief Obtains the flag that whether to support do not disturb mode. 71596279301Sopenharmony_ci * 71696279301Sopenharmony_ci * @param doesSupport Specifies whether to support do not disturb mode. 71796279301Sopenharmony_ci * @return Returns check result. 71896279301Sopenharmony_ci */ 71996279301Sopenharmony_ci static ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport); 72096279301Sopenharmony_ci 72196279301Sopenharmony_ci /** 72296279301Sopenharmony_ci * @brief Is coming call need silent in do not disturb mode. 72396279301Sopenharmony_ci * 72496279301Sopenharmony_ci * @param phoneNumber the calling format number. 72596279301Sopenharmony_ci * @return Returns silent in do not disturb mode. 72696279301Sopenharmony_ci */ 72796279301Sopenharmony_ci static ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType); 72896279301Sopenharmony_ci 72996279301Sopenharmony_ci /** 73096279301Sopenharmony_ci * @brief Check if the device supports distributed notification. 73196279301Sopenharmony_ci * 73296279301Sopenharmony_ci * @param enabled True if the device supports distributed notification; false otherwise. 73396279301Sopenharmony_ci * @return Returns is distributed enabled result. 73496279301Sopenharmony_ci */ 73596279301Sopenharmony_ci static ErrCode IsDistributedEnabled(bool &enabled); 73696279301Sopenharmony_ci 73796279301Sopenharmony_ci /** 73896279301Sopenharmony_ci * @brief Set whether the device supports distributed notifications. 73996279301Sopenharmony_ci * 74096279301Sopenharmony_ci * @param enable Specifies whether to enable the device to support distributed notification. 74196279301Sopenharmony_ci * The value true indicates that the device is enabled to support distributed notifications, and 74296279301Sopenharmony_ci * the value false indicates that the device is forbidden to support distributed notifications. 74396279301Sopenharmony_ci * @return Returns enable distributed result. 74496279301Sopenharmony_ci */ 74596279301Sopenharmony_ci static ErrCode EnableDistributed(const bool enabled); 74696279301Sopenharmony_ci 74796279301Sopenharmony_ci /** 74896279301Sopenharmony_ci * @brief Set whether an application supports distributed notifications. 74996279301Sopenharmony_ci * 75096279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of an application. 75196279301Sopenharmony_ci * @param enabled Specifies whether to enable an application to support distributed notification. 75296279301Sopenharmony_ci * The value true indicates that the application is enabled to support distributed notifications, 75396279301Sopenharmony_ci * and the value false indicates that the application is forbidden to support distributed 75496279301Sopenharmony_ci * notifications. 75596279301Sopenharmony_ci * @return Returns enable distributed by bundle result. 75696279301Sopenharmony_ci */ 75796279301Sopenharmony_ci static ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled); 75896279301Sopenharmony_ci 75996279301Sopenharmony_ci /** 76096279301Sopenharmony_ci * @brief Set whether this application supports distributed notifications. 76196279301Sopenharmony_ci * 76296279301Sopenharmony_ci * @param enabled Specifies whether to enable this application to support distributed notification. 76396279301Sopenharmony_ci * The value true indicates that this application is enabled to support distributed notifications, 76496279301Sopenharmony_ci * and the value false indicates that this application is forbidden to support distributed 76596279301Sopenharmony_ci * notifications. 76696279301Sopenharmony_ci * @return Returns enable distributed self result. 76796279301Sopenharmony_ci */ 76896279301Sopenharmony_ci static ErrCode EnableDistributedSelf(const bool enabled); 76996279301Sopenharmony_ci 77096279301Sopenharmony_ci /** 77196279301Sopenharmony_ci * @brief Check whether an application supports distributed notifications. 77296279301Sopenharmony_ci * 77396279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of an application. 77496279301Sopenharmony_ci * @param enabled True if the application supports distributed notification; false otherwise. 77596279301Sopenharmony_ci * @return Returns is distributed enabled by bundle result. 77696279301Sopenharmony_ci */ 77796279301Sopenharmony_ci static ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled); 77896279301Sopenharmony_ci 77996279301Sopenharmony_ci /** 78096279301Sopenharmony_ci * @brief Obtains the device remind type. 78196279301Sopenharmony_ci * @note Your application must have system signature to call this method. 78296279301Sopenharmony_ci * 78396279301Sopenharmony_ci * @param remindType Indicates the device remind type to get. 78496279301Sopenharmony_ci * @return Returns get device reminder type result. 78596279301Sopenharmony_ci */ 78696279301Sopenharmony_ci static ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType); 78796279301Sopenharmony_ci 78896279301Sopenharmony_ci /** 78996279301Sopenharmony_ci * @brief Publishes a continuous task notification. 79096279301Sopenharmony_ci * @param request Indicates the NotificationRequest object for setting the notification content. 79196279301Sopenharmony_ci * This parameter must be specified. 79296279301Sopenharmony_ci * @return Returns publish continuous task notification result. 79396279301Sopenharmony_ci */ 79496279301Sopenharmony_ci static ErrCode PublishContinuousTaskNotification(const NotificationRequest &request); 79596279301Sopenharmony_ci 79696279301Sopenharmony_ci /** 79796279301Sopenharmony_ci * @brief Cancels a published continuous task notification matching the specified label and notificationId. 79896279301Sopenharmony_ci * 79996279301Sopenharmony_ci * @param label Indicates the label of the continuous task notification to cancel. 80096279301Sopenharmony_ci * @param notificationId Indicates the ID of the continuous task notification to cancel. 80196279301Sopenharmony_ci * @return Returns cancel continuous task notification result. 80296279301Sopenharmony_ci */ 80396279301Sopenharmony_ci static ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId); 80496279301Sopenharmony_ci 80596279301Sopenharmony_ci /** 80696279301Sopenharmony_ci * @brief Obtains whether the template is supported by the system. 80796279301Sopenharmony_ci * 80896279301Sopenharmony_ci * @param support Indicates whether is it a system supported template. 80996279301Sopenharmony_ci * @return Returns check result. 81096279301Sopenharmony_ci */ 81196279301Sopenharmony_ci static ErrCode IsSupportTemplate(const std::string &templateName, bool &support); 81296279301Sopenharmony_ci 81396279301Sopenharmony_ci /** 81496279301Sopenharmony_ci * @brief Checks whether this application has permission to publish notifications under the user. 81596279301Sopenharmony_ci * 81696279301Sopenharmony_ci * @param userId Indicates the userId of the application. 81796279301Sopenharmony_ci * @param allowed True if the application has permissions; false otherwise. 81896279301Sopenharmony_ci * @return Returns get allowed result. 81996279301Sopenharmony_ci */ 82096279301Sopenharmony_ci static ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed); 82196279301Sopenharmony_ci 82296279301Sopenharmony_ci /** 82396279301Sopenharmony_ci * @brief Sets whether to allow all applications to publish notifications on a specified user. 82496279301Sopenharmony_ci * The caller must have system permissions to call this method. 82596279301Sopenharmony_ci * 82696279301Sopenharmony_ci * @param userId Indicates the ID of the user running the application. 82796279301Sopenharmony_ci * @param enabled Specifies whether to allow all applications to publish notifications. The value true 82896279301Sopenharmony_ci * indicates that notifications are allowed, and the value false indicates that notifications 82996279301Sopenharmony_ci * are not allowed. 83096279301Sopenharmony_ci * @return Returns set notifications enabled for all bundles result. 83196279301Sopenharmony_ci */ 83296279301Sopenharmony_ci static ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled); 83396279301Sopenharmony_ci 83496279301Sopenharmony_ci /** 83596279301Sopenharmony_ci * @brief Removes notifications under specified user. 83696279301Sopenharmony_ci * @note Your application must have platform signature to use this method. 83796279301Sopenharmony_ci * 83896279301Sopenharmony_ci * @param userId Indicates the ID of user whose notifications are to be removed. 83996279301Sopenharmony_ci * @return Returns remove notification result. 84096279301Sopenharmony_ci */ 84196279301Sopenharmony_ci static ErrCode RemoveNotifications(const int32_t &userId); 84296279301Sopenharmony_ci 84396279301Sopenharmony_ci /** 84496279301Sopenharmony_ci * @brief Sets the do not disturb time on a specified user. 84596279301Sopenharmony_ci * @note Your application must have system signature to call this method. 84696279301Sopenharmony_ci * 84796279301Sopenharmony_ci * @param userId Indicates the specific user. 84896279301Sopenharmony_ci * @param doNotDisturbDate Indicates the do not disturb time to set. 84996279301Sopenharmony_ci * @return Returns set do not disturb time result. 85096279301Sopenharmony_ci */ 85196279301Sopenharmony_ci static ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate); 85296279301Sopenharmony_ci 85396279301Sopenharmony_ci /** 85496279301Sopenharmony_ci * @brief Obtains the do not disturb time on a specified user. 85596279301Sopenharmony_ci * @note Your application must have system signature to call this method. 85696279301Sopenharmony_ci * 85796279301Sopenharmony_ci * @param userId Indicates the specific user. 85896279301Sopenharmony_ci * @param doNotDisturbDate Indicates the do not disturb time to get. 85996279301Sopenharmony_ci * @return Returns set do not disturb time result. 86096279301Sopenharmony_ci */ 86196279301Sopenharmony_ci static ErrCode GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate); 86296279301Sopenharmony_ci 86396279301Sopenharmony_ci /** 86496279301Sopenharmony_ci * @brief Obtains the do not disturb on a specified user. 86596279301Sopenharmony_ci * @note Your application must have system signature to call this method. 86696279301Sopenharmony_ci * 86796279301Sopenharmony_ci * @param profiles Indicates the do not disturb time to add. 86896279301Sopenharmony_ci * @return Returns set do not disturb time result. 86996279301Sopenharmony_ci */ 87096279301Sopenharmony_ci static ErrCode AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles); 87196279301Sopenharmony_ci 87296279301Sopenharmony_ci /** 87396279301Sopenharmony_ci * @brief Obtains the do not disturb on a specified user. 87496279301Sopenharmony_ci * @note Your application must have system signature to call this method. 87596279301Sopenharmony_ci * 87696279301Sopenharmony_ci * @param profiles Indicates the do not disturb time to remove. 87796279301Sopenharmony_ci * @return Returns set do not disturb time result. 87896279301Sopenharmony_ci */ 87996279301Sopenharmony_ci static ErrCode RemoveDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles); 88096279301Sopenharmony_ci 88196279301Sopenharmony_ci /** 88296279301Sopenharmony_ci * @brief Set whether to sync notifications to devices that do not have the app installed. 88396279301Sopenharmony_ci * 88496279301Sopenharmony_ci * @param userId Indicates the specific user. 88596279301Sopenharmony_ci * @param enabled Allow or disallow sync notifications. 88696279301Sopenharmony_ci * @return Returns set enabled result. 88796279301Sopenharmony_ci */ 88896279301Sopenharmony_ci static ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled); 88996279301Sopenharmony_ci 89096279301Sopenharmony_ci /** 89196279301Sopenharmony_ci * @brief Obtains whether to sync notifications to devices that do not have the app installed. 89296279301Sopenharmony_ci * 89396279301Sopenharmony_ci * @param userId Indicates the specific user. 89496279301Sopenharmony_ci * @param enabled Allow or disallow sync notifications. 89596279301Sopenharmony_ci * @return Returns get enabled result. 89696279301Sopenharmony_ci */ 89796279301Sopenharmony_ci static ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled); 89896279301Sopenharmony_ci 89996279301Sopenharmony_ci /** 90096279301Sopenharmony_ci * @brief Set badge number. 90196279301Sopenharmony_ci * 90296279301Sopenharmony_ci * @param badgeNumber The badge number. 90396279301Sopenharmony_ci * @return Returns set badge number result. 90496279301Sopenharmony_ci */ 90596279301Sopenharmony_ci static ErrCode SetBadgeNumber(int32_t badgeNumber); 90696279301Sopenharmony_ci 90796279301Sopenharmony_ci /** 90896279301Sopenharmony_ci * @brief Set badge number by bundle. 90996279301Sopenharmony_ci * 91096279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 91196279301Sopenharmony_ci * @param badgeNumber The badge number. 91296279301Sopenharmony_ci * @return Returns set badge number by bundle result. 91396279301Sopenharmony_ci */ 91496279301Sopenharmony_ci static ErrCode SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber); 91596279301Sopenharmony_ci 91696279301Sopenharmony_ci /** 91796279301Sopenharmony_ci * @brief Obtains allow notification application list. 91896279301Sopenharmony_ci * 91996279301Sopenharmony_ci * @param bundleOption Indicates the bundle bundleOption. 92096279301Sopenharmony_ci * @return Returns ERR_OK on success, others on failure. 92196279301Sopenharmony_ci */ 92296279301Sopenharmony_ci static ErrCode GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> &bundleOption); 92396279301Sopenharmony_ci 92496279301Sopenharmony_ci /** 92596279301Sopenharmony_ci * @brief Register Push Callback. 92696279301Sopenharmony_ci * 92796279301Sopenharmony_ci * @param pushCallback push appliction's Callback. 92896279301Sopenharmony_ci * @param notificationCheckRequest Filter conditions for push check. 92996279301Sopenharmony_ci * @return Returns register push callback result. 93096279301Sopenharmony_ci */ 93196279301Sopenharmony_ci static ErrCode RegisterPushCallback( 93296279301Sopenharmony_ci const sptr<IRemoteObject>& pushCallback, const sptr<NotificationCheckRequest> ¬ificationCheckRequest); 93396279301Sopenharmony_ci 93496279301Sopenharmony_ci /** 93596279301Sopenharmony_ci * @brief Unregister Push Callback. 93696279301Sopenharmony_ci * 93796279301Sopenharmony_ci * @return Returns unregister push Callback result. 93896279301Sopenharmony_ci */ 93996279301Sopenharmony_ci static ErrCode UnregisterPushCallback(); 94096279301Sopenharmony_ci 94196279301Sopenharmony_ci /** 94296279301Sopenharmony_ci * @brief Sets whether to allow a specified application to publish notifications cross 94396279301Sopenharmony_ci * device collaboration. The caller must have system permissions to call this method. 94496279301Sopenharmony_ci * 94596279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 94696279301Sopenharmony_ci * @param deviceType Indicates the type of the device running the application. 94796279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to publish notifications. The value 94896279301Sopenharmony_ci * true indicates that notifications are allowed, and the value false indicates that 94996279301Sopenharmony_ci * notifications are not allowed. 95096279301Sopenharmony_ci * @return Returns set notifications enabled for specified bundle result. 95196279301Sopenharmony_ci */ 95296279301Sopenharmony_ci static ErrCode SetDistributedEnabledByBundle( 95396279301Sopenharmony_ci const NotificationBundleOption &bundleOption, const std::string &deviceType, const bool enabled); 95496279301Sopenharmony_ci 95596279301Sopenharmony_ci /** 95696279301Sopenharmony_ci * @brief Get whether to allow a specified application to publish notifications cross 95796279301Sopenharmony_ci * device collaboration. The caller must have system permissions to call this method. 95896279301Sopenharmony_ci * 95996279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 96096279301Sopenharmony_ci * @param deviceType Indicates the type of the device running the application. 96196279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to publish notifications. The value 96296279301Sopenharmony_ci * true indicates that notifications are allowed, and the value false indicates that 96396279301Sopenharmony_ci * notifications are not allowed. 96496279301Sopenharmony_ci * @return Returns set notifications enabled for specified bundle result. 96596279301Sopenharmony_ci */ 96696279301Sopenharmony_ci static ErrCode IsDistributedEnabledByBundle( 96796279301Sopenharmony_ci const NotificationBundleOption &bundleOption, const std::string &deviceType, bool &enabled); 96896279301Sopenharmony_ci 96996279301Sopenharmony_ci /** 97096279301Sopenharmony_ci * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders 97196279301Sopenharmony_ci * 97296279301Sopenharmony_ci * @param deviceType Indicates the type of the device running the application. 97396279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to publish notifications. 97496279301Sopenharmony_ci * The value true indicates that notifications are allowed, and the value 97596279301Sopenharmony_ci * false indicates that notifications are not allowed. 97696279301Sopenharmony_ci * @return Returns set notifications enabled for specified bundle result. 97796279301Sopenharmony_ci */ 97896279301Sopenharmony_ci static ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled); 97996279301Sopenharmony_ci 98096279301Sopenharmony_ci /** 98196279301Sopenharmony_ci * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders 98296279301Sopenharmony_ci * 98396279301Sopenharmony_ci * @param deviceType Indicates the type of the device running the application. 98496279301Sopenharmony_ci * @param enabled Specifies whether to allow the given application to publish notifications. 98596279301Sopenharmony_ci * The value true indicates that notifications are allowed, and the value 98696279301Sopenharmony_ci * false indicates that notifications are not allowed. 98796279301Sopenharmony_ci * @return Returns set notifications enabled for specified bundle result. 98896279301Sopenharmony_ci */ 98996279301Sopenharmony_ci static ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled); 99096279301Sopenharmony_ci 99196279301Sopenharmony_ci /** 99296279301Sopenharmony_ci * @brief Set agent relationship. 99396279301Sopenharmony_ci * 99496279301Sopenharmony_ci * @param key Indicates storing agent relationship if the value is "PROXY_PKG". 99596279301Sopenharmony_ci * @param value Indicates key-value pair of agent relationship. 99696279301Sopenharmony_ci * @return Returns set result. 99796279301Sopenharmony_ci */ 99896279301Sopenharmony_ci static ErrCode SetAdditionConfig(const std::string &key, const std::string &value); 99996279301Sopenharmony_ci 100096279301Sopenharmony_ci /** 100196279301Sopenharmony_ci * @brief Cancels a published agent notification. 100296279301Sopenharmony_ci * 100396279301Sopenharmony_ci * @param bundleOption Indicates the bundle name and uid of the application. 100496279301Sopenharmony_ci * @param id Indicates the unique notification ID in the application. 100596279301Sopenharmony_ci * @return Returns cancel result. 100696279301Sopenharmony_ci */ 100796279301Sopenharmony_ci static ErrCode CancelAsBundleWithAgent(const NotificationBundleOption &bundleOption, const int32_t id); 100896279301Sopenharmony_ci 100996279301Sopenharmony_ci /** 101096279301Sopenharmony_ci * @brief Set the status of the target device. 101196279301Sopenharmony_ci * 101296279301Sopenharmony_ci * @param deviceType Type of the device whose status you want to set. 101396279301Sopenharmony_ci * @param status The status. 101496279301Sopenharmony_ci * @return Returns set result. 101596279301Sopenharmony_ci */ 101696279301Sopenharmony_ci static ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status); 101796279301Sopenharmony_ci 101896279301Sopenharmony_ci /** 101996279301Sopenharmony_ci * @brief Register Swing Callback Function. 102096279301Sopenharmony_ci * 102196279301Sopenharmony_ci * @param swingCallback swing Callback Function. 102296279301Sopenharmony_ci * @return Returns register swing callback result. 102396279301Sopenharmony_ci */ 102496279301Sopenharmony_ci static ErrCode RegisterSwingCallback(const std::function<void(bool, int)> swingCbFunc); 102596279301Sopenharmony_ci 102696279301Sopenharmony_ci /** 102796279301Sopenharmony_ci * @brief Get do not disturb profile by id. 102896279301Sopenharmony_ci * 102996279301Sopenharmony_ci * @param id Profile id. 103096279301Sopenharmony_ci * @param status Indicates the NotificationDoNotDisturbProfile objects. 103196279301Sopenharmony_ci * @return Returns ERR_OK on success, others on failure. 103296279301Sopenharmony_ci */ 103396279301Sopenharmony_ci static ErrCode GetDoNotDisturbProfile(int32_t id, sptr<NotificationDoNotDisturbProfile> &profile); 103496279301Sopenharmony_ci}; 103596279301Sopenharmony_ci} // namespace Notification 103696279301Sopenharmony_ci} // namespace OHOS 103796279301Sopenharmony_ci 103896279301Sopenharmony_ci#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H 1039