• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_NOTIFICATION_REQUEST_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_REQUEST_H
18 
19 #include "ans_const_define.h"
20 #include "message_user.h"
21 #include "notification_action_button.h"
22 #include "notification_constant.h"
23 #include "notification_content.h"
24 #include "notification_distributed_options.h"
25 #include "notification_flags.h"
26 #include "notification_json_convert.h"
27 #include "notification_template.h"
28 #include "parcel.h"
29 #include "pixel_map.h"
30 #include "want_agent.h"
31 #include "want_params.h"
32 #include "notification_check_request.h"
33 #include "notification_bundle_option.h"
34 
35 namespace OHOS {
36 namespace Notification {
37 
38 inline const std::string REQUEST_STORAGE_KEY_PREFIX {"ans_live_view"};
39 
40 struct NotificationKey {
41     int32_t id {};
42     std::string label {};
43 };
44 
45 struct LiveViewFilter {
46     NotificationBundleOption bundle;
47     NotificationKey notificationKey;
48     std::vector<std::string> extraInfoKeys;
49 };
50 
51 class NotificationRequest : public Parcelable, public NotificationJsonConvertionBase {
52 public:
53     enum class BadgeStyle {
54         /**
55          * displays only numbers.
56          */
57         NONE,
58         /**
59          * displayed as a large icon.
60          */
61         BIG,
62         /**
63          * displayed as a small icon.
64          */
65         LITTLE
66     };
67 
68     enum class GroupAlertType {
69         /**
70          * all notifications in a group have sound or vibration if sound or vibration is enabled
71          * for the associated NotificationSlot objects.
72          */
73         ALL,
74         /**
75          * child notifications have sound or vibration but the overview notification is muted (no sound or vibration)
76          * in a group if sound or vibration is enabled for the associated NotificationSlot objects.
77          */
78         CHILD,
79         /**
80          * the overview notification has sound or vibration but child notifications are muted (no sound or vibration)
81          * in a group if sound or vibration is enabled for the associated NotificationSlot objects.
82          */
83         OVERVIEW
84     };
85 
86     /**
87      * Indicates the classification of notifications for alarms or timers.
88      */
89     static const std::string CLASSIFICATION_ALARM;
90     /**
91      * Indicates the classification of notifications for incoming calls or similar synchronous communication requests.
92      */
93     static const std::string CLASSIFICATION_CALL;
94     /**
95      * Indicates the classification of notifications for emails.
96      */
97     static const std::string CLASSIFICATION_EMAIL;
98     /**
99      * Indicates the classification of notifications for errors occurred during background operations or identity
100      * authentication.
101      */
102     static const std::string CLASSIFICATION_ERROR;
103     /**
104      * Indicates the classification of notifications for calendar events.
105      */
106     static const std::string CLASSIFICATION_EVENT;
107     /**
108      * Indicates the classification of notifications for short messages or instant messages.
109      */
110     static const std::string CLASSIFICATION_MESSAGE;
111     /**
112      * Indicates the classification of notifications for map navigation.
113      */
114     static const std::string CLASSIFICATION_NAVIGATION;
115     /**
116      * Indicates the classification of notifications for processes that are operated in the background for a long time.
117      */
118     static const std::string CLASSIFICATION_PROGRESS;
119     /**
120      * Indicates the classification of notifications for advertisement or promotion information.
121      */
122     static const std::string CLASSIFICATION_PROMO;
123     /**
124      * Indicates the classification of notifications for specific and timely recommendations of a particular
125      * transaction.
126      */
127     static const std::string CLASSIFICATION_RECOMMENDATION;
128     /**
129      * Indicates the classification of notifications for reminders previously set by the user.
130      */
131     static const std::string CLASSIFICATION_REMINDER;
132     /**
133      * Indicates the classification of notifications for ongoing background services.
134      */
135     static const std::string CLASSIFICATION_SERVICE;
136     /**
137      * Indicates the classification of notifications for social network or sharing updates.
138      */
139     static const std::string CLASSIFICATION_SOCIAL;
140     /**
141      * Indicates the classification of notifications for ongoing information about the device and contextual status.
142      */
143     static const std::string CLASSIFICATION_STATUS;
144     /**
145      * Indicates the classification of notifications for system or device status updates.
146      */
147     static const std::string CLASSIFICATION_SYSTEM;
148     /**
149      * Indicates the classification of notifications for media transport control during playback.
150      */
151     static const std::string CLASSIFICATION_TRANSPORT;
152 
153     /**
154      * Indicates the default notification background color, which means that no color is displayed.
155      */
156     static const uint32_t COLOR_DEFAULT;
157 
158 public:
159     NotificationRequest() = default;
160 
161     /**
162      * @brief A constructor used to create a NotificationRequest instance with the input parameter notificationId
163      * passed.
164      *
165      * @param notificationId Indicates notification ID.
166      */
167     explicit NotificationRequest(int32_t notificationId);
168 
169     /**
170      * @brief A constructor used to create a NotificationRequest instance by copying parameters from an existing one.
171      *
172      * @param other Indicates the existing object.
173      */
174     NotificationRequest(const NotificationRequest &other);
175 
176     /**
177      * @brief A constructor used to create a NotificationRequest instance by copying parameters from an existing one.
178      *
179      * @param other Indicates the existing object.
180      */
181     NotificationRequest &operator=(const NotificationRequest &other);
182 
183     virtual ~NotificationRequest();
184 
185     /**
186      * @brief Checks whether this notification is in progress.
187      *
188      * @return Returns true if this notification is in progress; returns false otherwise.
189      */
190     bool IsInProgress() const;
191 
192     /**
193      * @brief Sets whether this notification is in progress.
194      * Users cannot directly dismiss notifications in progress because
195      * they usually contain some ongoing background services such as music playback.
196      *
197      * @param isOngoing Specifies whether this notification is in progress.
198      */
199     void SetInProgress(bool isOngoing);
200 
201     /**
202      * @brief Checks whether this notification is unremovable.
203      *
204      * @return Returns true if this notification is unremovable; returns false otherwise.
205      */
206     bool IsUnremovable() const;
207 
208     /**
209      * @brief Sets whether this notification is unremovable.
210      * If it is set to be unremovable, it cannot be removed by users.
211      *
212      * @param isUnremovable Specifies whether this notification is unremovable.
213      */
214     void SetUnremovable(bool isUnremovable);
215 
216     /**
217      * @brief Sets the number to be displayed for this notification.
218      *
219      * @param number Indicates the number to set.
220      */
221     void SetBadgeNumber(uint32_t number);
222 
223     /**
224      * @brief Obtains the number to be displayed for this notification.
225      *
226      * @return Returns the number to be displayed for this notification.
227      */
228     uint32_t GetBadgeNumber() const;
229 
230     /**
231      * @brief Sets the current notification ID to uniquely identify the notification in the application.
232      * After a notification is received, its ID is obtained by using the getNotificationId() method.
233      *
234      * @param notificationId Indicates the ID of the notification to be set.
235      */
236     void SetNotificationId(int32_t notificationId);
237 
238     /**
239      * @brief Obtains the notification ID, which is unique in the current application.
240      *
241      * @return the notification ID.
242      */
243     int32_t GetNotificationId() const;
244 
245     /**
246      * @brief Adds an WantAgent to this notification.
247      * After a notification is tapped, subsequent operations such as ability and common events will be triggered as
248      * set by WantAgent.
249      *
250      * @param wantAgent Indicates the operation triggered by tapping the notification, which can be set by
251      * WantAgent.
252      */
253     void SetWantAgent(const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &wantAgent);
254 
255     /**
256      * @brief Obtains the WantAgent contained in this notification.
257      *
258      * @return Returns the WantAgent contained in this notification.
259      */
260     const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> GetWantAgent() const;
261 
262     /**
263      * @brief Sets an WantAgent object that is triggered when the user explicitly removes this notification.
264      *
265      * @param wantAgent Indicates the WantAgent object to be triggered.
266      */
267     void SetRemovalWantAgent(const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &wantAgent);
268 
269     /**
270      * @brief Obtains the WantAgent object that is triggered when the user explicitly removes this notification.
271      *
272      * @return Returns the WantAgent object to be triggered.
273      */
274     const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> GetRemovalWantAgent() const;
275 
276     /**
277      * @brief Sets the WantAgent to start when the device is not in use,
278      * instead of showing this notification in the status bar.
279      * When the device is in use, the system UI displays a pop-up notification
280      * instead of starting the WantAgent specified by maxScreenWantAgent.
281      * Your application must have the ohos.permission.USE_WHOLE_SCREEN permission to use this method.
282      *
283      * @param wantAgent Indicates the WantAgent object containing information about the to-be-started ability that
284      * uses the Page template.
285      */
286     void SetMaxScreenWantAgent(const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &wantAgent);
287 
288     /**
289      * @brief Obtains the full-screen WantAgent set by calling setMaxScreenWantAgent(WantAgent).
290      *
291      * @return Returns the full-screen WantAgent.
292      */
293     const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> GetMaxScreenWantAgent() const;
294 
295     /**
296      * @brief Sets extra parameters that are stored as key-value pairs for the notification.
297      *
298      * @param extras Indicates the WantParams object containing the extra parameters in key-value pair format.
299      */
300     void SetAdditionalData(const std::shared_ptr<AAFwk::WantParams> &extras);
301 
302     /**
303      * @brief Obtains the WantParams object set in the notification.
304      *
305      * @return Returns the WantParams object.
306      */
307     const std::shared_ptr<AAFwk::WantParams> GetAdditionalData() const;
308 
309     /**
310      * @brief Sets the time to deliver a notification.
311      *
312      * @param deliveryTime Indicates the time in milliseconds.
313      */
314     void SetDeliveryTime(int64_t deliveryTime);
315 
316     /**
317      * @brief Obtains the time when a notification is delivered.
318      *
319      * @return Returns the time in milliseconds.
320      */
321     int64_t GetDeliveryTime() const;
322 
323     /**
324      * @brief Checks whether the notification delivery time is displayed for this notification.
325      *
326      * @return Returns true if the time is displayed; returns false otherwise.
327      */
328     bool IsShowDeliveryTime() const;
329 
330     /**
331      * @brief Sets whether to show the notification delivery time for this notification.
332      * This method is valid only when the notification delivery time has been set by calling setDeliveryTime(int64_t).
333      *
334      * @param showDeliveryTime Specifies whether to show the notification delivery time.
335      */
336     void SetShowDeliveryTime(bool showDeliveryTime);
337 
338     /**
339      * @brief Adds a NotificationActionButton to this notification.
340      * An operation button is usually placed next to the notification content by the system.
341      * Each action button must contain an icon, a title, and an WantAgent. When a notification is expanded,
342      * a maximum of three action buttons can be displayed from left to right in the order they were added.
343      * When the notification is collapsed, no action buttons will be displayed.
344      *
345      * @param actionButton Indicates the NotificationActionButton object to add.
346      */
347     void AddActionButton(const std::shared_ptr<NotificationActionButton> &actionButton);
348 
349     /**
350      * @brief Obtains the list of all NotificationActionButton objects included in this notification.
351      *
352      * @return Returns the list of NotificationActionButton objects.
353      */
354     const std::vector<std::shared_ptr<NotificationActionButton>> GetActionButtons() const;
355 
356     /**
357      * @brief Clear the list of all NotificationActionButton objects included in this notification.
358      */
359     void ClearActionButtons();
360 
361     /**
362      * @brief Checks whether the platform is allowed to generate contextual NotificationActionButton objects for this
363      * notification.
364      *
365      * @return Returns true if the platform is allowed to generate contextual NotificationActionButton objects;
366      * returns false otherwise.
367      */
368     bool IsPermitSystemGeneratedContextualActionButtons() const;
369 
370     /**
371      * @brief Sets whether to allow the platform to generate contextual NotificationActionButton objects for this
372      * notification.
373      *
374      * @param permitted Specifies whether to allow the platform to generate contextual NotificationActionButton objects.
375      * The default value true indicates that the platform is allowed to generate contextual action buttons,
376      * and the value false indicates not.
377      */
378     void SetPermitSystemGeneratedContextualActionButtons(bool permitted);
379 
380     bool IsAgentNotification() const;
381 
382     void SetIsAgentNotification(bool isAgent);
383 
384     /**
385      * @brief Adds a MessageUser object and associates it with this notification.
386      *
387      * @param messageUser Indicates the MessageUser object to add.
388      */
389     void AddMessageUser(const std::shared_ptr<MessageUser> &messageUser);
390 
391     /**
392      * @brief Obtains all MessageUser objects associated with this notification.
393      *
394      * @return Returns the list of MessageUser objects associated with this notification.
395      */
396     const std::vector<std::shared_ptr<MessageUser>> GetMessageUsers() const;
397 
398     /**
399      * @brief Checks whether this notification is set to alert only once,
400      * which means that sound or vibration will no longer be played
401      * for notifications with the same ID upon their updates.
402      *
403      * @return Returns true if this notification is set to alert only once; returns false otherwise.
404      */
405     bool IsAlertOneTime() const;
406 
407     /**
408      * @brief Sets whether to have this notification alert only once.
409      * If a notification alerts only once, sound or vibration will no longer be played
410      * for notifications with the same ID upon their updates after they are published.
411      *
412      * @param isAlertOnce Specifies whether to have this notification alert only once.
413      */
414     void SetAlertOneTime(bool isAlertOnce);
415 
416     /**
417      * @brief Sets the time to delete a notification.
418      *
419      * @param deletedTime Indicates the time in milliseconds.
420      * The default value is 0, indicating that the notification will not be automatically deleted.
421      * To enable the notification to be automatically deleted, set this parameter to an integer greater than 0.
422      */
423     void SetAutoDeletedTime(int64_t deletedTime);
424 
425     /**
426      * @brief Obtains the period during which a notification is deleted.
427      *
428      * @return Returns the period in milliseconds.
429      */
430     int64_t GetAutoDeletedTime() const;
431 
432     /**
433      * @brief Sets the update deadline time before deleting a notification.
434      *
435      * @param updateDeadLine Indicates the time in milliseconds.
436      * The default value is 0, indicating that the notification will not be automatically deleted.
437      * To enable the notification to be automatically deleted, set this parameter to an integer greater than 0.
438      */
439     void SetUpdateDeadLine(int64_t updateDeadLine);
440 
441     /**
442      * @brief Obtains the time point which a notification must be updated.
443      *
444      * @return Returns the time point in milliseconds.
445      */
446     int64_t GetUpdateDeadLine() const;
447 
448     /**
449      * @brief Sets the finish deadline time before deleting a notification.
450      *
451      * @param finishDeadLine Indicates the time in milliseconds.
452      * The default value is 0, indicating that the notification will not be automatically deleted.
453      * To enable the notification to be automatically deleted, set this parameter to an integer greater than 0.
454      */
455     void SetFinishDeadLine(int64_t finishDeadLine);
456 
457     /**
458      * @brief Obtains the time point which a notification must be finished.
459      *
460      * @return Returns the time point in milliseconds.
461      */
462     int64_t GetFinishDeadLine() const;
463 
464     /**
465      * @brief Sets the finish deadline time before deleting a notification.
466      *
467      * @param finishDeadLine Indicates the time in milliseconds.
468      * The default value is 0, indicating that the notification will not be automatically deleted.
469      * To enable the notification to be automatically deleted, set this parameter to an integer greater than 0.
470      */
471     void SetArchiveDeadLine(int64_t archiveDeadLine);
472 
473     /**
474      * @brief Obtains the time point which a notification must be finished.
475      *
476      * @return Returns the time point in milliseconds.
477      */
478     int64_t GetArchiveDeadLine() const;
479 
480     /**
481      * @brief Sets the little icon of the notification.
482      *
483      * @param littleIcon Indicates the icon of the notification.
484      */
485     void SetLittleIcon(const std::shared_ptr<Media::PixelMap> &littleIcon);
486 
487     /**
488      * @brief Obtains the icon of the notification.
489      *
490      * @return Returns the notification icon.
491      */
492     const std::shared_ptr<Media::PixelMap> GetLittleIcon() const;
493 
494     /**
495      * @brief Sets the large icon of this notification, which is usually displayed on the right of the notification.
496      *
497      * @param bigIcon Indicates the large icon to set. It must be a PixelMap object.
498      */
499     void SetBigIcon(const std::shared_ptr<Media::PixelMap> &bigIcon);
500 
501     /**
502      * @brief Obtains the large icon of this notification.
503      *
504      * @return Returns the large icon of this notification.
505      */
506     const std::shared_ptr<Media::PixelMap> GetBigIcon() const;
507 
508     /**
509      * @brief Sets the overlay icon of this notification.
510      *
511      * @param overlayIcon Indicates the overlay icon of the notification.
512      */
513     void SetOverlayIcon(const std::shared_ptr<Media::PixelMap> &overlayIcon);
514 
515     /**
516      * @brief Obtains the overlay icon of this notification.
517      *
518      * @return Returns the overlay icon of this notification.
519      */
520     const std::shared_ptr<Media::PixelMap> GetOverlayIcon() const;
521 
522     /**
523      * @brief Sets the classification of this notification, which describes the purpose of this notification.
524      * Notification classifications are used to filter and sort notifications.
525      *
526      * @param classification Indicates the notification classification predefined in the system,
527      * such as CLASSIFICATION_CALL or CLASSIFICATION_NAVIGATION etc.
528      */
529     void SetClassification(const std::string &classification);
530 
531     /**
532      * @brief Obtains the classification of this notification.
533      *
534      * @return Returns the classification of this notification.
535      */
536     std::string GetClassification() const;
537 
538     /**
539      * @brief Sets the background color of this notification.
540      * This method is valid only when background color has been enabled by calling setColorEnabled(bool).
541      *
542      * @param color Indicates the background color to set. For details about the value range, see Color.
543      */
544     void SetColor(uint32_t color);
545 
546     /**
547      * @brief Obtains the background color of this notification.
548      * The return value, except for the default color COLOR_DEFAULT,
549      * is the bitwise OR operation result of 0xFF000000 and the ARGB value set by setColor(uint32_t).
550      *
551      * @return Returns the background color of this notification.
552      */
553     uint32_t GetColor() const;
554 
555     /**
556      * @brief Checks whether background color is enabled for this notification.
557      *
558      * @return Returns true if background color is enabled; returns false otherwise.
559      */
560     bool IsColorEnabled() const;
561 
562     /**
563      * @brief Sets whether to enable background color for this notification.
564      * If colorEnabled is set to true, this method takes effect only
565      * when the notification content type has been set to NotificationRequest.
566      * NotificationMediaContent in the NotificationRequest object through
567      * NotificationRequest::setContent(NotificationContent) and an AVToken has been attached to
568      * that NotificationMediaContent object through NotificationMediaContent::setAVToken(AVToken).
569      *
570      * @param colorEnabled Specifies whether to enable background color.
571      */
572     void SetColorEnabled(bool colorEnabled);
573 
574     /**
575      * @brief Sets the notification content type to NotificationNormalContent, NotificationLongTextContent,
576      * or NotificationPictureContent etc.
577      * Each content type indicates a particular notification content.
578      *
579      * @param content Indicates the notification content type.
580      */
581     void SetContent(const std::shared_ptr<NotificationContent> &content);
582 
583     /**
584      * @brief Obtains the notification content set by calling the setContent(NotificationContent) method.
585      *
586      * @return Returns the notification content.
587      */
588     const std::shared_ptr<NotificationContent> GetContent() const;
589 
590     /**
591      * @brief Obtains the notification type.
592      *
593      * @return Returns the type of the current notification, which can be
594      * NotificationContent::Type::BASIC_TEXT,
595      * NotificationContent::Type::LONG_TEXT,
596      * NotificationContent::Type::PICTURE,
597      * NotificationContent::Type::CONVERSATION,
598      * NotificationContent::Type::MULTILINE,
599      * NotificationContent::Type::MEDIA,
600      * or NotificationContent::Type::LIVE_VIEW
601      */
602     NotificationContent::Type GetNotificationType() const;
603 
604     /**
605      * @brief Checks whether the notification creation time is displayed as a countdown timer.
606      *
607      * @return Returns true if the time is displayed as a countdown timer; returns false otherwise.
608      */
609     bool IsCountdownTimer() const;
610 
611     /**
612      * @brief Sets whether to show the notification creation time as a countdown timer.
613      * This method is valid only when setShowStopwatch(boolean) is set to true.
614      *
615      * @param isCountDown Specifies whether to show the notification creation time as a countdown timer.
616      */
617     void SetCountdownTimer(bool isCountDown);
618 
619     /**
620      * @brief Sets the group alert type for this notification,
621      * which determines how the group overview and other notifications in a group are published.
622      * The group information must have been set by calling setGroupValue(string).
623      * Otherwise, this method does not take effect.
624      *
625      * @param type Indicates the group alert type to set. which can be GroupAlertType::ALL (default value),
626      * GroupAlertType::OVERVIEW, or GroupAlertType::CHILD etc.
627      */
628     void SetGroupAlertType(NotificationRequest::GroupAlertType type);
629 
630     /**
631      * @brief Obtains the group alert type of this notification.
632      *
633      * @return Returns the group alert type of this notification.
634      */
635     NotificationRequest::GroupAlertType GetGroupAlertType() const;
636 
637     /**
638      * @brief Checks whether this notification is the group overview.
639      *
640      * @return Returns true if this notification is the group overview; returns false otherwise.
641      */
642     bool IsGroupOverview() const;
643 
644     /**
645      * @brief Sets whether to use this notification as the overview of its group.
646      * This method helps display the notifications that are assigned the same group name by calling
647      * setGroupName(string) as one stack in the notification bar.
648      * Each group requires only one group overview. After a notification is set as the group overview,
649      * it becomes invisible if another notification in the same group is published.
650      *
651      * @param overView Specifies whether to set this notification as the group overview.
652      */
653     void SetGroupOverview(bool overView);
654 
655     /**
656      * @brief Sets the group information for this notification.
657      * If no groups are set for notifications, all notifications from the same application will appear
658      * in the notification bar as one stack with the number of stacked notifications displayed.
659      * If notifications are grouped and there are multiple groups identified by different groupName,
660      * notifications with different groupName will appear in separate stacks.
661      * Note that one of the notifications in a group must be set as the overview of its group by calling
662      * setGroupOverview(bool), and other notifications are considered as child notifications.
663      * Otherwise, notifications will not be displayed as one group even if they are assigned the same groupName by
664      * calling setGroupName(string).
665      *
666      * @param groupName Specifies whether to set this notification as the group overview.
667      */
668     void SetGroupName(const std::string &groupName);
669 
670     /**
671      * @brief Obtains the group information about this notification.
672      *
673      * @return Returns the group information about this notification.
674      */
675     std::string GetGroupName() const;
676 
677     /**
678      * @brief Checks whether this notification is relevant only to the local device and cannot be displayed on remote
679      * devices.
680      *
681      * @return Returns true if this notification is relevant only to the local device; returns false otherwise.
682      */
683     bool IsOnlyLocal() const;
684 
685     /**
686      * @brief Sets whether this notification is relevant only to the local device and cannot be displayed on remote
687      * devices.This method takes effect only for notifications published by calling
688      * NotificationHelper::publishNotification(NotificationRequest) or
689      * NotificationHelper#publishNotification(string, NotificationRequest).
690      * Notifications published using NotificationHelper::publishNotification(NotificationRequest, string)
691      * in a distributed system will not be affected.
692      *
693      * @param flag Specifies whether this notification can be displayed only on the local device.
694      */
695     void SetOnlyLocal(bool flag);
696 
697     /**
698      * @brief Sets the text that will be displayed as a link to the settings of the application.
699      * Calling this method is invalid if the notification content type has been set to NotificationLongTextContent
700      * or NotificationPictureContent in the NotificationRequest object through setContent(NotificationContent).
701      *
702      * @param text Indicates the text to be included. You can set it to any valid link.
703      */
704     void SetSettingsText(const std::string &text);
705 
706     /**
707      * @brief Obtains the text that will be displayed as a link to the settings of the application.
708      *
709      * @return Returns the text displayed as the link to the application settings.
710      */
711     std::string GetSettingsText() const;
712 
713     /**
714      * @brief Deprecated. Obtains the time when a notification is created.
715      *
716      * @return Returns the time in milliseconds.
717      */
718     int64_t GetCreateTime() const;
719 
720     /**
721      * @brief Checks whether the notification creation time is displayed as a stopwatch.
722      *
723      * @return Returns true if the time is displayed as a stopwatch; returns false otherwise.
724      */
725     bool IsShowStopwatch() const;
726 
727     /**
728      * @brief Sets whether to show the notification creation time as a stopwatch.
729      * This method is valid only when the notification creation time has been set by calling setDeliveryTime(int64_t).
730      * When the notification creation time is set to be shown as a stopwatch, the interval between the current time
731      * and the creation time set by setDeliveryTime(int64_t) is dynamically displayed for this notification
732      * in Minutes: Seconds format. If the interval is longer than 60 minutes, it will be displayed
733      * in Hours: Minutes: Seconds format. If this method and setShowDeliveryTime(boolean) are both set to true, only
734      * this method takes effect, that is, the notification creation time will be shown as a stopwatch.
735      *
736      * @param isShow Specifies whether to show the notification creation time as a stopwatch.
737      */
738     void SetShowStopwatch(bool isShow);
739 
740     /**
741      * @brief Sets the slot type of a notification to bind the created NotificationSlot object.
742      * You can use NotificationSlot to create a slot object,
743      * then set the notification vibration and lock screen display, and use the current method to bind the slot.
744      * The value must be the type of an existing NotificationSlot object.
745      *
746      * @param slotType Indicates the unique type of the NotificationSlot object.
747      */
748     void SetSlotType(NotificationConstant::SlotType slotType);
749 
750     /**
751      * @brief Obtains the slot type of a notification set by calling the setSlotType(string) method.
752      *
753      * @return Returns the notification slot type.
754      */
755     NotificationConstant::SlotType GetSlotType() const;
756 
757     /**
758      * @brief Sets a key used for sorting notifications from the same application bundle.
759      *
760      * @param key Indicates the key to set.
761      */
762     void SetSortingKey(const std::string &key);
763 
764     /**
765      * @brief Obtains the key used for sorting notifications from the same application bundle.
766      *
767      * @return Returns the key for sorting notifications.
768      */
769     std::string GetSortingKey() const;
770 
771     /**
772      * @brief Sets the scrolling text to be displayed in the status bar when this notification is received.
773      *
774      * @param text Indicates the scrolling text to be displayed.
775      */
776     void SetStatusBarText(const std::string &text);
777 
778     /**
779      * @brief Obtains the scrolling text that will be displayed in the status bar when this notification is received.
780      *
781      * @return Returns the scrolling notification text.
782      */
783     std::string GetStatusBarText() const;
784 
785     /**
786      * @brief Checks whether the current notification will be automatically dismissed after being tapped.
787      *
788      * @return Returns true if the notification will be automatically dismissed; returns false otherwise.
789      */
790     bool IsTapDismissed() const;
791 
792     /**
793      * @brief Sets whether to automatically dismiss a notification after being tapped.
794      * If you set tapDismissed to true,
795      * you must call the setWantAgent(WantAgent) method to make the settings take effect.
796      *
797      * @param isDismissed Specifies whether a notification will be automatically dismissed after being tapped.
798      */
799     void SetTapDismissed(bool isDismissed);
800 
801     /**
802      * @brief Sets the notification display effect, including whether to display this notification on the lock screen,
803      * and how it will be presented if displayed.
804      * For details, see NotificationSlot::setLockscreenVisibleness(int).
805      * If the lock screen display effect is set for a NotificationRequest object
806      * and its associated NotificationSlot object, the display effect set in the NotificationRequest object prevails.
807      *
808      * @param type Indicates the notification display effect on the lock screen.
809      */
810     void SetVisibleness(NotificationConstant::VisiblenessType type);
811 
812     /**
813      * @brief Obtains the display effect of this notification on the lock screen.
814      *
815      * @return Returns the display effect of this notification on the lock screen.
816      */
817     NotificationConstant::VisiblenessType GetVisibleness() const;
818 
819     /**
820      * @brief Sets the badge icon style for this notification.
821      * This method does not take effect if the home screen does not support badge icons.
822      *
823      * @param style Indicates the type of the badge icon to be displayed for this notification.
824      * The value must be BadgeStyle::NONE, BadgeStyle::LITTLE, or BadgeStyle::BIG.
825      */
826     void SetBadgeIconStyle(NotificationRequest::BadgeStyle style);
827 
828     /**
829      * @brief Obtains the badge icon style of this notification.
830      *
831      * @return Returns the badge icon style of this notification.
832      */
833     NotificationRequest::BadgeStyle GetBadgeIconStyle() const;
834 
835     /**
836      * @brief Sets the shortcut ID for this notification.
837      * After a shortcut ID is set for a notification, the notification will be associated with the corresponding
838      * home-screen shortcut, and the shortcut will be hidden when the Home application displays the badge or content
839      * of the notification.
840      *
841      * @param shortcutId Indicates the shortcut ID to set.
842      */
843     void SetShortcutId(const std::string &shortcutId);
844 
845     /**
846      * @brief Obtains the shortcut ID associated with this notification.
847      *
848      * @return Returns the shortcut ID of this notification.
849      */
850     std::string GetShortcutId() const;
851 
852     /**
853      * @brief Sets whether this notification is displayed as a floating icon on top of the screen.
854      *
855      * @param floatingIcon Specifies whether a notification is displayed as a floating icon on top of the screen.
856      */
857     void SetFloatingIcon(bool floatingIcon);
858 
859     /**
860      * @brief Checks whether this notification is displayed as a floating icon on top of the screen.
861      *
862      * @return Returns true if this notification is displayed as a floating icon; returns false otherwise.
863      */
864     bool IsFloatingIcon() const;
865 
866     /**
867      * @brief Sets how the progress bar will be displayed for this notification.
868      * A progress bar is usually used in notification scenarios such as download.
869      *
870      * @param progress Indicates the current value displayed for the notification progress bar.
871      * @param progressMax Indicates the maximum value displayed for the notification progress bar.
872      * @param indeterminate Specifies whether the progress bar is indeterminate. The value true indicates that
873      * the progress bar is indeterminate, and users cannot see its current and maximum values.
874      */
875     void SetProgressBar(int32_t progress, int32_t progressMax, bool indeterminate);
876 
877     /**
878      * @brief Obtains the maximum value displayed for the progress bar of this notification.
879      *
880      * @return Returns the maximum value of the notification progress bar.
881      */
882     int32_t GetProgressMax() const;
883 
884     /**
885      * @brief Obtains the current value displayed for the progress bar of this notification.
886      *
887      * @return Returns the current value of the notification progress bar.
888      */
889     int32_t GetProgressValue() const;
890 
891     /**
892      * @brief Checks whether the progress bar of this notification is indeterminate.
893      *
894      * @return Returns true if the notification progress bar is indeterminate; returns false otherwise.
895      */
896     bool IsProgressIndeterminate() const;
897 
898     /**
899      * @brief Sets the most recent NotificationUserInput records that have been sent through this notification.
900      * The most recent input must be stored in index 0,
901      * the second most recent input must be stored in index 1, and so on.
902      * The system displays a maximum of five inputs.
903      *
904      * @param text Indicates the list of inputs to set.
905      */
906     void SetNotificationUserInputHistory(const std::vector<std::string> &text);
907 
908     /**
909      * @brief Obtains the most recent NotificationUserInput records.
910      *
911      * @return Returns the most recent NotificationUserInput records.
912      */
913     std::vector<std::string> GetNotificationUserInputHistory() const;
914 
915     /**
916      * @brief Obtains the unique hash code of a notification in the current application.
917      * To obtain a valid hash code, you must have subscribed to and received the notification.
918      * A valid notification hash code is a string composed of multiple attributes separated by an underscore (_),
919      * including the notification ID, creator bundle name, creator UID, and owner bundle name.
920      *
921      * @return Returns the hash code of the notification.
922      */
923     std::string GetNotificationHashCode() const;
924 
925     /**
926      * @brief Sets the bundle name of the notification owner.
927      * The notification owner refers to the application that subscribes to the notification.
928      *
929      * @param ownerName Indicates the bundle name of the notification owner.
930      */
931     void SetOwnerBundleName(const std::string &ownerName);
932 
933     /**
934      * @brief Obtains the bundle name of the notification owner.
935      * The notification owner refers to the application that subscribes to the notification.
936      *
937      * @return Returns the bundle name of the notification owner.
938      */
939     std::string GetOwnerBundleName() const;
940 
941     /**
942      * @brief Sets the bundle name of the notification creator.
943      * The notification creator refers to the application that publishes the notification.
944      *
945      * @param creatorName Indicates the bundle name of the notification creator.
946      */
947     void SetCreatorBundleName(const std::string &creatorName);
948 
949     /**
950      * @brief Obtains the bundle name of the notification creator.
951      * The notification creator refers to the application that publishes the notification.
952      *
953      * @return Returns the bundle name of the notification creator.
954      */
955     std::string GetCreatorBundleName() const;
956 
957     /**
958      * @brief Sets the PID of the notification creator.
959      *
960      * @param pid Indicates the PID of the notification creator.
961      */
962     void SetCreatorPid(pid_t pid);
963 
964     /**
965      * @brief Obtains the PID of the notification creator.
966      *
967      * @return Returns the PID of the notification creator.
968      */
969     pid_t GetCreatorPid() const;
970 
971     /**
972      * @brief Sets the UID of the notification creator.
973      *
974      * @param uid Indicates the UID of the notification creator.
975      */
976     void SetCreatorUid(int32_t uid);
977 
978     /**
979      * @brief Obtains the UID of the notification creator.
980      *
981      * @return Returns the UID of the notification creator.
982      */
983     int32_t GetCreatorUid() const;
984 
985     /**
986      * @brief Sets the UID of the notification owner.
987      *
988      * @param uid the UID of the notification owner.
989      */
990     void SetOwnerUid(int32_t uid);
991 
992     /**
993      * @brief Obtains the UID of the notification owner.
994      *
995      * @return the UID of the notification owner.
996      */
997     int32_t GetOwnerUid() const;
998 
999     /**
1000      * @brief Sets the label of this notification.
1001      *
1002      * @param label Indicates the label of this notification.
1003      */
1004     void SetLabel(const std::string &label);
1005 
1006     /**
1007      * @brief Obtains the label of this notification.
1008      * The label is set via NotificationHelper::publishNotification(string, NotificationRequest).
1009      * This method returns null if no specific label is set for this notification.
1010      *
1011      * @return Returns the label of this notification.
1012      */
1013     std::string GetLabel() const;
1014 
1015     /**
1016      * @brief Sets whether this notification is distributed.
1017      *
1018      * @param distribute Specifies whether a notification is displayed as a floating icon on top of the screen.
1019      */
1020     void SetDistributed(bool distribute);
1021 
1022     /**
1023      * @brief Sets devices that support display.
1024      *
1025      * @param devices Indicates the devices that support display.
1026      */
1027     void SetDevicesSupportDisplay(const std::vector<std::string> &devices);
1028 
1029     /**
1030      * @brief Sets devices that support operate.
1031      *
1032      * @param devices Indicates the devices that support operate.
1033      */
1034     void SetDevicesSupportOperate(const std::vector<std::string> &devices);
1035 
1036     /**
1037      * @brief Obtains the distributed Options.
1038      *
1039      * @return Returns the distributed Options.
1040      */
1041     NotificationDistributedOptions GetNotificationDistributedOptions() const;
1042 
1043     /**
1044      * @brief Sets the UserId of the notification creator.
1045      *
1046      * @param userId Indicates the UserId of the notification creator.
1047      */
1048     void SetCreatorUserId(int32_t userId);
1049 
1050     /**
1051      * @brief Obtains the UserId of the notification creator.
1052      *
1053      * @return Returns the UserId of the notification creator.
1054      */
1055     int32_t GetCreatorUserId() const;
1056 
1057     /**
1058      * @brief Sets the UserId of the notification owner.
1059      *
1060      * @param userId the UserId of the notification owner.
1061      */
1062     void SetOwnerUserId(int32_t userId);
1063 
1064     /**
1065      * @brief Obtains the UserId of the notification owner.
1066      *
1067      * @return the UserId of the notification owner.
1068      */
1069     int32_t GetOwnerUserId() const;
1070 
1071     /**
1072      * @brief Returns a string representation of the object.
1073      *
1074      * @return Returns a string representation of the object.
1075      */
1076     std::string Dump();
1077 
1078     /**
1079      * @brief Converts a NotificationRequest object into a Json.
1080      *
1081      * @param jsonObject Indicates the Json object.
1082      * @return Returns true if succeed; returns false otherwise.
1083      */
1084     bool ToJson(nlohmann::json &jsonObject) const override;
1085 
1086     /**
1087      * @brief Creates a NotificationRequest object from a Json.
1088      *
1089      * @param jsonObject Indicates the Json object.
1090      * @return Returns the NotificationRequest.
1091      */
1092     static NotificationRequest *FromJson(const nlohmann::json &jsonObject);
1093 
1094     /**
1095      * @brief Marshal a NotificationRequest object into a Parcel.
1096      *
1097      * @param parcel Indicates the object into the parcel.
1098      * @return Returns true if succeed; returns false otherwise.
1099      */
1100     virtual bool Marshalling(Parcel &parcel) const override;
1101 
1102     /**
1103      * @brief Unmarshal object from a Parcel.
1104      *
1105      * @param parcel Indicates the parcel object.
1106      * @return Returns the NotificationRequest.
1107      */
1108     static NotificationRequest *Unmarshalling(Parcel &parcel);
1109 
1110     /**
1111      * @brief Sets the template of this notification.
1112      *
1113      * @param template Indicates the template of this notification.
1114      */
1115     void SetTemplate(const std::shared_ptr<NotificationTemplate> &templ);
1116 
1117     /**
1118      * @brief Obtains the Template of the notification.
1119      *
1120      * @return Returns the Template of the notification.
1121      */
1122     std::shared_ptr<NotificationTemplate> GetTemplate() const;
1123 
1124     /**
1125      * @brief Sets the flags of this notification.
1126      *
1127      * @param flags Indicates the flags of this notification.
1128      */
1129     void SetFlags(const std::shared_ptr<NotificationFlags> &flags);
1130 
1131     /**
1132      * @brief Obtains the flags of the notification.
1133      *
1134      * @return Returns the flags of the notification.
1135      */
1136     std::shared_ptr<NotificationFlags> GetFlags() const;
1137 
1138     /**
1139      * @brief Sets the userId of the notification receiver.
1140      *
1141      * @param userId Indicates the userId of the notification receiver.
1142      */
1143     void SetReceiverUserId(int32_t userId);
1144 
1145     /**
1146      * @brief Obtains the userId of the notification receiver.
1147      *
1148      * @return Returns the userId of the notification receiver.
1149      */
1150     int32_t GetReceiverUserId() const;
1151 
1152     bool IsRemoveAllowed() const;
1153 
1154     void SetRemoveAllowed(bool isRemoveAllowed);
1155 
1156     bool IsCommonLiveView() const;
1157 
1158     /**
1159      * @brief Checks whether the image size exceeds the limit in content.
1160      *
1161      * @param pixelMap Indicates the image smart pointer.
1162      * @param maxSize The max size of image.
1163      * @return Returns the ErrCode.
1164      */
1165     static bool CheckImageOverSizeForPixelMap(const std::shared_ptr<Media::PixelMap> &pixelMap, uint32_t maxSize);
1166 
1167     /**
1168      * @brief Checks whether the picture size exceeds the limit in content.
1169      *
1170      * @param request Indicates the specified request.
1171      * @return Returns the ErrCode.
1172      */
1173     ErrCode CheckNotificationRequest(const sptr<NotificationRequest> &oldRequest) const;
1174 
1175     /**
1176      * @brief Fill missing parameters of the current notification request.
1177      *
1178      * @param oldRequest Indicates the old request.
1179      */
1180     void FillMissingParameters(const sptr<NotificationRequest> &oldRequest);
1181 
1182     /**
1183      * @brief Get notification request key.
1184      *
1185      * @return Return the unique key of notification request.
1186      */
1187     std::string GetKey();
1188 
1189     /**
1190      * @brief Get notification request base key.
1191      *
1192      * @return Return the base key of notification request.
1193      */
1194     std::string GetBaseKey(const std::string &deviceId);
1195 
1196     /**
1197      * @brief Check the image size in content.
1198      *
1199      * @return Return the check result, ERR_OK: check pass, others: not pass.
1200      */
1201     ErrCode CheckImageSizeForContent() const;
1202 
1203     /**
1204      * @brief Set notification isCoverActionButtons value.
1205      *
1206      * @param isCoverActionButtons the value of isCoverActionButtons.
1207      */
1208     void SetIsCoverActionButtons(bool isCoverActionButtons);
1209 
1210     /**
1211      * @brief Get notification isCoverActionButtons value.
1212      *
1213      * @return Return the value of isCoverActionButtons.
1214      */
1215     bool IsCoverActionButtons() const;
1216 
1217 private:
1218     /**
1219      * Indicates the color mask, used for calculation with the ARGB value set by setColor(int32_t).
1220      */
1221     static const uint32_t COLOR_MASK;
1222 
1223     /**
1224      * the maximum number of user input history is 5.
1225      */
1226     static const std::size_t MAX_USER_INPUT_HISTORY;
1227 
1228     /**
1229      * the maximum number of action buttons is 3.
1230      */
1231     static const std::size_t MAX_ACTION_BUTTONS;
1232 
1233     /**
1234      * the maximum number of message users is 1000.
1235      */
1236     static const std::size_t MAX_MESSAGE_USERS;
1237 
1238 private:
1239     /**
1240      * @brief Read a NotificationRequest object from a Parcel.
1241      *
1242      * @param parcel Indicates the parcel object.
1243      * @return Returns true if succeed; returns false otherwise.
1244      */
1245     bool ReadFromParcel(Parcel &parcel);
1246 
1247     /**
1248      * @brief Obtains the current system time in milliseconds.
1249      *
1250      * @return Returns the current system time in milliseconds.
1251      */
1252     int64_t GetNowSysTime();
1253 
1254     void CopyBase(const NotificationRequest &other);
1255     void CopyOther(const NotificationRequest &other);
1256 
1257     bool ConvertObjectsToJson(nlohmann::json &jsonObject) const;
1258     ErrCode CheckVersion(const sptr<NotificationRequest> &oldRequest) const;
1259 
1260     static void ConvertJsonToNum(NotificationRequest *target, const nlohmann::json &jsonObject);
1261     static void ConvertJsonToNumExt(NotificationRequest *target, const nlohmann::json &jsonObject);
1262     static void ConvertJsonToString(NotificationRequest *target, const nlohmann::json &jsonObject);
1263     static void ConvertJsonToEnum(NotificationRequest *target, const nlohmann::json &jsonObject);
1264     static void ConvertJsonToBool(NotificationRequest *target, const nlohmann::json &jsonObject);
1265     static void ConvertJsonToBoolExt(NotificationRequest *target, const nlohmann::json &jsonObject);
1266     static void ConvertJsonToPixelMap(NotificationRequest *target, const nlohmann::json &jsonObject);
1267     static bool ConvertJsonToNotificationContent(NotificationRequest *target, const nlohmann::json &jsonObject);
1268     static bool ConvertJsonToNotificationActionButton(NotificationRequest *target, const nlohmann::json &jsonObject);
1269     static bool ConvertJsonToNotificationDistributedOptions(
1270         NotificationRequest *target, const nlohmann::json &jsonObject);
1271     static bool ConvertJsonToNotificationFlags(NotificationRequest *target, const nlohmann::json &jsonObject);
1272     static ErrCode CheckImageSizeForConverSation(std::shared_ptr<NotificationBasicContent> &content);
1273     static ErrCode CheckImageSizeForPicture(std::shared_ptr<NotificationBasicContent> &content);
1274     static ErrCode CheckImageSizeForLiveView(std::shared_ptr<NotificationBasicContent> &content);
1275 
1276 private:
1277     int32_t notificationId_ {0};
1278     uint32_t color_ {NotificationRequest::COLOR_DEFAULT};
1279     uint32_t badgeNumber_ {0};
1280     int32_t progressValue_ {0};
1281     int32_t progressMax_ {0};
1282     int64_t createTime_ {0};
1283     int64_t deliveryTime_ {0};
1284 
1285     int64_t autoDeletedTime_ {NotificationConstant::INVALID_AUTO_DELETE_TIME};
1286     int64_t updateDeadLine_ {0};
1287     int64_t finishDeadLine_ {0};
1288     int64_t archiveDeadLine_ {0};
1289     pid_t creatorPid_ {0};
1290     int32_t creatorUid_ {0};
1291     int32_t ownerUid_ {0};
1292     int32_t creatorUserId_ {SUBSCRIBE_USER_INIT};
1293     int32_t ownerUserId_ {SUBSCRIBE_USER_INIT};
1294     int32_t receiverUserId_ {SUBSCRIBE_USER_INIT};
1295 
1296     std::string settingsText_ {};
1297     std::string creatorBundleName_ {};
1298     std::string ownerBundleName_ {};
1299     std::string groupName_ {};
1300     std::string statusBarText_ {};
1301     std::string label_ {};
1302     std::string shortcutId_ {};
1303     std::string sortingKey_ {};
1304     std::string classification_ {};
1305 
1306     NotificationConstant::SlotType slotType_ {NotificationConstant::SlotType::OTHER};
1307     NotificationRequest::GroupAlertType groupAlertType_ {NotificationRequest::GroupAlertType::ALL};
1308     NotificationConstant::VisiblenessType visiblenessType_ {NotificationConstant::VisiblenessType::NO_OVERRIDE};
1309     NotificationRequest::BadgeStyle badgeStyle_ {NotificationRequest::BadgeStyle::NONE};
1310     NotificationContent::Type notificationContentType_ {NotificationContent::Type::NONE};
1311 
1312     bool showDeliveryTime_ {false};
1313     bool tapDismissed_ {true};
1314     bool colorEnabled_ {false};
1315     bool alertOneTime_ {false};
1316     bool showStopwatch_ {false};
1317     bool isCountdown_ {false};
1318     bool inProgress_ {false};
1319     bool groupOverview_ {false};
1320     bool progressIndeterminate_ {false};
1321     bool unremovable_ {false};
1322     bool floatingIcon_ {false};
1323     bool onlyLocal_ {false};
1324     bool permitted_ {true};
1325     bool isAgent_ {false};
1326     bool isRemoveAllowed_ {true};
1327     bool isCoverActionButtons_ {false};
1328 
1329     std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> wantAgent_ {};
1330     std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> removalWantAgent_ {};
1331     std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> maxScreenWantAgent_ {};
1332     std::shared_ptr<AAFwk::WantParams> additionalParams_ {};
1333     std::shared_ptr<Media::PixelMap> littleIcon_ {};
1334     std::shared_ptr<Media::PixelMap> bigIcon_ {};
1335     std::shared_ptr<Media::PixelMap> overlayIcon_ {};
1336     std::shared_ptr<NotificationContent> notificationContent_ {};
1337 
1338     std::vector<std::shared_ptr<NotificationActionButton>> actionButtons_ {};
1339     std::vector<std::shared_ptr<MessageUser>> messageUsers_ {};
1340     std::vector<std::string> userInputHistory_ {};
1341 
1342     NotificationDistributedOptions distributedOptions_;
1343 
1344     std::shared_ptr<NotificationTemplate> notificationTemplate_ {};
1345     std::shared_ptr<NotificationFlags> notificationFlags_ {};
1346 };
1347 }  // namespace Notification
1348 }  // namespace OHOS
1349 
1350 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_REQUEST_H
1351