196279301Sopenharmony_ci/*
296279301Sopenharmony_ci * Copyright (c) 2021 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_REMINDER_HELPER_H
1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_HELPER_H
1896279301Sopenharmony_ci
1996279301Sopenharmony_ci#include <vector>
2096279301Sopenharmony_ci
2196279301Sopenharmony_ci#include "notification_slot.h"
2296279301Sopenharmony_ci#include "reminder_request.h"
2396279301Sopenharmony_ci
2496279301Sopenharmony_cinamespace OHOS {
2596279301Sopenharmony_cinamespace Notification {
2696279301Sopenharmony_ciclass ReminderHelper {
2796279301Sopenharmony_cipublic:
2896279301Sopenharmony_ci    /**
2996279301Sopenharmony_ci     * Publishes a scheduled reminder.
3096279301Sopenharmony_ci     *
3196279301Sopenharmony_ci     * Third-party applications can call this method to publish a scheduled reminder. After this method is called,
3296279301Sopenharmony_ci     * the timing and pop-up notification functions of the calling application will be performed by the system service
3396279301Sopenharmony_ci     * agent in the background, even when the application is frozen or exits. You can call the
3496279301Sopenharmony_ci     * ReminderRequest::SetWantAgentInfo(WantAgentInfo wantAgentInfo) method to specify whether to start the
3596279301Sopenharmony_ci     * application after the pop-up notification is taped.
3696279301Sopenharmony_ci     *
3796279301Sopenharmony_ci     * The background agent maintains an ordered list of reminders for all third-party applications. The list is
3896279301Sopenharmony_ci     * updated based on the scheduled trigger time of each reminder. The system starts only one most recent scheduled
3996279301Sopenharmony_ci     * reminder at a time. If a reminder with a more recent trigger time is added, the new scheduled reminder will
4096279301Sopenharmony_ci     * be put on top of the list. The next reminder is triggered only after the current reminder is complete.
4196279301Sopenharmony_ci     *
4296279301Sopenharmony_ci     * @note One application can create a maximum of 30 valid reminders, and the total number of valid reminders
4396279301Sopenharmony_ci     * in the system cannot exceed 2000. The minimum snooze interval for a reminder is 5 minutes.
4496279301Sopenharmony_ci     *
4596279301Sopenharmony_ci     * @param reminder Indicates the reminder instance to publish. This parameter cannot be null. Otherwise,
4696279301Sopenharmony_ci     *                 an exception will be thrown due to invalid parameters, causing the application to crash.
4796279301Sopenharmony_ci     * @return Returns publish reminder result.
4896279301Sopenharmony_ci     *                 Reminder id will be set with a number >= 0 if publishing the reminder successfully, Otherwise
4996279301Sopenharmony_ci     *                 reminder id is -1. You can call reminder.GetReminderId() to get the reminder id.
5096279301Sopenharmony_ci     */
5196279301Sopenharmony_ci    static ErrCode PublishReminder(ReminderRequest &reminder);
5296279301Sopenharmony_ci
5396279301Sopenharmony_ci    /**
5496279301Sopenharmony_ci     * Cancels a specified reminder.
5596279301Sopenharmony_ci     *
5696279301Sopenharmony_ci     * @param reminderId Indicates the ID of the reminder instance to cancel.
5796279301Sopenharmony_ci     * @return Returns cancel reminder result.
5896279301Sopenharmony_ci     */
5996279301Sopenharmony_ci    static ErrCode CancelReminder(const int32_t reminderId);
6096279301Sopenharmony_ci
6196279301Sopenharmony_ci    /**
6296279301Sopenharmony_ci     * Cancels all reminders of current third part application.
6396279301Sopenharmony_ci     *
6496279301Sopenharmony_ci     * @return Returns cancel all reminders result.
6596279301Sopenharmony_ci     */
6696279301Sopenharmony_ci    static ErrCode CancelAllReminders();
6796279301Sopenharmony_ci
6896279301Sopenharmony_ci    /**
6996279301Sopenharmony_ci     * Obtains all valid reminder notifications set by the current application, namely, the reminders that will
7096279301Sopenharmony_ci     * still be triggered later. If a reminder will never be triggered again, it is not considered a valid reminder.
7196279301Sopenharmony_ci     *
7296279301Sopenharmony_ci     * @param[out] validReminders Indicates an initial vector to receive the result.
7396279301Sopenharmony_ci     * @return Returns an array list containing all valid reminder notifications set by the current application.
7496279301Sopenharmony_ci     */
7596279301Sopenharmony_ci    static ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &validReminders);
7696279301Sopenharmony_ci
7796279301Sopenharmony_ci    /**
7896279301Sopenharmony_ci     * Creates a NotificationSlot.
7996279301Sopenharmony_ci     *
8096279301Sopenharmony_ci     * After a notification slot is created by using this method, only the name and description of the notification
8196279301Sopenharmony_ci     * slot can be changed. Changes to the other attributes, such as the vibration status and notification tone,
8296279301Sopenharmony_ci     * will no longer take effect.
8396279301Sopenharmony_ci     *
8496279301Sopenharmony_ci     * You can call the ReminderRequest#setSlotId(String) method to bind the slot for publishing a reminder.
8596279301Sopenharmony_ci     * When the application is uninstalled, all notification slots related to the application will be deleted.
8696279301Sopenharmony_ci     *
8796279301Sopenharmony_ci     * @param slot Indicates the NotificationSlot instance to add.
8896279301Sopenharmony_ci     * @return Returns add notification slot result.
8996279301Sopenharmony_ci     */
9096279301Sopenharmony_ci    static ErrCode AddNotificationSlot(const NotificationSlot &slot);
9196279301Sopenharmony_ci
9296279301Sopenharmony_ci    /**
9396279301Sopenharmony_ci     * Removes a NotificationSlot instance used by the reminder.
9496279301Sopenharmony_ci     *
9596279301Sopenharmony_ci     * @param slotType Indicates the type of the slot, which is set when calling AddNotificationSlot to add a slot.
9696279301Sopenharmony_ci     * @return Returns remove notification slot result.
9796279301Sopenharmony_ci     */
9896279301Sopenharmony_ci    static ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType);
9996279301Sopenharmony_ci
10096279301Sopenharmony_ci    /**
10196279301Sopenharmony_ci     * @brief Add exclude date for reminder
10296279301Sopenharmony_ci     *
10396279301Sopenharmony_ci     * @param reminderId Identifies the reminders id.
10496279301Sopenharmony_ci     * @param date exclude date
10596279301Sopenharmony_ci     * @return Returns ERR_OK on success, others on failure.
10696279301Sopenharmony_ci     */
10796279301Sopenharmony_ci    static ErrCode AddExcludeDate(const int32_t reminderId, const uint64_t date);
10896279301Sopenharmony_ci
10996279301Sopenharmony_ci    /**
11096279301Sopenharmony_ci     * @brief Clear exclude date for reminder
11196279301Sopenharmony_ci     *
11296279301Sopenharmony_ci     * @param reminderId Identifies the reminders id.
11396279301Sopenharmony_ci     * @return Returns ERR_OK on success, others on failure.
11496279301Sopenharmony_ci     */
11596279301Sopenharmony_ci    static ErrCode DelExcludeDates(const int32_t reminderId);
11696279301Sopenharmony_ci
11796279301Sopenharmony_ci    /**
11896279301Sopenharmony_ci     * @brief Get exclude date for reminder
11996279301Sopenharmony_ci     *
12096279301Sopenharmony_ci     * @param reminderId Identifies the reminders id.
12196279301Sopenharmony_ci     * @param dates exclude dates
12296279301Sopenharmony_ci     * @return Returns ERR_OK on success, others on failure.
12396279301Sopenharmony_ci     */
12496279301Sopenharmony_ci    static ErrCode GetExcludeDates(const int32_t reminderId, std::vector<uint64_t>& dates);
12596279301Sopenharmony_ci
12696279301Sopenharmony_ciprivate:
12796279301Sopenharmony_ci    static bool CheckPermission();
12896279301Sopenharmony_ci};
12996279301Sopenharmony_ci}  // namespace Reminder
13096279301Sopenharmony_ci}  // namespace OHOS
13196279301Sopenharmony_ci
13296279301Sopenharmony_ci#endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_HELPER_H