1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_CLIENT_H 16 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_CLIENT_H 17 #include <list> 18 #include <memory> 19 20 #include "reminder_request.h" 21 #include "reminder_request_adaptation.h" 22 #include "notification_slot.h" 23 #include "notification_constant.h" 24 #include "ians_manager.h" 25 #include "ireminder_agent_service.h" 26 #include "ffrt.h" 27 28 namespace OHOS { 29 namespace Notification { 30 class ReminderRequestClient { 31 public: 32 /** 33 * @brief Publishes a scheduled reminder. 34 * 35 * @param reminder Indicates a reminder. 36 * @return Returns publish result. 37 */ 38 ErrCode PublishReminder(const ReminderRequest& reminder, int32_t& reminderId); 39 40 /** 41 * @brief Updates a scheduled reminder. 42 * 43 * @param reminderId Indicates reminder Id. 44 * @param reminder Indicates a reminder. 45 * @return Returns publish result. 46 */ 47 ErrCode UpdateReminder(const int32_t reminderId, const ReminderRequest& reminder); 48 49 /** 50 * @brief Cancels a specified reminder. 51 * 52 * @param reminderId Indicates reminder Id. 53 * @return Returns cancel result. 54 */ 55 ErrCode CancelReminder(const int32_t reminderId); 56 57 /** 58 * @brief Cancels all reminders of current third part application. 59 * 60 * @return Returns cancel result. 61 */ 62 ErrCode CancelAllReminders(); 63 64 /** 65 * @brief Obtains all valid reminder notifications set by the current application. 66 * 67 * @param[out] validReminders Indicates the vector to store the result. 68 * @return Returns get valid reminders result. 69 */ 70 ErrCode GetValidReminders(std::vector<ReminderRequestAdaptation> &validReminders); 71 72 /** 73 * @brief Add exclude date for reminder 74 * 75 * @param reminderId Identifies the reminders id. 76 * @param date exclude date 77 * @return Returns ERR_OK on success, others on failure. 78 */ 79 ErrCode AddExcludeDate(const int32_t reminderId, const int64_t date); 80 81 /** 82 * @brief Clear exclude date for reminder 83 * 84 * @param reminderId Identifies the reminders id. 85 * @return Returns ERR_OK on success, others on failure. 86 */ 87 ErrCode DelExcludeDates(const int32_t reminderId); 88 89 /** 90 * @brief Get exclude date for reminder 91 * 92 * @param reminderId Identifies the reminders id. 93 * @param dates exclude dates 94 * @return Returns ERR_OK on success, others on failure. 95 */ 96 ErrCode GetExcludeDates(const int32_t reminderId, std::vector<int64_t>& dates); 97 98 /** 99 * @brief Creates a notification slot. 100 * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot 101 * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to 102 * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the 103 * notification published can have all the characteristics set in the NotificationSlot. After a notification slot is 104 * created by using this method, only the name and description of the notification slot can be changed. Changes to 105 * the other attributes, such as the vibration status and notification tone, will no longer take effect. 106 * 107 * @param slot Indicates the notification slot to be created, which is set by NotificationSlot. 108 * This parameter must be specified. 109 * @return Returns add notification slot result. 110 */ 111 ErrCode AddNotificationSlot(const NotificationSlot &slot); 112 113 /** 114 * @brief Deletes a created notification slot based on the slot ID. 115 * 116 * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot 117 * This parameter must be specified. 118 * @return Returns remove notification slot result. 119 */ 120 ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType); 121 122 void LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject); 123 124 void LoadSystemAbilityFail(); 125 126 void StartReminderAgentService(); 127 128 private: 129 130 /** 131 * @brief Adds a notification slot by type. 132 * 133 * @param slotType Indicates the notification slot type to be added. 134 * @return Returns add notification slot result. 135 */ 136 ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType); 137 138 sptr<IAnsManager> GetAnsManagerProxy(); 139 140 sptr<IReminderAgentService> GetReminderServiceProxy(); 141 142 bool LoadReminderService(); 143 144 ffrt::mutex serviceLock_; 145 146 ffrt::condition_variable proxyConVar_; 147 148 sptr<IReminderAgentService> proxy_; 149 }; 150 } // namespace Notification 151 } // namespace OHOS 152 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_CLIENT_H 153 154