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