196279301Sopenharmony_ci/* 296279301Sopenharmony_ci * Copyright (c) 2021-2022 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_REQUEST_H 1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_H 1896279301Sopenharmony_ci 1996279301Sopenharmony_ci#include <map> 2096279301Sopenharmony_ci#include <string> 2196279301Sopenharmony_ci 2296279301Sopenharmony_ci#include "notification_bundle_option.h" 2396279301Sopenharmony_ci#include "notification_constant.h" 2496279301Sopenharmony_ci#include "notification_request.h" 2596279301Sopenharmony_ci#include "want_params.h" 2696279301Sopenharmony_ci 2796279301Sopenharmony_cinamespace OHOS { 2896279301Sopenharmony_cinamespace Notification { 2996279301Sopenharmony_ci 3096279301Sopenharmony_ci#define READ_STRING_RETURN_FALSE_LOG(parcel, value, msg) \ 3196279301Sopenharmony_ci if (!((parcel).ReadString(value))) { \ 3296279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 3396279301Sopenharmony_ci return false; \ 3496279301Sopenharmony_ci } \ 3596279301Sopenharmony_ci 3696279301Sopenharmony_ci#define READ_BOOL_RETURN_FALSE_LOG(parcel, value, msg) \ 3796279301Sopenharmony_ci if (!((parcel).ReadBool(value))) { \ 3896279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 3996279301Sopenharmony_ci return false; \ 4096279301Sopenharmony_ci } \ 4196279301Sopenharmony_ci 4296279301Sopenharmony_ci#define READ_INT64_RETURN_FALSE_LOG(parcel, value, msg) \ 4396279301Sopenharmony_ci if (!((parcel).ReadInt64(value))) { \ 4496279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 4596279301Sopenharmony_ci return false; \ 4696279301Sopenharmony_ci } \ 4796279301Sopenharmony_ci 4896279301Sopenharmony_ci#define READ_INT32_RETURN_FALSE_LOG(parcel, value, msg) \ 4996279301Sopenharmony_ci if (!((parcel).ReadInt32(value))) { \ 5096279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 5196279301Sopenharmony_ci return false; \ 5296279301Sopenharmony_ci } \ 5396279301Sopenharmony_ci 5496279301Sopenharmony_ci#define READ_UINT64_RETURN_FALSE_LOG(parcel, value, msg) \ 5596279301Sopenharmony_ci if (!((parcel).ReadUint64(value))) { \ 5696279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 5796279301Sopenharmony_ci return false; \ 5896279301Sopenharmony_ci } \ 5996279301Sopenharmony_ci 6096279301Sopenharmony_ci#define READ_UINT32_RETURN_FALSE_LOG(parcel, value, msg) \ 6196279301Sopenharmony_ci if (!((parcel).ReadUint32(value))) { \ 6296279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 6396279301Sopenharmony_ci return false; \ 6496279301Sopenharmony_ci } \ 6596279301Sopenharmony_ci 6696279301Sopenharmony_ci#define READ_UINT16_RETURN_FALSE_LOG(parcel, value, msg) \ 6796279301Sopenharmony_ci if (!((parcel).ReadUint16(value))) { \ 6896279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 6996279301Sopenharmony_ci return false; \ 7096279301Sopenharmony_ci } \ 7196279301Sopenharmony_ci 7296279301Sopenharmony_ci#define READ_UINT8_RETURN_FALSE_LOG(parcel, value, msg) \ 7396279301Sopenharmony_ci if (!((parcel).ReadUint8(value))) { \ 7496279301Sopenharmony_ci ANSR_LOGE("Failed to read %s", msg); \ 7596279301Sopenharmony_ci return false; \ 7696279301Sopenharmony_ci } \ 7796279301Sopenharmony_ci 7896279301Sopenharmony_ci#define WRITE_STRING_RETURN_FALSE_LOG(parcel, value, msg) \ 7996279301Sopenharmony_ci if (!((parcel).WriteString(value))) { \ 8096279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 8196279301Sopenharmony_ci return false; \ 8296279301Sopenharmony_ci } \ 8396279301Sopenharmony_ci 8496279301Sopenharmony_ci#define WRITE_BOOL_RETURN_FALSE_LOG(parcel, value, msg) \ 8596279301Sopenharmony_ci if (!((parcel).WriteBool(value))) { \ 8696279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 8796279301Sopenharmony_ci return false; \ 8896279301Sopenharmony_ci } \ 8996279301Sopenharmony_ci 9096279301Sopenharmony_ci#define WRITE_INT64_RETURN_FALSE_LOG(parcel, value, msg) \ 9196279301Sopenharmony_ci if (!((parcel).WriteInt64(value))) { \ 9296279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 9396279301Sopenharmony_ci return false; \ 9496279301Sopenharmony_ci } \ 9596279301Sopenharmony_ci 9696279301Sopenharmony_ci#define WRITE_INT32_RETURN_FALSE_LOG(parcel, value, msg) \ 9796279301Sopenharmony_ci if (!((parcel).WriteInt32(value))) { \ 9896279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 9996279301Sopenharmony_ci return false; \ 10096279301Sopenharmony_ci } \ 10196279301Sopenharmony_ci 10296279301Sopenharmony_ci#define WRITE_UINT64_RETURN_FALSE_LOG(parcel, value, msg) \ 10396279301Sopenharmony_ci if (!((parcel).WriteUint64(value))) { \ 10496279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 10596279301Sopenharmony_ci return false; \ 10696279301Sopenharmony_ci } \ 10796279301Sopenharmony_ci 10896279301Sopenharmony_ci#define WRITE_UINT32_RETURN_FALSE_LOG(parcel, value, msg) \ 10996279301Sopenharmony_ci if (!((parcel).WriteUint32(value))) { \ 11096279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 11196279301Sopenharmony_ci return false; \ 11296279301Sopenharmony_ci } \ 11396279301Sopenharmony_ci 11496279301Sopenharmony_ci#define WRITE_UINT16_RETURN_FALSE_LOG(parcel, value, msg) \ 11596279301Sopenharmony_ci if (!((parcel).WriteUint16(value))) { \ 11696279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 11796279301Sopenharmony_ci return false; \ 11896279301Sopenharmony_ci } \ 11996279301Sopenharmony_ci 12096279301Sopenharmony_ci#define WRITE_UINT8_RETURN_FALSE_LOG(parcel, value, msg) \ 12196279301Sopenharmony_ci if (!((parcel).WriteUint8(value))) { \ 12296279301Sopenharmony_ci ANSR_LOGE("Failed to write %s", msg); \ 12396279301Sopenharmony_ci return false; \ 12496279301Sopenharmony_ci } \ 12596279301Sopenharmony_ci 12696279301Sopenharmony_ciclass ReminderRequest : public Parcelable { 12796279301Sopenharmony_cipublic: 12896279301Sopenharmony_ci /** 12996279301Sopenharmony_ci * @brief Supported reminder type. 13096279301Sopenharmony_ci */ 13196279301Sopenharmony_ci enum class ReminderType : uint8_t { 13296279301Sopenharmony_ci /** 13396279301Sopenharmony_ci * Indicates the classification of reminder for timer. 13496279301Sopenharmony_ci */ 13596279301Sopenharmony_ci TIMER, 13696279301Sopenharmony_ci 13796279301Sopenharmony_ci /** 13896279301Sopenharmony_ci * Indicates the classification of reminder for calendar. 13996279301Sopenharmony_ci */ 14096279301Sopenharmony_ci CALENDAR, 14196279301Sopenharmony_ci 14296279301Sopenharmony_ci /** 14396279301Sopenharmony_ci * Indicates the classification of reminder for alarm. 14496279301Sopenharmony_ci */ 14596279301Sopenharmony_ci ALARM, 14696279301Sopenharmony_ci INVALID 14796279301Sopenharmony_ci }; 14896279301Sopenharmony_ci 14996279301Sopenharmony_ci /** 15096279301Sopenharmony_ci * @brief Supported action button type. 15196279301Sopenharmony_ci */ 15296279301Sopenharmony_ci enum class ActionButtonType : uint8_t { 15396279301Sopenharmony_ci /** 15496279301Sopenharmony_ci * @brief Indicates that this action button is used to close reminder's notification. 15596279301Sopenharmony_ci * It always works well, whether the application is running at the time. 15696279301Sopenharmony_ci * 15796279301Sopenharmony_ci */ 15896279301Sopenharmony_ci CLOSE, 15996279301Sopenharmony_ci 16096279301Sopenharmony_ci /** 16196279301Sopenharmony_ci * @brief Indicates that this action button is used to snooze reminder. 16296279301Sopenharmony_ci * It always work well, whether the application is running at the time. 16396279301Sopenharmony_ci * 16496279301Sopenharmony_ci */ 16596279301Sopenharmony_ci SNOOZE, 16696279301Sopenharmony_ci 16796279301Sopenharmony_ci /** 16896279301Sopenharmony_ci * @brief Indicates that this action button is custom. 16996279301Sopenharmony_ci * 17096279301Sopenharmony_ci */ 17196279301Sopenharmony_ci CUSTOM, 17296279301Sopenharmony_ci INVALID 17396279301Sopenharmony_ci }; 17496279301Sopenharmony_ci 17596279301Sopenharmony_ci /** 17696279301Sopenharmony_ci * @brief Supported notification update type. 17796279301Sopenharmony_ci */ 17896279301Sopenharmony_ci enum class UpdateNotificationType : uint8_t { 17996279301Sopenharmony_ci COMMON, 18096279301Sopenharmony_ci REMOVAL_WANT_AGENT, 18196279301Sopenharmony_ci WANT_AGENT, 18296279301Sopenharmony_ci MAX_SCREEN_WANT_AGENT, 18396279301Sopenharmony_ci BUNDLE_INFO, 18496279301Sopenharmony_ci CONTENT 18596279301Sopenharmony_ci }; 18696279301Sopenharmony_ci 18796279301Sopenharmony_ci /** 18896279301Sopenharmony_ci * @brief Enumerates the Time type for converting between c time and acture time. 18996279301Sopenharmony_ci */ 19096279301Sopenharmony_ci enum class TimeTransferType : uint8_t { 19196279301Sopenharmony_ci YEAR, 19296279301Sopenharmony_ci MONTH, 19396279301Sopenharmony_ci WEEK 19496279301Sopenharmony_ci }; 19596279301Sopenharmony_ci 19696279301Sopenharmony_ci /** 19796279301Sopenharmony_ci * @brief Enumerates the Time format for print. 19896279301Sopenharmony_ci */ 19996279301Sopenharmony_ci enum class TimeFormat : uint8_t { 20096279301Sopenharmony_ci YMDHMS, 20196279301Sopenharmony_ci HM 20296279301Sopenharmony_ci }; 20396279301Sopenharmony_ci 20496279301Sopenharmony_ci struct ButtonWantAgent { 20596279301Sopenharmony_ci std::string pkgName = ""; 20696279301Sopenharmony_ci std::string abilityName = ""; 20796279301Sopenharmony_ci }; 20896279301Sopenharmony_ci 20996279301Sopenharmony_ci struct ButtonDataShareUpdate { 21096279301Sopenharmony_ci std::string uri = ""; 21196279301Sopenharmony_ci std::string equalTo = ""; 21296279301Sopenharmony_ci std::string valuesBucket = ""; 21396279301Sopenharmony_ci }; 21496279301Sopenharmony_ci /** 21596279301Sopenharmony_ci * @brief Attributes of action button. 21696279301Sopenharmony_ci */ 21796279301Sopenharmony_ci struct ActionButtonInfo { 21896279301Sopenharmony_ci /** 21996279301Sopenharmony_ci * Type of the button. 22096279301Sopenharmony_ci */ 22196279301Sopenharmony_ci ActionButtonType type; 22296279301Sopenharmony_ci 22396279301Sopenharmony_ci /** 22496279301Sopenharmony_ci * Content show on the button. 22596279301Sopenharmony_ci */ 22696279301Sopenharmony_ci std::string title = ""; 22796279301Sopenharmony_ci 22896279301Sopenharmony_ci /** 22996279301Sopenharmony_ci * resource key(for language) 23096279301Sopenharmony_ci */ 23196279301Sopenharmony_ci std::string resource = ""; 23296279301Sopenharmony_ci 23396279301Sopenharmony_ci /** 23496279301Sopenharmony_ci * The ability that is redirected to when the button is clicked. 23596279301Sopenharmony_ci */ 23696279301Sopenharmony_ci std::shared_ptr<ButtonWantAgent> wantAgent; 23796279301Sopenharmony_ci 23896279301Sopenharmony_ci /** 23996279301Sopenharmony_ci * The ability that is updata App rdb. 24096279301Sopenharmony_ci */ 24196279301Sopenharmony_ci std::shared_ptr<ButtonDataShareUpdate> dataShareUpdate; 24296279301Sopenharmony_ci }; 24396279301Sopenharmony_ci 24496279301Sopenharmony_ci /** 24596279301Sopenharmony_ci * @brief Want agent information. Indicates the package and the ability to switch to. 24696279301Sopenharmony_ci */ 24796279301Sopenharmony_ci struct WantAgentInfo { 24896279301Sopenharmony_ci std::string pkgName = ""; 24996279301Sopenharmony_ci std::string abilityName = ""; 25096279301Sopenharmony_ci std::string uri = ""; 25196279301Sopenharmony_ci AAFwk::WantParams parameters; 25296279301Sopenharmony_ci }; 25396279301Sopenharmony_ci 25496279301Sopenharmony_ci struct MaxScreenAgentInfo { 25596279301Sopenharmony_ci std::string pkgName = ""; 25696279301Sopenharmony_ci std::string abilityName = ""; 25796279301Sopenharmony_ci }; 25896279301Sopenharmony_ci 25996279301Sopenharmony_ci /** 26096279301Sopenharmony_ci * @brief Copy construct from an exist reminder. 26196279301Sopenharmony_ci * 26296279301Sopenharmony_ci * @param Indicates the exist reminder. 26396279301Sopenharmony_ci */ 26496279301Sopenharmony_ci explicit ReminderRequest(const ReminderRequest &other); 26596279301Sopenharmony_ci 26696279301Sopenharmony_ci /** 26796279301Sopenharmony_ci * @brief This constructor should only be used in background proxy service process 26896279301Sopenharmony_ci * when reminder instance recovery from database. 26996279301Sopenharmony_ci * 27096279301Sopenharmony_ci * @param reminderId Indicates reminder id. 27196279301Sopenharmony_ci */ 27296279301Sopenharmony_ci explicit ReminderRequest(int32_t reminderId); 27396279301Sopenharmony_ci ReminderRequest& operator = (const ReminderRequest &other); 27496279301Sopenharmony_ci virtual ~ReminderRequest() override {}; 27596279301Sopenharmony_ci 27696279301Sopenharmony_ci /** 27796279301Sopenharmony_ci * @brief Marshal a NotificationRequest object into a Parcel. 27896279301Sopenharmony_ci * 27996279301Sopenharmony_ci * @param parcel the object into the parcel 28096279301Sopenharmony_ci */ 28196279301Sopenharmony_ci virtual bool Marshalling(Parcel &parcel) const override; 28296279301Sopenharmony_ci 28396279301Sopenharmony_ci /** 28496279301Sopenharmony_ci * @brief Unmarshal object from a Parcel. 28596279301Sopenharmony_ci * 28696279301Sopenharmony_ci * @return the NotificationRequest 28796279301Sopenharmony_ci */ 28896279301Sopenharmony_ci static ReminderRequest *Unmarshalling(Parcel &parcel); 28996279301Sopenharmony_ci virtual bool ReadFromParcel(Parcel &parcel); 29096279301Sopenharmony_ci 29196279301Sopenharmony_ci /** 29296279301Sopenharmony_ci * @brief If the reminder is showing on the notification panel, it should not be removed automatically. 29396279301Sopenharmony_ci * 29496279301Sopenharmony_ci * @return true if it can be removed automatically. 29596279301Sopenharmony_ci */ 29696279301Sopenharmony_ci bool CanRemove() const; 29796279301Sopenharmony_ci 29896279301Sopenharmony_ci bool CanShow() const; 29996279301Sopenharmony_ci 30096279301Sopenharmony_ci /** 30196279301Sopenharmony_ci * @brief Obtains all the information of the reminder. 30296279301Sopenharmony_ci * 30396279301Sopenharmony_ci * @return Information of the reminder. 30496279301Sopenharmony_ci */ 30596279301Sopenharmony_ci std::string Dump() const; 30696279301Sopenharmony_ci 30796279301Sopenharmony_ci /** 30896279301Sopenharmony_ci * @brief Obtains the configured action buttons. 30996279301Sopenharmony_ci * 31096279301Sopenharmony_ci * @return map of action buttons. 31196279301Sopenharmony_ci */ 31296279301Sopenharmony_ci std::map<ActionButtonType, ActionButtonInfo> GetActionButtons() const; 31396279301Sopenharmony_ci 31496279301Sopenharmony_ci /** 31596279301Sopenharmony_ci * @brief Obtains creator bundle name 31696279301Sopenharmony_ci * 31796279301Sopenharmony_ci * @return creator bundle name 31896279301Sopenharmony_ci */ 31996279301Sopenharmony_ci std::string GetCreatorBundleName() const; 32096279301Sopenharmony_ci 32196279301Sopenharmony_ci /** 32296279301Sopenharmony_ci * @brief Obtains creator uid 32396279301Sopenharmony_ci * 32496279301Sopenharmony_ci * @return creator uid 32596279301Sopenharmony_ci */ 32696279301Sopenharmony_ci int32_t GetCreatorUid() const; 32796279301Sopenharmony_ci 32896279301Sopenharmony_ci /** 32996279301Sopenharmony_ci * @brief Obtains the configured content. 33096279301Sopenharmony_ci * 33196279301Sopenharmony_ci * @return content text. 33296279301Sopenharmony_ci */ 33396279301Sopenharmony_ci std::string GetContent() const; 33496279301Sopenharmony_ci 33596279301Sopenharmony_ci /** 33696279301Sopenharmony_ci * @brief Obtains the configured expired content. 33796279301Sopenharmony_ci * 33896279301Sopenharmony_ci * @return expired content text. 33996279301Sopenharmony_ci */ 34096279301Sopenharmony_ci std::string GetExpiredContent() const; 34196279301Sopenharmony_ci 34296279301Sopenharmony_ci std::shared_ptr<MaxScreenAgentInfo> GetMaxScreenWantAgentInfo() const; 34396279301Sopenharmony_ci 34496279301Sopenharmony_ci /** 34596279301Sopenharmony_ci * @brief Obtains notification id. 34696279301Sopenharmony_ci * 34796279301Sopenharmony_ci * @return notification id. 34896279301Sopenharmony_ci */ 34996279301Sopenharmony_ci int32_t GetNotificationId() const; 35096279301Sopenharmony_ci 35196279301Sopenharmony_ci /** 35296279301Sopenharmony_ci * @brief Obtains group id. 35396279301Sopenharmony_ci * 35496279301Sopenharmony_ci * @return group id. 35596279301Sopenharmony_ci */ 35696279301Sopenharmony_ci std::string GetGroupId() const; 35796279301Sopenharmony_ci 35896279301Sopenharmony_ci /** 35996279301Sopenharmony_ci * @brief Obtains notification request. 36096279301Sopenharmony_ci * 36196279301Sopenharmony_ci * @return notification request instance. 36296279301Sopenharmony_ci */ 36396279301Sopenharmony_ci sptr<NotificationRequest> GetNotificationRequest() const; 36496279301Sopenharmony_ci 36596279301Sopenharmony_ci /** 36696279301Sopenharmony_ci * @brief Obtains reminder id. 36796279301Sopenharmony_ci * 36896279301Sopenharmony_ci * @return reminder id. 36996279301Sopenharmony_ci */ 37096279301Sopenharmony_ci int32_t GetReminderId() const; 37196279301Sopenharmony_ci 37296279301Sopenharmony_ci uint64_t GetReminderTimeInMilli() const; 37396279301Sopenharmony_ci 37496279301Sopenharmony_ci /** 37596279301Sopenharmony_ci * @brief Obtains reminder type. 37696279301Sopenharmony_ci * 37796279301Sopenharmony_ci * @return reminder type. 37896279301Sopenharmony_ci */ 37996279301Sopenharmony_ci ReminderType GetReminderType() const; 38096279301Sopenharmony_ci 38196279301Sopenharmony_ci /** 38296279301Sopenharmony_ci * @brief Obtains the ringing or vibration duration configured for this reminder. 38396279301Sopenharmony_ci * 38496279301Sopenharmony_ci * @return uint16_t The ringing or vibration duration in seconds. 38596279301Sopenharmony_ci */ 38696279301Sopenharmony_ci uint16_t GetRingDuration() const; 38796279301Sopenharmony_ci 38896279301Sopenharmony_ci /** 38996279301Sopenharmony_ci * @brief Obtains slot type. 39096279301Sopenharmony_ci * 39196279301Sopenharmony_ci * @return slot type. 39296279301Sopenharmony_ci */ 39396279301Sopenharmony_ci NotificationConstant::SlotType GetSlotType() const; 39496279301Sopenharmony_ci 39596279301Sopenharmony_ci /** 39696279301Sopenharmony_ci * @brief Obtains snoozeSlot type. 39796279301Sopenharmony_ci * 39896279301Sopenharmony_ci * @return snoozeSlot type. 39996279301Sopenharmony_ci */ 40096279301Sopenharmony_ci NotificationConstant::SlotType GetSnoozeSlotType() const; 40196279301Sopenharmony_ci 40296279301Sopenharmony_ci std::string GetSnoozeContent() const; 40396279301Sopenharmony_ci uint8_t GetSnoozeTimes() const; 40496279301Sopenharmony_ci uint8_t GetSnoozeTimesDynamic() const; 40596279301Sopenharmony_ci uint8_t GetState() const; 40696279301Sopenharmony_ci 40796279301Sopenharmony_ci /** 40896279301Sopenharmony_ci * @brief Obtains the Time Interval in seconds. 40996279301Sopenharmony_ci * 41096279301Sopenharmony_ci * @return uint64_t Time Interval in seconds. 41196279301Sopenharmony_ci */ 41296279301Sopenharmony_ci uint64_t GetTimeInterval() const; 41396279301Sopenharmony_ci 41496279301Sopenharmony_ci /** 41596279301Sopenharmony_ci * @brief Obtains title. 41696279301Sopenharmony_ci * 41796279301Sopenharmony_ci * @return title. 41896279301Sopenharmony_ci */ 41996279301Sopenharmony_ci std::string GetTitle() const; 42096279301Sopenharmony_ci 42196279301Sopenharmony_ci /** 42296279301Sopenharmony_ci * @brief Obtains trigger time in milli. 42396279301Sopenharmony_ci * 42496279301Sopenharmony_ci * @return trigger time. 42596279301Sopenharmony_ci */ 42696279301Sopenharmony_ci uint64_t GetTriggerTimeInMilli() const; 42796279301Sopenharmony_ci 42896279301Sopenharmony_ci int32_t GetUserId() const; 42996279301Sopenharmony_ci int32_t GetUid() const; 43096279301Sopenharmony_ci 43196279301Sopenharmony_ci /** 43296279301Sopenharmony_ci * @brief Obtains bundle name 43396279301Sopenharmony_ci * 43496279301Sopenharmony_ci * @return bundle name 43596279301Sopenharmony_ci */ 43696279301Sopenharmony_ci std::string GetBundleName() const; 43796279301Sopenharmony_ci 43896279301Sopenharmony_ci /** 43996279301Sopenharmony_ci * @brief Set the reminder type. 44096279301Sopenharmony_ci * 44196279301Sopenharmony_ci * @param reminderType the reminder type. 44296279301Sopenharmony_ci */ 44396279301Sopenharmony_ci void SetReminderType(const ReminderType type); 44496279301Sopenharmony_ci 44596279301Sopenharmony_ci /** 44696279301Sopenharmony_ci * @brief Set the reminder state. 44796279301Sopenharmony_ci * 44896279301Sopenharmony_ci * @param state the reminder state. 44996279301Sopenharmony_ci */ 45096279301Sopenharmony_ci void SetState(const uint8_t state); 45196279301Sopenharmony_ci 45296279301Sopenharmony_ci /** 45396279301Sopenharmony_ci * @brief Set the reminder repeat days of week. 45496279301Sopenharmony_ci * 45596279301Sopenharmony_ci * @param state the reminder repeat days of week. 45696279301Sopenharmony_ci */ 45796279301Sopenharmony_ci void SetRepeatDaysOfWeek(const uint8_t repeatDaysOfWeek); 45896279301Sopenharmony_ci 45996279301Sopenharmony_ci /** 46096279301Sopenharmony_ci * @brief Set the app system. 46196279301Sopenharmony_ci * 46296279301Sopenharmony_ci */ 46396279301Sopenharmony_ci void SetSystemApp(bool isSystem); 46496279301Sopenharmony_ci 46596279301Sopenharmony_ci /** 46696279301Sopenharmony_ci * @brief Check the app is system or not. 46796279301Sopenharmony_ci * 46896279301Sopenharmony_ci * @return true is the app is system. 46996279301Sopenharmony_ci */ 47096279301Sopenharmony_ci bool IsSystemApp() const; 47196279301Sopenharmony_ci 47296279301Sopenharmony_ci /** 47396279301Sopenharmony_ci * @brief Obtains want agent information. 47496279301Sopenharmony_ci * 47596279301Sopenharmony_ci * @return want agent information. 47696279301Sopenharmony_ci */ 47796279301Sopenharmony_ci std::shared_ptr<WantAgentInfo> GetWantAgentInfo() const; 47896279301Sopenharmony_ci 47996279301Sopenharmony_ci /** 48096279301Sopenharmony_ci * @brief Inites reminder creator bundle name when publish reminder success. 48196279301Sopenharmony_ci * 48296279301Sopenharmony_ci * @param creatorBundleName Indicates the creator bundle name which the reminder belong to 48396279301Sopenharmony_ci */ 48496279301Sopenharmony_ci void InitCreatorBundleName(const std::string &creatorBundleName); 48596279301Sopenharmony_ci 48696279301Sopenharmony_ci /** 48796279301Sopenharmony_ci * @brief Inites reminder creator uid when publish reminder success. 48896279301Sopenharmony_ci * 48996279301Sopenharmony_ci * @param uid Indicates the creator uid which the reminder belong to 49096279301Sopenharmony_ci */ 49196279301Sopenharmony_ci void InitCreatorUid(const int32_t creatorUid); 49296279301Sopenharmony_ci 49396279301Sopenharmony_ci /** 49496279301Sopenharmony_ci * @brief Inits reminder id when publish reminder success. 49596279301Sopenharmony_ci * Assign a unique reminder id for each reminder. 49696279301Sopenharmony_ci */ 49796279301Sopenharmony_ci void InitReminderId(); 49896279301Sopenharmony_ci 49996279301Sopenharmony_ci /** 50096279301Sopenharmony_ci * @brief Inits reminder userId when publish reminder success. 50196279301Sopenharmony_ci * 50296279301Sopenharmony_ci * When package remove, user id is sended by wantAgent, but we cannot get the uid according user id as the 50396279301Sopenharmony_ci * package has been removed, and the bundleOption can not be create with correct uid. so we need to record 50496279301Sopenharmony_ci * the user id, and use it to judge which user the reminder belong to. 50596279301Sopenharmony_ci * 50696279301Sopenharmony_ci * @param userId Indicates the userId which the reminder belong to. 50796279301Sopenharmony_ci */ 50896279301Sopenharmony_ci void InitUserId(const int32_t &userId); 50996279301Sopenharmony_ci 51096279301Sopenharmony_ci /** 51196279301Sopenharmony_ci * @brief Inites reminder uid when publish reminder success. 51296279301Sopenharmony_ci * 51396279301Sopenharmony_ci * When system reboot and recovery from database, we cannot get the uid according user id as BMS has not be 51496279301Sopenharmony_ci * ready. So we need to record the uid in order to create correct bundleOption. 51596279301Sopenharmony_ci * 51696279301Sopenharmony_ci * @param uid Indicates the uid which the reminder belong to. 51796279301Sopenharmony_ci */ 51896279301Sopenharmony_ci void InitUid(const int32_t &uid); 51996279301Sopenharmony_ci 52096279301Sopenharmony_ci /** 52196279301Sopenharmony_ci * @brief Inites reminder bundle name when publish reminder success. 52296279301Sopenharmony_ci * 52396279301Sopenharmony_ci * @param bundleName Indicates the bundle name which the reminder belong to 52496279301Sopenharmony_ci */ 52596279301Sopenharmony_ci void InitBundleName(const std::string &bundleName); 52696279301Sopenharmony_ci 52796279301Sopenharmony_ci /** 52896279301Sopenharmony_ci * @brief Check the reminder is alerting or not. 52996279301Sopenharmony_ci * 53096279301Sopenharmony_ci * @return true if the reminder is playing sound or vibrating. 53196279301Sopenharmony_ci */ 53296279301Sopenharmony_ci bool IsAlerting() const; 53396279301Sopenharmony_ci 53496279301Sopenharmony_ci /** 53596279301Sopenharmony_ci * @brief Check the reminder is expired or not. 53696279301Sopenharmony_ci * 53796279301Sopenharmony_ci * @return true is the reminder is expired. 53896279301Sopenharmony_ci */ 53996279301Sopenharmony_ci bool IsExpired() const; 54096279301Sopenharmony_ci 54196279301Sopenharmony_ci /** 54296279301Sopenharmony_ci * @brief Check the reminder is showing on the panel. 54396279301Sopenharmony_ci * 54496279301Sopenharmony_ci * @return true if the reminder is showing on the panel. 54596279301Sopenharmony_ci */ 54696279301Sopenharmony_ci bool IsShowing() const; 54796279301Sopenharmony_ci 54896279301Sopenharmony_ci /** 54996279301Sopenharmony_ci * @brief Closes the reminder by manual. 55096279301Sopenharmony_ci * 55196279301Sopenharmony_ci * 1) Resets the state of "Alering/Showing/Snooze" 55296279301Sopenharmony_ci * 2) Resets snoozeTimesDynamic_ if update to next trigger time, otherwise set reminder to expired. 55396279301Sopenharmony_ci * 55496279301Sopenharmony_ci * @param updateNext Whether to update to next reminder. 55596279301Sopenharmony_ci */ 55696279301Sopenharmony_ci void OnClose(bool updateNext); 55796279301Sopenharmony_ci 55896279301Sopenharmony_ci /** 55996279301Sopenharmony_ci * @brief When date/time change, reminder need to refresh next trigger time. 56096279301Sopenharmony_ci * 56196279301Sopenharmony_ci * @return true if need to show reminder immediately. 56296279301Sopenharmony_ci */ 56396279301Sopenharmony_ci virtual bool OnDateTimeChange(); 56496279301Sopenharmony_ci 56596279301Sopenharmony_ci /** 56696279301Sopenharmony_ci * When shown notification is covered by a new notification with the same id, we should remove 56796279301Sopenharmony_ci * the state of showing, so that the reminder can be removed automatically when it is expired. 56896279301Sopenharmony_ci */ 56996279301Sopenharmony_ci void OnSameNotificationIdCovered(); 57096279301Sopenharmony_ci 57196279301Sopenharmony_ci /** 57296279301Sopenharmony_ci * Set the reminder state is InActive, so that it will be removed when expired 57396279301Sopenharmony_ci */ 57496279301Sopenharmony_ci void SetStateToInActive(); 57596279301Sopenharmony_ci 57696279301Sopenharmony_ci /** 57796279301Sopenharmony_ci * @brief Shows the reminder on panel. TriggerTime will be updated to next. 57896279301Sopenharmony_ci * 57996279301Sopenharmony_ci * @param isPlaySoundOrVibration true means it is play sound or vibration. 58096279301Sopenharmony_ci * @param isSysTimeChanged true means it is called when the system time is changed by user, otherwise false. 58196279301Sopenharmony_ci * @param allowToNotify true means that the notification will be shown as normal, otherwise false. 58296279301Sopenharmony_ci */ 58396279301Sopenharmony_ci void OnShow(bool isPlaySoundOrVibration, bool isSysTimeChanged, bool allowToNotify); 58496279301Sopenharmony_ci 58596279301Sopenharmony_ci /** 58696279301Sopenharmony_ci * @brief Reset the state of "Showing" when the reminder is shown failed. 58796279301Sopenharmony_ci */ 58896279301Sopenharmony_ci void OnShowFail(); 58996279301Sopenharmony_ci 59096279301Sopenharmony_ci /** 59196279301Sopenharmony_ci * @brief Snooze the reminder by manual. 59296279301Sopenharmony_ci * 59396279301Sopenharmony_ci * 1) Updates the trigger time to the next one. 59496279301Sopenharmony_ci * 2) Updates the notification content for "Snooze". 59596279301Sopenharmony_ci * 3) Switches the state from "Showing[, Alerting]" to "Snooze". 59696279301Sopenharmony_ci */ 59796279301Sopenharmony_ci bool OnSnooze(); 59896279301Sopenharmony_ci 59996279301Sopenharmony_ci /** 60096279301Sopenharmony_ci * @brief Starts the reminder 60196279301Sopenharmony_ci * 60296279301Sopenharmony_ci * Sets the state from "Inactive" to "Active". 60396279301Sopenharmony_ci */ 60496279301Sopenharmony_ci void OnStart(); 60596279301Sopenharmony_ci 60696279301Sopenharmony_ci /** 60796279301Sopenharmony_ci * @brief Stops the reminder. 60896279301Sopenharmony_ci * 60996279301Sopenharmony_ci * Sets the state from "Active" to "Inactive". 61096279301Sopenharmony_ci */ 61196279301Sopenharmony_ci void OnStop(); 61296279301Sopenharmony_ci 61396279301Sopenharmony_ci /** 61496279301Sopenharmony_ci * @brief Terminate the alerting reminder, which is executed when the ring duration is over. 61596279301Sopenharmony_ci * 61696279301Sopenharmony_ci * 1) Disables the state of "Alerting". 61796279301Sopenharmony_ci * 2) Updates the notification content for "Alert". 61896279301Sopenharmony_ci * 61996279301Sopenharmony_ci * @return false if alerting state has already been set false before calling the method. 62096279301Sopenharmony_ci */ 62196279301Sopenharmony_ci bool OnTerminate(); 62296279301Sopenharmony_ci 62396279301Sopenharmony_ci /** 62496279301Sopenharmony_ci * @brief When timezone change, reminder need to refresh next trigger time. 62596279301Sopenharmony_ci * 62696279301Sopenharmony_ci * @return true if need to show reminder immediately. 62796279301Sopenharmony_ci */ 62896279301Sopenharmony_ci virtual bool OnTimeZoneChange(); 62996279301Sopenharmony_ci 63096279301Sopenharmony_ci /** 63196279301Sopenharmony_ci * @brief Sets action button. 63296279301Sopenharmony_ci * 63396279301Sopenharmony_ci * @param title Indicates the title of the button. 63496279301Sopenharmony_ci * @param type Indicates the type of the button. 63596279301Sopenharmony_ci * @param resource Indicates the resource of the button. 63696279301Sopenharmony_ci * @return Current reminder self. 63796279301Sopenharmony_ci */ 63896279301Sopenharmony_ci ReminderRequest& SetActionButton(const std::string &title, const ActionButtonType &type, 63996279301Sopenharmony_ci const std::string &resource, const std::shared_ptr<ButtonWantAgent> &buttonWantAgent = nullptr, 64096279301Sopenharmony_ci const std::shared_ptr<ButtonDataShareUpdate> &buttonDataShareUpdate = nullptr); 64196279301Sopenharmony_ci 64296279301Sopenharmony_ci /** 64396279301Sopenharmony_ci * @brief Sets reminder content. 64496279301Sopenharmony_ci * 64596279301Sopenharmony_ci * @param content Indicates content text. 64696279301Sopenharmony_ci * @return Current reminder self. 64796279301Sopenharmony_ci */ 64896279301Sopenharmony_ci ReminderRequest& SetContent(const std::string &content); 64996279301Sopenharmony_ci 65096279301Sopenharmony_ci /** 65196279301Sopenharmony_ci * @brief Sets reminder is expired or not. 65296279301Sopenharmony_ci * 65396279301Sopenharmony_ci * @param isExpired Indicates the reminder is expired or not. 65496279301Sopenharmony_ci */ 65596279301Sopenharmony_ci void SetExpired(bool isExpired); 65696279301Sopenharmony_ci 65796279301Sopenharmony_ci /** 65896279301Sopenharmony_ci * @brief Sets expired content. 65996279301Sopenharmony_ci * 66096279301Sopenharmony_ci * @param expiredContent Indicates expired content. 66196279301Sopenharmony_ci * @return Current reminder self. 66296279301Sopenharmony_ci */ 66396279301Sopenharmony_ci ReminderRequest& SetExpiredContent(const std::string &expiredContent); 66496279301Sopenharmony_ci 66596279301Sopenharmony_ci ReminderRequest& SetMaxScreenWantAgentInfo(const std::shared_ptr<MaxScreenAgentInfo> &maxScreenWantAgentInfo); 66696279301Sopenharmony_ci 66796279301Sopenharmony_ci /** 66896279301Sopenharmony_ci * @brief Sets notification id. 66996279301Sopenharmony_ci * 67096279301Sopenharmony_ci * @param notificationId Indicates notification id. 67196279301Sopenharmony_ci * @return Current reminder self. 67296279301Sopenharmony_ci */ 67396279301Sopenharmony_ci ReminderRequest& SetNotificationId(int32_t notificationId); 67496279301Sopenharmony_ci 67596279301Sopenharmony_ci /** 67696279301Sopenharmony_ci * @brief Sets group id. 67796279301Sopenharmony_ci * 67896279301Sopenharmony_ci * @param notificationId Indicates group id. 67996279301Sopenharmony_ci * @return Current reminder self. 68096279301Sopenharmony_ci */ 68196279301Sopenharmony_ci ReminderRequest& SetGroupId(const std::string &groupId); 68296279301Sopenharmony_ci 68396279301Sopenharmony_ci /** 68496279301Sopenharmony_ci * @brief Sets reminder id. 68596279301Sopenharmony_ci * 68696279301Sopenharmony_ci * @param reminderId Indicates reminder id. 68796279301Sopenharmony_ci */ 68896279301Sopenharmony_ci void SetReminderId(int32_t reminderId); 68996279301Sopenharmony_ci 69096279301Sopenharmony_ci void SetReminderTimeInMilli(const uint64_t reminderTimeInMilli); 69196279301Sopenharmony_ci 69296279301Sopenharmony_ci /** 69396279301Sopenharmony_ci * @brief Sets the ringing or vibration duration for this reminder, in seconds. 69496279301Sopenharmony_ci * 69596279301Sopenharmony_ci * @param ringDurationInSeconds Indicates the duration. The default is 1 second. 69696279301Sopenharmony_ci * @return Current reminder self. 69796279301Sopenharmony_ci */ 69896279301Sopenharmony_ci ReminderRequest& SetRingDuration(const uint64_t ringDurationInSeconds); 69996279301Sopenharmony_ci 70096279301Sopenharmony_ci /** 70196279301Sopenharmony_ci * @brief Sets slot type. 70296279301Sopenharmony_ci * 70396279301Sopenharmony_ci * @param slotType Indicates slot type. 70496279301Sopenharmony_ci * @return Current reminder self. 70596279301Sopenharmony_ci */ 70696279301Sopenharmony_ci ReminderRequest& SetSlotType(const NotificationConstant::SlotType &slotType); 70796279301Sopenharmony_ci ReminderRequest& SetSnoozeSlotType(const NotificationConstant::SlotType &snoozeSlotType); 70896279301Sopenharmony_ci ReminderRequest& SetSnoozeContent(const std::string &snoozeContent); 70996279301Sopenharmony_ci 71096279301Sopenharmony_ci /** 71196279301Sopenharmony_ci * @brief Set the number of snooze times for this reminder. 71296279301Sopenharmony_ci * 71396279301Sopenharmony_ci * @note If the value of snoozeTimes is less than or equals to 0, this reminder is a one-shot 71496279301Sopenharmony_ci * reminder and will not be snoozed. 71596279301Sopenharmony_ci * 71696279301Sopenharmony_ci * It the value of snoozeTimes is greater than 0, for example, snoozeTimes=3, this reminder 71796279301Sopenharmony_ci * will be snoozed three times after the first alarm, that is, this reminder will be triggered 71896279301Sopenharmony_ci * for four times. 71996279301Sopenharmony_ci * 72096279301Sopenharmony_ci * This method does not take affect on the reminders for countdown timers. 72196279301Sopenharmony_ci * 72296279301Sopenharmony_ci * @param snoozeTimes Indicates the number of times that the reminder will be snoozed. 72396279301Sopenharmony_ci * @return ReminderRequest& Current reminder self. 72496279301Sopenharmony_ci */ 72596279301Sopenharmony_ci ReminderRequest& SetSnoozeTimes(const uint8_t snoozeTimes); 72696279301Sopenharmony_ci 72796279301Sopenharmony_ci ReminderRequest& SetSnoozeTimesDynamic(const uint8_t snooziTimes); 72896279301Sopenharmony_ci 72996279301Sopenharmony_ci /** 73096279301Sopenharmony_ci * @brief Sets the Time Interval for this reminder, in seconds. The default value is 0. 73196279301Sopenharmony_ci * 73296279301Sopenharmony_ci * @note The minimum snooze interval is 5 minute. If the snooze interval is set to a value greater 73396279301Sopenharmony_ci * than 0 and less than 5 minutes, the system converts it to 5 minutes by default. 73496279301Sopenharmony_ci * 73596279301Sopenharmony_ci * This method does not take effect on the reminders for countdown timers. 73696279301Sopenharmony_ci * 73796279301Sopenharmony_ci * @param timeIntervalInSeconds Indicates the snooze interval to set. If the value is less or equals to 0, 73896279301Sopenharmony_ci * the reminder will not be snoozed. 73996279301Sopenharmony_ci * @return ReminderRequest& Current reminder self. 74096279301Sopenharmony_ci */ 74196279301Sopenharmony_ci ReminderRequest& SetTimeInterval(const uint64_t timeIntervalInSeconds); 74296279301Sopenharmony_ci 74396279301Sopenharmony_ci /** 74496279301Sopenharmony_ci * @brief Sets title. 74596279301Sopenharmony_ci * 74696279301Sopenharmony_ci * @param title Indicates title. 74796279301Sopenharmony_ci * @return Current reminder self. 74896279301Sopenharmony_ci */ 74996279301Sopenharmony_ci ReminderRequest& SetTitle(const std::string &title); 75096279301Sopenharmony_ci 75196279301Sopenharmony_ci /** 75296279301Sopenharmony_ci * @brief Sets trigger time. 75396279301Sopenharmony_ci * 75496279301Sopenharmony_ci * @param triggerTimeInMilli Indicates trigger time in milli. 75596279301Sopenharmony_ci */ 75696279301Sopenharmony_ci void SetTriggerTimeInMilli(uint64_t triggerTimeInMilli); 75796279301Sopenharmony_ci 75896279301Sopenharmony_ci /** 75996279301Sopenharmony_ci * @brief Sets want agent information. 76096279301Sopenharmony_ci * 76196279301Sopenharmony_ci * @param wantAgentInfo Indicates want agent information. 76296279301Sopenharmony_ci * @return Current reminder self. 76396279301Sopenharmony_ci */ 76496279301Sopenharmony_ci ReminderRequest& SetWantAgentInfo(const std::shared_ptr<WantAgentInfo> &wantAgentInfo); 76596279301Sopenharmony_ci 76696279301Sopenharmony_ci bool ShouldShowImmediately() const; 76796279301Sopenharmony_ci 76896279301Sopenharmony_ci /** 76996279301Sopenharmony_ci * @brief Updates {@link triggerTimeInMilli_} to next. 77096279301Sopenharmony_ci * @note If next trigger time not exist, {@link isExpired_} flag will be set with true. 77196279301Sopenharmony_ci * 77296279301Sopenharmony_ci * @return true if next trigger time exist and set success. 77396279301Sopenharmony_ci */ 77496279301Sopenharmony_ci virtual bool UpdateNextReminder(); 77596279301Sopenharmony_ci virtual bool SetNextTriggerTime(); 77696279301Sopenharmony_ci 77796279301Sopenharmony_ci /** 77896279301Sopenharmony_ci * @brief Check reminder request is repeat 77996279301Sopenharmony_ci */ 78096279301Sopenharmony_ci virtual bool IsRepeat() const 78196279301Sopenharmony_ci { 78296279301Sopenharmony_ci return false; 78396279301Sopenharmony_ci } 78496279301Sopenharmony_ci 78596279301Sopenharmony_ci /** 78696279301Sopenharmony_ci * @brief Check reminder request is in exclude date 78796279301Sopenharmony_ci */ 78896279301Sopenharmony_ci virtual bool CheckExcludeDate() 78996279301Sopenharmony_ci { 79096279301Sopenharmony_ci return false; 79196279301Sopenharmony_ci } 79296279301Sopenharmony_ci 79396279301Sopenharmony_ci /** 79496279301Sopenharmony_ci * @brief Check rrule want agent, pull up service extension 79596279301Sopenharmony_ci * 79696279301Sopenharmony_ci * @return true if need pull up service extension 79796279301Sopenharmony_ci */ 79896279301Sopenharmony_ci virtual bool IsPullUpService() 79996279301Sopenharmony_ci { 80096279301Sopenharmony_ci return false; 80196279301Sopenharmony_ci } 80296279301Sopenharmony_ci 80396279301Sopenharmony_ci /** 80496279301Sopenharmony_ci * @brief Check need notification reminder. due to system timer. 80596279301Sopenharmony_ci * When change system time to later, more than the trigger time, system timer must trigger. 80696279301Sopenharmony_ci */ 80796279301Sopenharmony_ci virtual bool IsNeedNotification() 80896279301Sopenharmony_ci { 80996279301Sopenharmony_ci return true; 81096279301Sopenharmony_ci } 81196279301Sopenharmony_ci 81296279301Sopenharmony_ci void SetWantAgentStr(const std::string& wantStr); 81396279301Sopenharmony_ci std::string GetWantAgentStr(); 81496279301Sopenharmony_ci void SetMaxWantAgentStr(const std::string& maxWantStr); 81596279301Sopenharmony_ci std::string GetMaxWantAgentStr(); 81696279301Sopenharmony_ci 81796279301Sopenharmony_ci /** 81896279301Sopenharmony_ci * @brief Sets tapDismissed. 81996279301Sopenharmony_ci * 82096279301Sopenharmony_ci * @param tapDismissed Indicates tapDismissed. 82196279301Sopenharmony_ci */ 82296279301Sopenharmony_ci void SetTapDismissed(bool tapDismissed); 82396279301Sopenharmony_ci 82496279301Sopenharmony_ci /** 82596279301Sopenharmony_ci * @brief Gets tapDismissed. 82696279301Sopenharmony_ci * 82796279301Sopenharmony_ci * @return True if tapDismissed. 82896279301Sopenharmony_ci */ 82996279301Sopenharmony_ci bool IsTapDismissed() const; 83096279301Sopenharmony_ci 83196279301Sopenharmony_ci /** 83296279301Sopenharmony_ci * @brief Sets autoDeletedTime. 83396279301Sopenharmony_ci * 83496279301Sopenharmony_ci * @param autoDeletedTime Indicates autoDeletedTime. 83596279301Sopenharmony_ci */ 83696279301Sopenharmony_ci void SetAutoDeletedTime(int64_t autoDeletedTime); 83796279301Sopenharmony_ci 83896279301Sopenharmony_ci /** 83996279301Sopenharmony_ci * @brief Gets autoDeletedTime. 84096279301Sopenharmony_ci * 84196279301Sopenharmony_ci * @return AutoDeletedTime. 84296279301Sopenharmony_ci */ 84396279301Sopenharmony_ci int64_t GetAutoDeletedTime() const; 84496279301Sopenharmony_ci 84596279301Sopenharmony_ci /** 84696279301Sopenharmony_ci * @brief Sets custom button uri. 84796279301Sopenharmony_ci * 84896279301Sopenharmony_ci * @param uri Indicates uri. 84996279301Sopenharmony_ci */ 85096279301Sopenharmony_ci void SetCustomButtonUri(const std::string &uri); 85196279301Sopenharmony_ci 85296279301Sopenharmony_ci /** 85396279301Sopenharmony_ci * @brief Gets custom button uri. 85496279301Sopenharmony_ci * 85596279301Sopenharmony_ci * @return custom button uri. 85696279301Sopenharmony_ci */ 85796279301Sopenharmony_ci std::string GetCustomButtonUri() const; 85896279301Sopenharmony_ci 85996279301Sopenharmony_ci /** 86096279301Sopenharmony_ci * @brief Gets custom ring uri. 86196279301Sopenharmony_ci * 86296279301Sopenharmony_ci * @return custom ring uri. 86396279301Sopenharmony_ci */ 86496279301Sopenharmony_ci std::string GetCustomRingUri() const; 86596279301Sopenharmony_ci 86696279301Sopenharmony_ci /** 86796279301Sopenharmony_ci * @brief Sets custom ring uri. 86896279301Sopenharmony_ci * 86996279301Sopenharmony_ci * @param uri Indicates uri. 87096279301Sopenharmony_ci */ 87196279301Sopenharmony_ci void SetCustomRingUri(const std::string &uri); 87296279301Sopenharmony_ci 87396279301Sopenharmony_ci /** 87496279301Sopenharmony_ci * @brief Gets notification bundle option. 87596279301Sopenharmony_ci */ 87696279301Sopenharmony_ci sptr<NotificationBundleOption> GetNotificationBundleOption() const; 87796279301Sopenharmony_ci 87896279301Sopenharmony_ci /** 87996279301Sopenharmony_ci * @brief Sets notification bundle option. 88096279301Sopenharmony_ci */ 88196279301Sopenharmony_ci void SetNotificationBundleOption(const sptr<NotificationBundleOption>& option); 88296279301Sopenharmony_ci 88396279301Sopenharmony_ci /** 88496279301Sopenharmony_ci * @brief Update notification attributes. 88596279301Sopenharmony_ci * 88696279301Sopenharmony_ci * Some attributes need to be updated after the reminder published or before the notification publish. 88796279301Sopenharmony_ci * For example, action button should not init until the reminder is published successfully, as the reminder id is 88896279301Sopenharmony_ci * assigned after that. 88996279301Sopenharmony_ci * 89096279301Sopenharmony_ci * @param type Indicates the update type. 89196279301Sopenharmony_ci * @param extra Indicates the extra content. 89296279301Sopenharmony_ci */ 89396279301Sopenharmony_ci void UpdateNotificationRequest(UpdateNotificationType type, std::string extra); 89496279301Sopenharmony_ci 89596279301Sopenharmony_ci /** 89696279301Sopenharmony_ci * @brief Get repeated days of the week. 89796279301Sopenharmony_ci * 89896279301Sopenharmony_ci * @return Array of the int type. 89996279301Sopenharmony_ci */ 90096279301Sopenharmony_ci std::vector<int32_t> GetDaysOfWeek() const; 90196279301Sopenharmony_ci 90296279301Sopenharmony_ci /** 90396279301Sopenharmony_ci * @brief Create notification request struct when recover from rdb or 90496279301Sopenharmony_ci * recv reminder info from ipc. 90596279301Sopenharmony_ci */ 90696279301Sopenharmony_ci bool InitNotificationRequest(); 90796279301Sopenharmony_ci 90896279301Sopenharmony_ci /** 90996279301Sopenharmony_ci * @brief Gets repeat days of week 91096279301Sopenharmony_ci */ 91196279301Sopenharmony_ci uint8_t GetRepeatDaysOfWeek() const; 91296279301Sopenharmony_ci 91396279301Sopenharmony_ci /** 91496279301Sopenharmony_ci * @brief When system language change, will call this function. 91596279301Sopenharmony_ci * need load resource to update button title 91696279301Sopenharmony_ci * @param resMgr Indicates the resource manager for get button title 91796279301Sopenharmony_ci */ 91896279301Sopenharmony_ci void OnLanguageChange(const std::shared_ptr<Global::Resource::ResourceManager> &resMgr); 91996279301Sopenharmony_ci 92096279301Sopenharmony_cipublic: 92196279301Sopenharmony_ci /** 92296279301Sopenharmony_ci * @brief Serialize want agent info and max want agent info to string. 92396279301Sopenharmony_ci * Persist to the rdb. 92496279301Sopenharmony_ci */ 92596279301Sopenharmony_ci void SerializeWantAgent(std::string& wantInfoStr, std::string& maxWantInfoStr); 92696279301Sopenharmony_ci 92796279301Sopenharmony_ci /** 92896279301Sopenharmony_ci * @brief Deserialize want agent info and max want agent info from string. 92996279301Sopenharmony_ci * Recover from the rdb. 93096279301Sopenharmony_ci */ 93196279301Sopenharmony_ci void DeserializeWantAgent(const std::string& wantAgentInfo, const uint8_t type); 93296279301Sopenharmony_ci 93396279301Sopenharmony_ci /** 93496279301Sopenharmony_ci * @brief Serialize action button info to string. 93596279301Sopenharmony_ci * Persist to the rdb. 93696279301Sopenharmony_ci */ 93796279301Sopenharmony_ci std::string SerializeButtonInfo() const; 93896279301Sopenharmony_ci 93996279301Sopenharmony_ci /** 94096279301Sopenharmony_ci * @brief Deserialize action button info from string. 94196279301Sopenharmony_ci * Recover from the rdb. 94296279301Sopenharmony_ci */ 94396279301Sopenharmony_ci void DeserializeButtonInfo(const std::string& buttonInfoStr); 94496279301Sopenharmony_ci 94596279301Sopenharmony_ci static int32_t GetActualTime(const TimeTransferType &type, int32_t cTime); 94696279301Sopenharmony_ci static int32_t GetCTime(const TimeTransferType &type, int32_t actualTime); 94796279301Sopenharmony_ci static uint64_t GetDurationSinceEpochInMilli(const time_t target); 94896279301Sopenharmony_ci static std::vector<std::string> StringSplit(std::string source, const std::string &split); 94996279301Sopenharmony_ci 95096279301Sopenharmony_ci static int32_t GLOBAL_ID; 95196279301Sopenharmony_ci static const uint64_t INVALID_LONG_LONG_VALUE; 95296279301Sopenharmony_ci static const uint16_t INVALID_U16_VALUE; 95396279301Sopenharmony_ci static const uint8_t INVALID_U8_VALUE; 95496279301Sopenharmony_ci static const uint16_t MILLI_SECONDS; 95596279301Sopenharmony_ci static const uint16_t SAME_TIME_DISTINGUISH_MILLISECONDS; 95696279301Sopenharmony_ci static const std::string NOTIFICATION_LABEL; 95796279301Sopenharmony_ci static const uint8_t MONDAY; 95896279301Sopenharmony_ci static const uint8_t SUNDAY; 95996279301Sopenharmony_ci static const uint8_t DAYS_PER_WEEK; 96096279301Sopenharmony_ci static const uint8_t HOURS_PER_DAY; 96196279301Sopenharmony_ci static const uint16_t SECONDS_PER_HOUR; 96296279301Sopenharmony_ci static const uint8_t MINUTES_PER_HOUR; 96396279301Sopenharmony_ci /** 96496279301Sopenharmony_ci * @brief Show the reminder with a notification. 96596279301Sopenharmony_ci */ 96696279301Sopenharmony_ci static const std::string REMINDER_EVENT_ALARM_ALERT; 96796279301Sopenharmony_ci 96896279301Sopenharmony_ci /** 96996279301Sopenharmony_ci * @brief Close the reminder when click the close button of notification. 97096279301Sopenharmony_ci */ 97196279301Sopenharmony_ci static const std::string REMINDER_EVENT_CLOSE_ALERT; 97296279301Sopenharmony_ci 97396279301Sopenharmony_ci /** 97496279301Sopenharmony_ci * @brief Snooze the reminder when click the snooze button of notification. 97596279301Sopenharmony_ci */ 97696279301Sopenharmony_ci static const std::string REMINDER_EVENT_SNOOZE_ALERT; 97796279301Sopenharmony_ci 97896279301Sopenharmony_ci static const std::string REMINDER_EVENT_CUSTOM_ALERT; 97996279301Sopenharmony_ci 98096279301Sopenharmony_ci /** 98196279301Sopenharmony_ci * @biref Close the reminder when click the notification, not button. 98296279301Sopenharmony_ci */ 98396279301Sopenharmony_ci static const std::string REMINDER_EVENT_CLICK_ALERT; 98496279301Sopenharmony_ci 98596279301Sopenharmony_ci /** 98696279301Sopenharmony_ci * @brief Used to control ring duration. 98796279301Sopenharmony_ci */ 98896279301Sopenharmony_ci static const std::string REMINDER_EVENT_ALERT_TIMEOUT; 98996279301Sopenharmony_ci 99096279301Sopenharmony_ci /** 99196279301Sopenharmony_ci * @brief Update the reminder when remove notification from the systemUI. 99296279301Sopenharmony_ci */ 99396279301Sopenharmony_ci static const std::string REMINDER_EVENT_REMOVE_NOTIFICATION; 99496279301Sopenharmony_ci static const std::string PARAM_REMINDER_ID; 99596279301Sopenharmony_ci static const uint8_t REMINDER_STATUS_INACTIVE; 99696279301Sopenharmony_ci static const uint8_t REMINDER_STATUS_ACTIVE; 99796279301Sopenharmony_ci static const uint8_t REMINDER_STATUS_ALERTING; 99896279301Sopenharmony_ci static const uint8_t REMINDER_STATUS_SHOWING; 99996279301Sopenharmony_ci static const uint8_t REMINDER_STATUS_SNOOZE; 100096279301Sopenharmony_ci static const uint8_t TIME_HOUR_OFFSET; 100196279301Sopenharmony_ci 100296279301Sopenharmony_ci // For ActionButtonDataShare. 100396279301Sopenharmony_ci static const std::string SEP_BUTTON_VALUE_TYPE; 100496279301Sopenharmony_ci static const std::string SEP_BUTTON_VALUE; 100596279301Sopenharmony_ci static const std::string SEP_BUTTON_VALUE_BLOB; 100696279301Sopenharmony_ci 100796279301Sopenharmony_ci // no object in parcel 100896279301Sopenharmony_ci static constexpr int32_t VALUE_NULL = -1; 100996279301Sopenharmony_ci // object exist in parcel 101096279301Sopenharmony_ci static constexpr int32_t VALUE_OBJECT = 1; 101196279301Sopenharmony_ci // wantAgent flag 101296279301Sopenharmony_ci static constexpr int32_t WANT_AGENT_FLAG = 0; 101396279301Sopenharmony_ci // maxWantAgent flag 101496279301Sopenharmony_ci static constexpr int32_t MAX_WANT_AGENT_FLAG = 1; 101596279301Sopenharmony_ci 101696279301Sopenharmony_ci // max ring duration 101796279301Sopenharmony_ci static constexpr uint64_t MAX_RING_DURATION = 30 * 60 * 1000; // 30 min 101896279301Sopenharmony_ci 101996279301Sopenharmony_ciprotected: 102096279301Sopenharmony_ci enum class DbRecoveryType : uint8_t { 102196279301Sopenharmony_ci INT, 102296279301Sopenharmony_ci LONG 102396279301Sopenharmony_ci }; 102496279301Sopenharmony_ci ReminderRequest(); 102596279301Sopenharmony_ci explicit ReminderRequest(ReminderType reminderType); 102696279301Sopenharmony_ci std::string GetDateTimeInfo(const time_t &timeInSecond) const; 102796279301Sopenharmony_ci virtual uint64_t PreGetNextTriggerTimeIgnoreSnooze(bool ignoreRepeat, bool forceToGetNext) 102896279301Sopenharmony_ci { 102996279301Sopenharmony_ci return INVALID_LONG_LONG_VALUE; 103096279301Sopenharmony_ci } 103196279301Sopenharmony_ci 103296279301Sopenharmony_ci uint8_t repeatDaysOfWeek_{0}; 103396279301Sopenharmony_ci 103496279301Sopenharmony_ci /** 103596279301Sopenharmony_ci * Obtains the next triggerTime if it is a week repeat. 103696279301Sopenharmony_ci * 103796279301Sopenharmony_ci * @param now Indicates current time. 103896279301Sopenharmony_ci * @param now Indicatet target time. 103996279301Sopenharmony_ci * @return nextTriggerTime. 104096279301Sopenharmony_ci */ 104196279301Sopenharmony_ci int64_t GetNextDaysOfWeek(const time_t now, const time_t target) const; 104296279301Sopenharmony_ci void SetRepeatDaysOfWeek(bool set, const std::vector<uint8_t> &daysOfWeek); 104396279301Sopenharmony_ci time_t GetTriggerTimeWithDST(const time_t now, const time_t nextTriggerTime) const; 104496279301Sopenharmony_ci uint64_t GetTriggerTime(const time_t now, const time_t nextTriggerTime) const; 104596279301Sopenharmony_ci uint64_t GetNowInstantMilli() const; 104696279301Sopenharmony_ci 104796279301Sopenharmony_ciprivate: 104896279301Sopenharmony_ci void AddActionButtons(const bool includeSnooze); 104996279301Sopenharmony_ci void AddRemovalWantAgent(); 105096279301Sopenharmony_ci std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> CreateWantAgent(AppExecFwk::ElementName &element) const; 105196279301Sopenharmony_ci std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> CreateMaxWantAgent(AppExecFwk::ElementName &element) const; 105296279301Sopenharmony_ci std::string GetShowTime(const uint64_t showTime) const; 105396279301Sopenharmony_ci std::string GetTimeInfoInner(const time_t &timeInSecond, const TimeFormat &format, bool keep24Hour) const; 105496279301Sopenharmony_ci std::string GetState(const uint8_t state) const; 105596279301Sopenharmony_ci bool HandleSysTimeChange(uint64_t oriTriggerTime, uint64_t optTriggerTime); 105696279301Sopenharmony_ci bool HandleTimeZoneChange(uint64_t oldZoneTriggerTime, uint64_t newZoneTriggerTime, uint64_t optTriggerTime); 105796279301Sopenharmony_ci void InitServerObj(); 105896279301Sopenharmony_ci void SetMaxScreenWantAgent(AppExecFwk::ElementName &element); 105996279301Sopenharmony_ci void SetState(bool deSet, const uint8_t newState, std::string function); 106096279301Sopenharmony_ci void SetWantAgent(AppExecFwk::ElementName &element); 106196279301Sopenharmony_ci void UpdateActionButtons(const bool &setSnooze); 106296279301Sopenharmony_ci bool UpdateNextReminder(const bool &force); 106396279301Sopenharmony_ci void UpdateNotificationContent(const bool &setSnooze); 106496279301Sopenharmony_ci void UpdateNotificationCommon(bool isSnooze); 106596279301Sopenharmony_ci 106696279301Sopenharmony_ci /** 106796279301Sopenharmony_ci * @brief Determine whether it is repeated every week. 106896279301Sopenharmony_ci * 106996279301Sopenharmony_ci * @return True if repeate. 107096279301Sopenharmony_ci */ 107196279301Sopenharmony_ci bool IsRepeatDaysOfWeek(int32_t day) const; 107296279301Sopenharmony_ci 107396279301Sopenharmony_ci /** 107496279301Sopenharmony_ci * @brief Used for reminder recovery from database. 107596279301Sopenharmony_ci * 107696279301Sopenharmony_ci * @param bundleName Indicates the third part bundle name. 107796279301Sopenharmony_ci */ 107896279301Sopenharmony_ci void UpdateNotificationBundleInfo(); 107996279301Sopenharmony_ci 108096279301Sopenharmony_ci /** 108196279301Sopenharmony_ci * @brief Update the notification, which will be shown for the "Alerting" reminder. 108296279301Sopenharmony_ci * 1. Update the notification label/content. 108396279301Sopenharmony_ci * 2. Restore the snooze action button. 108496279301Sopenharmony_ci */ 108596279301Sopenharmony_ci void UpdateNotificationStateForAlert(); 108696279301Sopenharmony_ci 108796279301Sopenharmony_ci /** 108896279301Sopenharmony_ci * @brief Update the notification, which will be shown when user do a snooze. 108996279301Sopenharmony_ci * 1. Update the notification label/content. 109096279301Sopenharmony_ci * 2. Remove the snooze action button. 109196279301Sopenharmony_ci */ 109296279301Sopenharmony_ci void UpdateNotificationStateForSnooze(); 109396279301Sopenharmony_ci 109496279301Sopenharmony_ci bool MarshallingWantParameters(Parcel& parcel, const AAFwk::WantParams& params) const; 109596279301Sopenharmony_ci bool MarshallingActionButton(Parcel& parcel) const; 109696279301Sopenharmony_ci bool ReadWantParametersFromParcel(Parcel& parcel, AAFwk::WantParams& wantParams); 109796279301Sopenharmony_ci bool ReadActionButtonFromParcel(Parcel& parcel); 109896279301Sopenharmony_ci 109996279301Sopenharmony_ci void RecoverActionButtonJsonMode(const std::string& jsonString); 110096279301Sopenharmony_ci void RecoverWantAgentByJson(const std::string& wantAgentInfo, const uint8_t& type); 110196279301Sopenharmony_ci 110296279301Sopenharmony_ci static const uint32_t MIN_TIME_INTERVAL_IN_MILLI; 110396279301Sopenharmony_ci static const std::string SEP_BUTTON_SINGLE; 110496279301Sopenharmony_ci static const std::string SEP_BUTTON_MULTI; 110596279301Sopenharmony_ci static const std::string SEP_WANT_AGENT; 110696279301Sopenharmony_ci 110796279301Sopenharmony_ci std::string content_ {}; 110896279301Sopenharmony_ci std::string expiredContent_ {}; 110996279301Sopenharmony_ci std::string snoozeContent_ {}; 111096279301Sopenharmony_ci std::string displayContent_ {}; 111196279301Sopenharmony_ci std::string title_ {}; 111296279301Sopenharmony_ci std::string bundleName_ {}; 111396279301Sopenharmony_ci bool isExpired_ {false}; 111496279301Sopenharmony_ci uint8_t snoozeTimes_ {0}; 111596279301Sopenharmony_ci uint8_t snoozeTimesDynamic_ {0}; 111696279301Sopenharmony_ci uint8_t state_ {0}; 111796279301Sopenharmony_ci int32_t notificationId_ {0}; 111896279301Sopenharmony_ci std::string groupId_ {}; 111996279301Sopenharmony_ci int32_t reminderId_ {-1}; 112096279301Sopenharmony_ci int32_t userId_ {-1}; 112196279301Sopenharmony_ci int32_t uid_ {-1}; 112296279301Sopenharmony_ci bool isSystemApp_ {false}; 112396279301Sopenharmony_ci bool tapDismissed_ {true}; 112496279301Sopenharmony_ci int64_t autoDeletedTime_ {0}; 112596279301Sopenharmony_ci std::string customButtonUri_ {}; 112696279301Sopenharmony_ci std::string customRingUri_ {}; 112796279301Sopenharmony_ci std::string creatorBundleName_ {}; 112896279301Sopenharmony_ci int32_t creatorUid_ {-1}; 112996279301Sopenharmony_ci 113096279301Sopenharmony_ci // Indicates the reminder has been shown in the past time. 113196279301Sopenharmony_ci // When the reminder has been created but not showed, it is equals to 0. 113296279301Sopenharmony_ci uint64_t reminderTimeInMilli_ {0}; 113396279301Sopenharmony_ci uint64_t ringDurationInMilli_ {MILLI_SECONDS}; 113496279301Sopenharmony_ci uint64_t triggerTimeInMilli_ {0}; 113596279301Sopenharmony_ci uint64_t timeIntervalInMilli_ {0}; 113696279301Sopenharmony_ci ReminderType reminderType_ {ReminderType::INVALID}; 113796279301Sopenharmony_ci NotificationConstant::SlotType slotType_ {NotificationConstant::SlotType::SOCIAL_COMMUNICATION}; 113896279301Sopenharmony_ci NotificationConstant::SlotType snoozeSlotType_ {NotificationConstant::SlotType::OTHER}; 113996279301Sopenharmony_ci sptr<NotificationRequest> notificationRequest_ = nullptr; 114096279301Sopenharmony_ci std::shared_ptr<WantAgentInfo> wantAgentInfo_ = nullptr; 114196279301Sopenharmony_ci std::shared_ptr<MaxScreenAgentInfo> maxScreenWantAgentInfo_ = nullptr; 114296279301Sopenharmony_ci std::map<ActionButtonType, ActionButtonInfo> actionButtonMap_ {}; 114396279301Sopenharmony_ci 114496279301Sopenharmony_ci std::string wantAgentStr_{}; 114596279301Sopenharmony_ci std::string maxWantAgentStr_{}; 114696279301Sopenharmony_ci 114796279301Sopenharmony_ci sptr<NotificationBundleOption> notificationOption_ {nullptr}; 114896279301Sopenharmony_ci}; 114996279301Sopenharmony_ci} // namespace Reminder 115096279301Sopenharmony_ci} // namespace OHOS 115196279301Sopenharmony_ci#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_H