• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 
16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "abs_shared_result_set.h"
23 #include "notification_bundle_option.h"
24 #include "notification_constant.h"
25 #include "notification_request.h"
26 #include "values_bucket.h"
27 
28 namespace OHOS {
29 namespace Notification {
30 
31 #define READ_STRING_RETURN_FALSE_LOG(parcel, value, msg) \
32     if (!((parcel).ReadString(value))) {                 \
33         ANSR_LOGE("Failed to read %s", msg);             \
34         return false;                                    \
35     }                                                    \
36 
37 #define READ_BOOL_RETURN_FALSE_LOG(parcel, value, msg) \
38     if (!((parcel).ReadBool(value))) {                 \
39         ANSR_LOGE("Failed to read %s", msg);           \
40         return false;                                  \
41     }                                                  \
42 
43 #define READ_INT64_RETURN_FALSE_LOG(parcel, value, msg) \
44     if (!((parcel).ReadInt64(value))) {                 \
45         ANSR_LOGE("Failed to read %s", msg);            \
46         return false;                                   \
47     }                                                   \
48 
49 #define READ_INT32_RETURN_FALSE_LOG(parcel, value, msg) \
50     if (!((parcel).ReadInt32(value))) {                 \
51         ANSR_LOGE("Failed to read %s", msg);            \
52         return false;                                   \
53     }                                                   \
54 
55 #define READ_UINT64_RETURN_FALSE_LOG(parcel, value, msg) \
56     if (!((parcel).ReadUint64(value))) {                 \
57         ANSR_LOGE("Failed to read %s", msg);             \
58         return false;                                    \
59     }                                                    \
60 
61 #define READ_UINT32_RETURN_FALSE_LOG(parcel, value, msg) \
62     if (!((parcel).ReadUint32(value))) {                 \
63         ANSR_LOGE("Failed to read %s", msg);             \
64         return false;                                    \
65     }                                                    \
66 
67 #define READ_UINT16_RETURN_FALSE_LOG(parcel, value, msg) \
68     if (!((parcel).ReadUint16(value))) {                 \
69         ANSR_LOGE("Failed to read %s", msg);             \
70         return false;                                    \
71     }                                                    \
72 
73 #define READ_UINT8_RETURN_FALSE_LOG(parcel, value, msg) \
74     if (!((parcel).ReadUint8(value))) {                 \
75         ANSR_LOGE("Failed to read %s", msg);            \
76         return false;                                   \
77     }                                                   \
78 
79 #define WRITE_STRING_RETURN_FALSE_LOG(parcel, value, msg) \
80     if (!((parcel).WriteString(value))) {                 \
81         ANSR_LOGE("Failed to write %s", msg);             \
82         return false;                                     \
83     }                                                     \
84 
85 #define WRITE_BOOL_RETURN_FALSE_LOG(parcel, value, msg) \
86     if (!((parcel).WriteBool(value))) {                 \
87         ANSR_LOGE("Failed to write %s", msg);           \
88         return false;                                   \
89     }                                                   \
90 
91 #define WRITE_INT64_RETURN_FALSE_LOG(parcel, value, msg) \
92     if (!(parcel.WriteInt64(value))) {                   \
93         ANSR_LOGE("Failed to write %s", msg);            \
94         return false;                                    \
95     }                                                    \
96 
97 #define WRITE_INT32_RETURN_FALSE_LOG(parcel, value, msg) \
98     if (!((parcel).WriteInt32(value))) {                 \
99         ANSR_LOGE("Failed to write %s", msg);            \
100         return false;                                    \
101     }                                                    \
102 
103 #define WRITE_UINT64_RETURN_FALSE_LOG(parcel, value, msg) \
104     if (!((parcel).WriteUint64(value))) {                 \
105         ANSR_LOGE("Failed to write %s", msg);             \
106         return false;                                     \
107     }                                                     \
108 
109 #define WRITE_UINT32_RETURN_FALSE_LOG(parcel, value, msg) \
110     if (!((parcel).WriteUint32(value))) {                 \
111         ANSR_LOGE("Failed to write %s", msg);             \
112         return false;                                     \
113     }                                                     \
114 
115 #define WRITE_UINT16_RETURN_FALSE_LOG(parcel, value, msg) \
116     if (!((parcel).WriteUint16(value))) {                 \
117         ANSR_LOGE("Failed to write %s", msg);             \
118         return false;                                     \
119     }                                                     \
120 
121 #define WRITE_UINT8_RETURN_FALSE_LOG(parcel, value, msg) \
122     if (!((parcel).WriteUint8(value))) {                 \
123         ANSR_LOGE("Failed to write %s", msg);            \
124         return false;                                    \
125     }                                                    \
126 
127 class ReminderRequest : public Parcelable {
128 public:
129     /**
130      * @brief Supported reminder type.
131      */
132     enum class ReminderType : uint8_t {
133         /**
134          * Indicates the classification of reminder for timer.
135          */
136         TIMER,
137 
138         /**
139          * Indicates the classification of reminder for calendar.
140          */
141         CALENDAR,
142 
143         /**
144          * Indicates the classification of reminder for alarm.
145          */
146         ALARM,
147         INVALID
148     };
149 
150     /**
151      * @brief Supported action button type.
152      */
153     enum class ActionButtonType : uint8_t {
154         /**
155          * @brief Indicates that this action button is used to close reminder's notification.
156          * It always works well, whether the application is running at the time.
157          *
158          */
159         CLOSE,
160 
161         /**
162          * @brief Indicates that this action button is used to snooze reminder.
163          * It always work well, whether the application is running at the time.
164          *
165          */
166         SNOOZE,
167 
168         /**
169          * @brief Indicates that this action button is custom.
170          *
171          */
172         CUSTOM,
173         INVALID
174     };
175 
176     /**
177      * @brief Supported notification update type.
178      */
179     enum class UpdateNotificationType : uint8_t {
180         COMMON,
181         REMOVAL_WANT_AGENT,
182         WANT_AGENT,
183         MAX_SCREEN_WANT_AGENT,
184         BUNDLE_INFO,
185         CONTENT
186     };
187 
188     /**
189      * @brief Enumerates the Time type for converting between c time and acture time.
190      */
191     enum class TimeTransferType : uint8_t {
192         YEAR,
193         MONTH,
194         WEEK
195     };
196 
197     /**
198      * @brief Enumerates the Time format for print.
199      */
200     enum class TimeFormat : uint8_t {
201         YMDHMS,
202         HM
203     };
204 
205     struct ButtonWantAgent {
206         std::string pkgName = "";
207         std::string abilityName = "";
208     };
209 
210     struct ButtonDataShareUpdate {
211         std::string uri = "";
212         std::string equalTo = "";
213         std::string valuesBucket = "";
214     };
215     /**
216      * @brief Attributes of action button.
217      */
218     struct ActionButtonInfo {
219         /**
220          * Type of the button.
221          */
222         ActionButtonType type;
223 
224         /**
225          * Content show on the button.
226          */
227         std::string title = "";
228 
229         /**
230          * resource key(for language)
231          */
232         std::string resource = "";
233 
234         /**
235          * The ability that is redirected to when the button is clicked.
236          */
237         std::shared_ptr<ButtonWantAgent> wantAgent;
238 
239         /**
240          * The ability that is updata App rdb.
241          */
242         std::shared_ptr<ButtonDataShareUpdate> dataShareUpdate;
243     };
244 
245     /**
246      * @brief Want agent information. Indicates the package and the ability to switch to.
247      */
248     struct WantAgentInfo {
249         std::string pkgName = "";
250         std::string abilityName = "";
251         std::string uri = "";
252     };
253 
254     struct MaxScreenAgentInfo {
255         std::string pkgName = "";
256         std::string abilityName = "";
257     };
258 
259     /**
260      * @brief Copy construct from an exist reminder.
261      *
262      * @param Indicates the exist reminder.
263      */
264     explicit ReminderRequest(const ReminderRequest &other);
265 
266     /**
267      * @brief This constructor should only be used in background proxy service process
268      * when reminder instance recovery from database.
269      *
270      * @param reminderId Indicates reminder id.
271      */
272     explicit ReminderRequest(int32_t reminderId);
273     ReminderRequest& operator = (const ReminderRequest &other);
~ReminderRequest()274     virtual ~ReminderRequest() override {};
275 
276     /**
277      * @brief Marshal a NotificationRequest object into a Parcel.
278      *
279      * @param parcel the object into the parcel
280      */
281     virtual bool Marshalling(Parcel &parcel) const override;
282 
283     /**
284      * @brief Unmarshal object from a Parcel.
285      *
286      * @return the NotificationRequest
287      */
288     static ReminderRequest *Unmarshalling(Parcel &parcel);
289     virtual bool ReadFromParcel(Parcel &parcel);
290 
291     /**
292      * @brief If the reminder is showing on the notification panel, it should not be removed automatically.
293      *
294      * @return true if it can be removed automatically.
295      */
296     bool CanRemove() const;
297 
298     bool CanShow() const;
299 
300     /**
301      * @brief Obtains all the information of the reminder.
302      *
303      * @return Information of the reminder.
304      */
305     std::string Dump() const;
306 
307     /**
308      * @brief Obtains the configured action buttons.
309      *
310      * @return map of action buttons.
311      */
312     std::map<ActionButtonType, ActionButtonInfo> GetActionButtons() const;
313 
314     /**
315      * @brief Obtains creator bundle name
316      *
317      * @return creator bundle name
318      */
319     std::string GetCreatorBundleName() const;
320 
321     /**
322      * @brief Obtains the configured content.
323      *
324      * @return content text.
325      */
326     std::string GetContent() const;
327 
328     /**
329      * @brief Obtains the configured expired content.
330      *
331      * @return expired content text.
332      */
333     std::string GetExpiredContent() const;
334 
335     std::shared_ptr<MaxScreenAgentInfo> GetMaxScreenWantAgentInfo() const;
336 
337     /**
338      * @brief Obtains notification id.
339      *
340      * @return notification id.
341      */
342     int32_t GetNotificationId() const;
343 
344     /**
345      * @brief Obtains group id.
346      *
347      * @return group id.
348      */
349     std::string GetGroupId() const;
350 
351     /**
352      * @brief Obtains notification request.
353      *
354      * @return notification request instance.
355      */
356     sptr<NotificationRequest> GetNotificationRequest() const;
357 
358     /**
359      * @brief Obtains reminder id.
360      *
361      * @return reminder id.
362      */
363     int32_t GetReminderId() const;
364 
365     uint64_t GetReminderTimeInMilli() const;
366 
367     /**
368      * @brief Obtains reminder type.
369      *
370      * @return reminder type.
371      */
372     ReminderType GetReminderType() const;
373 
374     /**
375      * @brief Obtains the ringing or vibration duration configured for this reminder.
376      *
377      * @return uint16_t The ringing or vibration duration in seconds.
378      */
379     uint16_t GetRingDuration() const;
380 
381     /**
382      * @brief Obtains slot type.
383      *
384      * @return slot type.
385      */
386     NotificationConstant::SlotType GetSlotType() const;
387 
388     /**
389      * @brief Obtains snoozeSlot type.
390      *
391      * @return snoozeSlot type.
392      */
393     NotificationConstant::SlotType GetSnoozeSlotType() const;
394 
395     std::string GetSnoozeContent() const;
396     uint8_t GetSnoozeTimes() const;
397     uint8_t GetSnoozeTimesDynamic() const;
398     uint8_t GetState() const;
399 
400     /**
401      * @brief Obtains the Time Interval in seconds.
402      *
403      * @return uint64_t Time Interval in seconds.
404      */
405     uint64_t GetTimeInterval() const;
406 
407     /**
408      * @brief Obtains title.
409      *
410      * @return title.
411      */
412     std::string GetTitle() const;
413 
414     /**
415      * @brief Obtains trigger time in milli.
416      *
417      * @return trigger time.
418      */
419     uint64_t GetTriggerTimeInMilli() const;
420 
421     int32_t GetUserId() const;
422     int32_t GetUid() const;
423 
424     /**
425      * @brief Obtains bundle name
426      *
427      * @return bundle name
428      */
429     std::string GetBundleName() const;
430 
431     /**
432      * @brief Set the app system.
433      *
434      */
435     void SetSystemApp(bool isSystem);
436 
437     /**
438      * @brief Check the app is system or not.
439      *
440      * @return true is the app is system.
441      */
442     bool IsSystemApp() const;
443 
444     /**
445      * @brief Obtains want agent information.
446      *
447      * @return want agent information.
448      */
449     std::shared_ptr<WantAgentInfo> GetWantAgentInfo() const;
450 
451     /**
452      * @brief Inites reminder creator bundle name when publish reminder success.
453      *
454      * @param creatorBundleName Indicates the creator bundle name which the reminder belong to
455      */
456     void InitCreatorBundleName(const std::string &creatorBundleName);
457 
458     /**
459      * @brief Inits reminder id when publish reminder success.
460      * Assign a unique reminder id for each reminder.
461      */
462     void InitReminderId();
463 
464     /**
465      * @brief Inits reminder userId when publish reminder success.
466      *
467      * When package remove, user id is sended by wantAgent, but we cannot get the uid according user id as the
468      * package has been removed, and the bundleOption can not be create with correct uid. so we need to record
469      * the user id, and use it to judge which user the reminder belong to.
470      *
471      * @param userId Indicates the userId which the reminder belong to.
472      */
473     void InitUserId(const int32_t &userId);
474 
475     /**
476      * @brief Inites reminder uid when publish reminder success.
477      *
478      * When system reboot and recovery from database, we cannot get the uid according user id as BMS has not be
479      * ready. So we need to record the uid in order to create correct bundleOption.
480      *
481      * @param uid Indicates the uid which the reminder belong to.
482      */
483     void InitUid(const int32_t &uid);
484 
485     /**
486      * @brief Inites reminder bundle name when publish reminder success.
487      *
488      * @param bundleName Indicates the bundle name which the reminder belong to
489      */
490     void InitBundleName(const std::string &bundleName);
491 
492     /**
493      * @brief Check the reminder is alerting or not.
494      *
495      * @return true if the reminder is playing sound or vibrating.
496      */
497     bool IsAlerting() const;
498 
499     /**
500      * @brief Check the reminder is expired or not.
501      *
502      * @return true is the reminder is expired.
503      */
504     bool IsExpired() const;
505 
506     /**
507      * @brief Check the reminder is showing on the panel.
508      *
509      * @return true if the reminder is showing on the panel.
510      */
511     bool IsShowing() const;
512 
513     /**
514      * @brief Closes the reminder by manual.
515      *
516      * 1) Resets the state of "Alering/Showing/Snooze"
517      * 2) Resets snoozeTimesDynamic_ if update to next trigger time, otherwise set reminder to expired.
518      *
519      * @param updateNext Whether to update to next reminder.
520      */
521     void OnClose(bool updateNext);
522 
523     /**
524      * @brief When date/time change, reminder need to refresh next trigger time.
525      *
526      * @return true if need to show reminder immediately.
527      */
528     virtual bool OnDateTimeChange();
529 
530     /**
531      * When shown notification is covered by a new notification with the same id, we should remove
532      * the state of showing, so that the reminder can be removed automatically when it is expired.
533      */
534     void OnSameNotificationIdCovered();
535 
536     /**
537      * Set the reminder state is InActive, so that it will be removed when expired
538      */
539     void SetStateToInActive();
540 
541     /**
542      * @brief Shows the reminder on panel. TriggerTime will be updated to next.
543      *
544      * @param isPlaySoundOrVibration true means it is play sound or vibration.
545      * @param isSysTimeChanged true means it is called when the system time is changed by user, otherwise false.
546      * @param allowToNotify true means that the notification will be shown as normal, otherwise false.
547      */
548     void OnShow(bool isPlaySoundOrVibration, bool isSysTimeChanged, bool allowToNotify);
549 
550     /**
551      * @brief Reset the state of "Showing" when the reminder is shown failed.
552      */
553     void OnShowFail();
554 
555     /**
556      * @brief Snooze the reminder by manual.
557      *
558      * 1) Updates the trigger time to the next one.
559      * 2) Updates the notification content for "Snooze".
560      * 3) Switches the state from "Showing[, Alerting]" to "Snooze".
561      */
562     bool OnSnooze();
563 
564     /**
565      * @brief Starts the reminder
566      *
567      * Sets the state from "Inactive" to "Active".
568      */
569     void OnStart();
570 
571     /**
572      * @brief Stops the reminder.
573      *
574      * Sets the state from "Active" to "Inactive".
575      */
576     void OnStop();
577 
578     /**
579      * @brief Terminate the alerting reminder, which is executed when the ring duration is over.
580      *
581      * 1) Disables the state of "Alerting".
582      * 2) Updates the notification content for "Alert".
583      *
584      * @return false if alerting state has already been set false before calling the method.
585      */
586     bool OnTerminate();
587 
588     /**
589      * @brief When timezone change, reminder need to refresh next trigger time.
590      *
591      * @return true if need to show reminder immediately.
592      */
593     virtual bool OnTimeZoneChange();
594 
595     /**
596      * @brief Recovery reminder instance from database record.
597      *
598      * @param resultSet Indicates the resultSet with pointer to the row of record data.
599      */
600     virtual void RecoverFromDb(const std::shared_ptr<NativeRdb::ResultSet> &resultSet);
601 
602     /**
603      * @brief Sets action button.
604      *
605      * @param title Indicates the title of the button.
606      * @param type Indicates the type of the button.
607      * @param resource Indicates the resource of the button.
608      * @return Current reminder self.
609      */
610     ReminderRequest& SetActionButton(const std::string &title, const ActionButtonType &type,
611         const std::string &resource, const std::shared_ptr<ButtonWantAgent> &buttonWantAgent = nullptr,
612         const std::shared_ptr<ButtonDataShareUpdate> &buttonDataShareUpdate = nullptr);
613 
614     /**
615      * @brief Sets reminder content.
616      *
617      * @param content Indicates content text.
618      * @return Current reminder self.
619      */
620     ReminderRequest& SetContent(const std::string &content);
621 
622     /**
623      * @brief Sets reminder is expired or not.
624      *
625      * @param isExpired Indicates the reminder is expired or not.
626      */
627     void SetExpired(bool isExpired);
628 
629     /**
630      * @brief Sets expired content.
631      *
632      * @param expiredContent Indicates expired content.
633      * @return Current reminder self.
634      */
635     ReminderRequest& SetExpiredContent(const std::string &expiredContent);
636 
637     ReminderRequest& SetMaxScreenWantAgentInfo(const std::shared_ptr<MaxScreenAgentInfo> &maxScreenWantAgentInfo);
638 
639     /**
640      * @brief Sets notification id.
641      *
642      * @param notificationId Indicates notification id.
643      * @return Current reminder self.
644      */
645     ReminderRequest& SetNotificationId(int32_t notificationId);
646 
647     /**
648      * @brief Sets group id.
649      *
650      * @param notificationId Indicates group id.
651      * @return Current reminder self.
652      */
653     ReminderRequest& SetGroupId(const std::string &groupId);
654 
655     /**
656      * @brief Sets reminder id.
657      *
658      * @param reminderId Indicates reminder id.
659      */
660     void SetReminderId(int32_t reminderId);
661 
662     void SetReminderTimeInMilli(const uint64_t reminderTimeInMilli);
663 
664     /**
665      * @brief Sets the ringing or vibration duration for this reminder, in seconds.
666      *
667      * @param ringDurationInSeconds Indicates the duration. The default is 1 second.
668      * @return Current reminder self.
669      */
670     ReminderRequest& SetRingDuration(const uint64_t ringDurationInSeconds);
671 
672     /**
673      * @brief Sets slot type.
674      *
675      * @param slotType Indicates slot type.
676      * @return Current reminder self.
677      */
678     ReminderRequest& SetSlotType(const NotificationConstant::SlotType &slotType);
679     ReminderRequest& SetSnoozeSlotType(const NotificationConstant::SlotType &snoozeSlotType);
680     ReminderRequest& SetSnoozeContent(const std::string &snoozeContent);
681 
682     /**
683      * @brief Set the number of snooze times for this reminder.
684      *
685      * @note If the value of snoozeTimes is less than or equals to 0, this reminder is a one-shot
686      * reminder and will not be snoozed.
687      *
688      * It the value of snoozeTimes is greater than 0, for example, snoozeTimes=3, this reminder
689      * will be snoozed three times after the first alarm, that is, this reminder will be triggered
690      * for four times.
691      *
692      * This method does not take affect on the reminders for countdown timers.
693      *
694      * @param snoozeTimes Indicates the number of times that the reminder will be snoozed.
695      * @return ReminderRequest& Current reminder self.
696      */
697     ReminderRequest& SetSnoozeTimes(const uint8_t snoozeTimes);
698 
699     ReminderRequest& SetSnoozeTimesDynamic(const uint8_t snooziTimes);
700 
701     /**
702      * @brief Sets the Time Interval for this reminder, in seconds. The default value is 0.
703      *
704      * @note The minimum snooze interval is 5 minute. If the snooze interval is set to a value greater
705      * than 0 and less than 5 minutes, the system converts it to 5 minutes by default.
706      *
707      * This method does not take effect on the reminders for countdown timers.
708      *
709      * @param timeIntervalInSeconds Indicates the snooze interval to set. If the value is less or equals to 0,
710      * the reminder will not be snoozed.
711      * @return ReminderRequest& Current reminder self.
712      */
713     ReminderRequest& SetTimeInterval(const uint64_t timeIntervalInSeconds);
714 
715     /**
716      * @brief Sets title.
717      *
718      * @param title Indicates title.
719      * @return Current reminder self.
720      */
721     ReminderRequest& SetTitle(const std::string &title);
722 
723     /**
724      * @brief Sets trigger time.
725      *
726      * @param triggerTimeInMilli Indicates trigger time in milli.
727      */
728     void SetTriggerTimeInMilli(uint64_t triggerTimeInMilli);
729 
730     /**
731      * @brief Sets want agent information.
732      *
733      * @param wantAgentInfo Indicates want agent information.
734      * @return Current reminder self.
735      */
736     ReminderRequest& SetWantAgentInfo(const std::shared_ptr<WantAgentInfo> &wantAgentInfo);
737 
738     bool ShouldShowImmediately() const;
739 
740     /**
741      * @brief Updates {@link triggerTimeInMilli_} to next.
742      * @note If next trigger time not exist, {@link isExpired_} flag will be set with true.
743      *
744      * @return true if next trigger time exist and set success.
745      */
746     virtual bool UpdateNextReminder();
747     virtual bool SetNextTriggerTime();
748 
749     /**
750      * @brief Sets tapDismissed.
751      *
752      * @param tapDismissed Indicates tapDismissed.
753      */
754     void SetTapDismissed(bool tapDismissed);
755 
756     /**
757      * @brief Gets tapDismissed.
758      *
759      * @return True if tapDismissed.
760      */
761     bool IsTapDismissed() const;
762 
763     /**
764      * @brief Sets autoDeletedTime.
765      *
766      * @param autoDeletedTime Indicates autoDeletedTime.
767      */
768     void SetAutoDeletedTime(int64_t autoDeletedTime);
769 
770     /**
771      * @brief Gets autoDeletedTime.
772      *
773      * @return AutoDeletedTime.
774      */
775     int64_t GetAutoDeletedTime() const;
776 
777     /**
778      * @brief Sets custom button uri.
779      *
780      * @param uri Indicates uri.
781      */
782     void SetCustomButtonUri(const std::string &uri);
783 
784     /**
785      * @brief Gets custom button uri.
786      *
787      * @return custom button uri.
788      */
789     std::string GetCustomButtonUri() const;
790 
791     /**
792      * @brief Gets custom ring uri.
793      *
794      * @return custom ring uri.
795      */
796     std::string GetCustomRingUri() const;
797 
798      /**
799      * @brief Sets custom ring uri.
800      *
801      * @param uri Indicates uri.
802      */
803     void SetCustomRingUri(const std::string &uri);
804 
805     /**
806      * @brief Update notification attributes.
807      *
808      * Some attributes need to be updated after the reminder published or before the notification publish.
809      * For example, action button should not init until the reminder is published successfully, as the reminder id is
810      * assigned after that.
811      *
812      * @param type Indicates the update type.
813      * @param extra Indicates the extra content.
814      */
815     void UpdateNotificationRequest(UpdateNotificationType type, std::string extra);
816 
817     /**
818      * @brief Get repeated days of the week.
819      *
820      * @return  Array of the int type.
821      */
822     std::vector<int32_t> GetDaysOfWeek() const;
823 
824     /**
825      * @brief When system language change, will call this function.
826      *     need load resource to update button title
827      * @param resMgr Indicates the resource manager for get button title
828      */
829     void OnLanguageChange(const std::shared_ptr<Global::Resource::ResourceManager> &resMgr);
830 
831     static int32_t GetActualTime(const TimeTransferType &type, int32_t cTime);
832     static int32_t GetCTime(const TimeTransferType &type, int32_t actualTime);
833     static uint64_t GetDurationSinceEpochInMilli(const time_t target);
834     static int32_t GetUid(const int32_t &userId, const std::string &bundleName);
835     static int32_t GetUserId(const int32_t &uid);
836     static void AppendValuesBucket(const sptr<ReminderRequest> &reminder,
837         const sptr<NotificationBundleOption> &bundleOption, NativeRdb::ValuesBucket &values);
838     static std::vector<std::string> StringSplit(std::string source, const std::string &split);
839 
840     static int32_t GLOBAL_ID;
841     static const uint64_t INVALID_LONG_LONG_VALUE;
842     static const uint16_t INVALID_U16_VALUE;
843     static const uint8_t INVALID_U8_VALUE;
844     static const uint16_t MILLI_SECONDS;
845     static const uint16_t SAME_TIME_DISTINGUISH_MILLISECONDS;
846     static const std::string NOTIFICATION_LABEL;
847     static const uint8_t MONDAY;
848     static const uint8_t SUNDAY;
849     static const uint8_t DAYS_PER_WEEK;
850     static const uint8_t HOURS_PER_DAY;
851     static const uint16_t SECONDS_PER_HOUR;
852     static const uint8_t MINUTES_PER_HOUR;
853     /**
854      * @brief Show the reminder with a notification.
855      */
856     static const std::string REMINDER_EVENT_ALARM_ALERT;
857 
858     /**
859      * @brief Close the reminder when click the close button of notification.
860      */
861     static const std::string REMINDER_EVENT_CLOSE_ALERT;
862 
863     /**
864      * @brief Snooze the reminder when click the snooze button of notification.
865      */
866     static const std::string REMINDER_EVENT_SNOOZE_ALERT;
867 
868     static const std::string REMINDER_EVENT_CUSTOM_ALERT;
869 
870     /**
871      * @brief Used to control ring duration.
872      */
873     static const std::string REMINDER_EVENT_ALERT_TIMEOUT;
874 
875     /**
876      * @brief Update the reminder when remove notification from the systemUI.
877      */
878     static const std::string REMINDER_EVENT_REMOVE_NOTIFICATION;
879     static const std::string PARAM_REMINDER_ID;
880     static const uint8_t REMINDER_STATUS_INACTIVE;
881     static const uint8_t REMINDER_STATUS_ACTIVE;
882     static const uint8_t REMINDER_STATUS_ALERTING;
883     static const uint8_t REMINDER_STATUS_SHOWING;
884     static const uint8_t REMINDER_STATUS_SNOOZE;
885     static const uint8_t TIME_HOUR_OFFSET;
886 
887     // For database recovery.
888     static void InitDbColumns();
889     static const std::string REMINDER_ID;
890     static const std::string PKG_NAME;
891     static const std::string USER_ID;
892     static const std::string UID;
893     static const std::string SYS_APP;
894     static const std::string APP_LABEL;
895     static const std::string REMINDER_TYPE;
896     static const std::string REMINDER_TIME;
897     static const std::string TRIGGER_TIME;
898     static const std::string RTC_TRIGGER_TIME;
899     static const std::string TIME_INTERVAL;
900     static const std::string SNOOZE_TIMES;
901     static const std::string DYNAMIC_SNOOZE_TIMES;
902     static const std::string RING_DURATION;
903     static const std::string IS_EXPIRED;
904     static const std::string IS_ACTIVE;
905     static const std::string STATE;
906     static const std::string ZONE_ID;
907     static const std::string HAS_SCHEDULED_TIMEOUT;
908     static const std::string ACTION_BUTTON_INFO;
909     static const std::string CUSTOM_BUTTON_URI;
910     static const std::string SLOT_ID;
911     static const std::string SNOOZE_SLOT_ID;
912     static const std::string NOTIFICATION_ID;
913     static const std::string TITLE;
914     static const std::string CONTENT;
915     static const std::string SNOOZE_CONTENT;
916     static const std::string EXPIRED_CONTENT;
917     static const std::string AGENT;
918     static const std::string MAX_SCREEN_AGENT;
919     static const std::string TAP_DISMISSED;
920     static const std::string AUTO_DELETED_TIME;
921     static const std::string REPEAT_DAYS_OF_WEEK;
922     static const std::string GROUP_ID;
923     static const std::string CUSTOM_RING_URI;
924     static std::string sqlOfAddColumns;
925     static std::vector<std::string> columns;
926 
927     // For ActionButtonDataShare.
928     static const std::string SEP_BUTTON_VALUE_TYPE;
929     static const std::string SEP_BUTTON_VALUE;
930     static const std::string SEP_BUTTON_VALUE_BLOB;
931 
932 protected:
933     enum class DbRecoveryType : uint8_t {
934         INT,
935         LONG
936     };
937     ReminderRequest();
938     explicit ReminderRequest(ReminderType reminderType);
939     std::string GetDateTimeInfo(const time_t &timeInSecond) const;
PreGetNextTriggerTimeIgnoreSnooze(bool ignoreRepeat,bool forceToGetNext)940     virtual uint64_t PreGetNextTriggerTimeIgnoreSnooze(bool ignoreRepeat, bool forceToGetNext) const
941     {
942         return INVALID_LONG_LONG_VALUE;
943     }
944 
945     int64_t RecoverInt64FromDb(const std::shared_ptr<NativeRdb::ResultSet> &resultSet,
946         const std::string &columnName, const DbRecoveryType &columnType);
947 
948     /**
949      * @brief For database recovery.
950      *
951      * Add column to create table of database.
952      *
953      * @param name Indicates the column name.
954      * @param type Indicates the type of the column.
955      * @param isEnd Indicates whether it is the last column.
956      */
957     static void AddColumn(const std::string &name, const std::string &type, const bool &isEnd);
958 
959     uint8_t repeatDaysOfWeek_{0};
960 
961     /**
962      * Obtains the next triggerTime if it is a week repeat.
963      *
964      * @param now Indicates current time.
965      * @param now Indicatet target time.
966      * @return nextTriggerTime.
967      */
968     int64_t GetNextDaysOfWeek(const time_t now, const time_t target) const;
969     void SetRepeatDaysOfWeek(bool set, const std::vector<uint8_t> &daysOfWeek);
970     uint8_t GetRepeatDaysOfWeek() const;
971     time_t GetTriggerTimeWithDST(const time_t now, const time_t nextTriggerTime) const;
972     uint64_t GetTriggerTime(const time_t now, const time_t nextTriggerTime) const;
973 
974 private:
975     void AddActionButtons(const bool includeSnooze);
976     void AddRemovalWantAgent();
977     std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> CreateWantAgent(AppExecFwk::ElementName &element,
978         bool isWantAgent) const;
979     std::string GetButtonInfo() const;
980     uint64_t GetNowInstantMilli() const;
981     std::string GetShowTime(const uint64_t showTime) const;
982     std::string GetTimeInfoInner(const time_t &timeInSecond, const TimeFormat &format, bool keep24Hour) const;
983     std::string GetState(const uint8_t state) const;
984     bool HandleSysTimeChange(uint64_t oriTriggerTime, uint64_t optTriggerTime);
985     bool HandleTimeZoneChange(uint64_t oldZoneTriggerTime, uint64_t newZoneTriggerTime, uint64_t optTriggerTime);
986     bool InitNotificationRequest();
987     void InitServerObj();
988     void SetMaxScreenWantAgent(AppExecFwk::ElementName &element);
989     void SetState(bool deSet, const uint8_t newState, std::string function);
990     void SetWantAgent(AppExecFwk::ElementName &element);
991     void UpdateActionButtons(const bool &setSnooze);
992     bool UpdateNextReminder(const bool &force);
993     void UpdateNotificationContent(const bool &setSnooze);
994     void UpdateNotificationCommon(bool isSnooze);
995 
996     /**
997      * @brief Determine whether it is repeated every week.
998      *
999      * @return  True if repeate.
1000      */
1001     bool IsRepeatDaysOfWeek(int32_t day) const;
1002 
1003     /**
1004      * @brief Used for reminder recovery from database.
1005      *
1006      * @param bundleName Indicates the third part bundle name.
1007      */
1008     void UpdateNotificationBundleInfo();
1009 
1010     /**
1011      * @brief Update the notification, which will be shown for the "Alerting" reminder.
1012      * 1. Update the notification label/content.
1013      * 2. Restore the snooze action button.
1014      */
1015     void UpdateNotificationStateForAlert();
1016 
1017     /**
1018      * @brief Update the notification, which will be shown when user do a snooze.
1019      * 1. Update the notification label/content.
1020      * 2. Remove the snooze action button.
1021      */
1022     void UpdateNotificationStateForSnooze();
1023 
1024     static void AppendWantAgentValuesBucket(const sptr<ReminderRequest>& reminder,
1025         NativeRdb::ValuesBucket& values);
1026 
1027     bool MarshallingActionButton(Parcel& parcel) const;
1028     bool ReadActionButtonFromParcel(Parcel& parcel);
1029 
1030     void RecoverBasicFromDb(const std::shared_ptr<NativeRdb::ResultSet>& resultSet);
1031     void RecoverActionButtonJsonMode(const std::string& jsonString);
1032     void RecoverActionButton(const std::shared_ptr<NativeRdb::ResultSet>& resultSet);
1033     void RecoverWantAgent(const std::string& wantAgentInfo, const uint8_t& type);
1034 
1035     static const uint32_t MIN_TIME_INTERVAL_IN_MILLI;
1036     static const std::string SEP_BUTTON_SINGLE;
1037     static const std::string SEP_BUTTON_MULTI;
1038     static const std::string SEP_WANT_AGENT;
1039 
1040     std::string content_ {};
1041     std::string expiredContent_ {};
1042     std::string snoozeContent_ {};
1043     std::string displayContent_ {};
1044     std::string title_ {};
1045     std::string bundleName_ {};
1046     bool isExpired_ {false};
1047     uint8_t snoozeTimes_ {0};
1048     uint8_t snoozeTimesDynamic_ {0};
1049     uint8_t state_ {0};
1050     int32_t notificationId_ {0};
1051     std::string groupId_ {};
1052     int32_t reminderId_ {-1};
1053     int32_t userId_ {-1};
1054     int32_t uid_ {-1};
1055     bool isSystemApp_ {false};
1056     bool tapDismissed_ {true};
1057     int64_t autoDeletedTime_ {0};
1058     std::string customButtonUri_ {};
1059     std::string customRingUri_ {};
1060     std::string creatorBundleName_ {};
1061 
1062     // Indicates the reminder has been shown in the past time.
1063     // When the reminder has been created but not showed, it is equals to 0.
1064     uint64_t reminderTimeInMilli_ {0};
1065     uint64_t ringDurationInMilli_ {MILLI_SECONDS};
1066     uint64_t triggerTimeInMilli_ {0};
1067     uint64_t timeIntervalInMilli_ {0};
1068     ReminderType reminderType_ {ReminderType::INVALID};
1069     NotificationConstant::SlotType slotType_ {NotificationConstant::SlotType::SOCIAL_COMMUNICATION};
1070     NotificationConstant::SlotType snoozeSlotType_ {NotificationConstant::SlotType::OTHER};
1071     sptr<NotificationRequest> notificationRequest_ = nullptr;
1072     std::shared_ptr<WantAgentInfo> wantAgentInfo_ = nullptr;
1073     std::shared_ptr<MaxScreenAgentInfo> maxScreenWantAgentInfo_ = nullptr;
1074     std::map<ActionButtonType, ActionButtonInfo> actionButtonMap_ {};
1075 };
1076 }  // namespace Reminder
1077 }  // namespace OHOS
1078 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_REMINDER_REQUEST_H