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_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_NOTIFICATION_H 17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_NOTIFICATION_H 18 19 #include <list> 20 #include <memory> 21 22 #include "ans_dialog_host_client.h" 23 #include "ans_manager_death_recipient.h" 24 #include "ans_manager_interface.h" 25 #include "ans_subscriber_listener.h" 26 #include "notification_subscriber.h" 27 #include "notification_local_live_view_subscriber.h" 28 #include "want_params.h" 29 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 30 #include "swing_callback_stub.h" 31 #endif 32 33 namespace OHOS { 34 namespace Notification { 35 class AnsNotification { 36 public: 37 /** 38 * @brief Creates a notification slot. 39 * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot 40 * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to 41 * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the 42 * notification published can have all the characteristics set in the NotificationSlot. After a notification slot is 43 * created by using this method, only the name and description of the notification slot can be changed. Changes to 44 * the other attributes, such as the vibration status and notification tone, will no longer take effect. 45 * 46 * @param slot Indicates the notification slot to be created, which is set by NotificationSlot. 47 * This parameter must be specified. 48 * @return Returns add notification slot result. 49 */ 50 ErrCode AddNotificationSlot(const NotificationSlot &slot); 51 52 /** 53 * @brief Adds a notification slot by type. 54 * 55 * @param slotType Indicates the notification slot type to be added. 56 * @return Returns add notification slot result. 57 */ 58 ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType); 59 60 /** 61 * @brief Creates multiple notification slots. 62 * 63 * @param slots Indicates the notification slots to create. 64 * @return Returns add notification slots result. 65 */ 66 ErrCode AddNotificationSlots(const std::vector<NotificationSlot> &slots); 67 68 /** 69 * @brief Deletes a created notification slot based on the slot ID. 70 * 71 * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot 72 * This parameter must be specified. 73 * @return Returns remove notification slot result. 74 */ 75 ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType); 76 77 /** 78 * @brief Deletes all notification slots. 79 * 80 * @return Returns remove all slots result. 81 */ 82 ErrCode RemoveAllSlots(); 83 84 /** 85 * @brief Queries a created notification slot. 86 * 87 * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This 88 * parameter must be specified. 89 * @param slot Indicates the created NotificationSlot. 90 * @return Returns the get notification slot result. 91 */ 92 ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot); 93 94 /** 95 * @brief Obtains all notification slots of this application. 96 * 97 * @param slots Indicates the created NotificationSlot. 98 * @return Returns all notification slots of this application. 99 */ 100 ErrCode GetNotificationSlots(std::vector<sptr<NotificationSlot>> &slots); 101 102 /** 103 * @brief Obtains number of slot. 104 * 105 * @param bundleOption Indicates the bundle name and uid of the application. 106 * @param num Indicates number of slot. 107 * @return Returns get slot number by bundle result. 108 */ 109 ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num); 110 111 /** 112 * @brief Obtains slotFlags of bundle. 113 * 114 * @param bundleOption Indicates the bundle name and uid of the application. 115 * @param slotFlags Indicates slotFlags of bundle. 116 * @return Returns get slotflags by bundle result. 117 */ 118 ErrCode GetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t &slotFlags); 119 120 /** 121 * @brief Set slotFlags of bundle. 122 * 123 * @param bundleOption Indicates the bundle name and uid of the application. 124 * @param slotFlags Indicates slotFlags of bundle. 125 * @return Returns set slotflags by bundle result. 126 */ 127 ErrCode SetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t slotFlags); 128 129 /** 130 * @brief Publishes a notification. 131 * @note If a notification with the same ID has been published by the current application and has not been deleted, 132 * this method will update the notification. 133 * 134 * @param request Indicates the NotificationRequest object for setting the notification content. 135 * This parameter must be specified. 136 * @return Returns publish notification result. 137 */ 138 ErrCode PublishNotification(const NotificationRequest &request); 139 140 /** 141 * @brief Publishes a notification with a specified label. 142 * @note If a notification with the same ID has been published by the current application and has not been deleted, 143 * this method will update the notification. 144 * 145 * @param label Indicates the label of the notification to publish. 146 * @param request Indicates the NotificationRequest object for setting the notification content. 147 * This parameter must be specified. 148 * @return Returns publish notification result. 149 */ 150 ErrCode PublishNotification(const std::string &label, const NotificationRequest &request); 151 152 /** 153 * @brief Publishes a notification. 154 * @note If a notification with the same ID has been published by the current application and has not been deleted, 155 * this method will update the notification. 156 * 157 * @param request Indicates the NotificationRequest object for setting the notification content. 158 * This parameter must be specified. 159 * @return Returns publish notification result. 160 */ 161 ErrCode PublishNotificationForIndirectProxy(const NotificationRequest &request); 162 163 /** 164 * @brief Cancels a published notification. 165 * 166 * @param notificationId Indicates the unique notification ID in the application. 167 * The value must be the ID of a published notification. 168 * Otherwise, this method does not take effect. 169 * @return Returns cancel notification result. 170 */ 171 ErrCode CancelNotification(int32_t notificationId); 172 173 /** 174 * @brief Cancels a published notification matching the specified label and notificationId. 175 * 176 * @param label Indicates the label of the notification to cancel. 177 * @param notificationId Indicates the ID of the notification to cancel. 178 * @return Returns cancel notification result. 179 */ 180 ErrCode CancelNotification(const std::string &label, int32_t notificationId); 181 182 /** 183 * @brief Cancels all the published notifications. 184 * @note To cancel a specified notification, see CancelNotification(int32_t). 185 * 186 * @return Returns cancel all notifications result. 187 */ 188 ErrCode CancelAllNotifications(); 189 190 /** 191 * @brief Cancels a published agent notification. 192 * 193 * @param notificationId Indicates the unique notification ID in the application. 194 * The value must be the ID of a published notification. 195 * Otherwise, this method does not take effect. 196 * @param representativeBundle Indicates the name of application bundle your application is representing. 197 * @param userId Indicates the specific user. 198 * @return Returns cancel notification result. 199 */ 200 ErrCode CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId); 201 202 /** 203 * @brief Cancels a published agent notification. 204 * 205 * @param bundleOption Indicates the bundle of application your application is representing. 206 * @param notificationId Indicates the unique notification ID in the application. 207 * The value must be the ID of a published notification. 208 * Otherwise, this method does not take effect. 209 * @return Returns cancel notification result. 210 */ 211 ErrCode CancelAsBundle(const NotificationBundleOption &bundleOption, int32_t notificationId); 212 213 /** 214 * @brief Obtains the number of active notifications of the current application in the system. 215 * 216 * @param num Indicates the number of active notifications of the current application. 217 * @return Returns get active notification nums result. 218 */ 219 ErrCode GetActiveNotificationNums(uint64_t &num); 220 221 /** 222 * @brief Obtains active notifications of the current application in the system. 223 * 224 * @param request Indicates active NotificationRequest objects of the current application. 225 * @return Returns get active notifications result. 226 */ 227 ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &request); 228 229 /** 230 * @brief Allows another application to act as an agent to publish notifications in the name of your application 231 * bundle. You can revoke this authorization by passing null to this method. 232 * 233 * @param agent Indicates the name of the application bundle that can publish notifications for your application. 234 * @return Returns set notification agent result. 235 */ 236 ErrCode SetNotificationAgent(const std::string &agent); 237 238 /** 239 * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. 240 * 241 * @param agent Indicates the name of the application bundle that can publish notifications for your application if 242 * any; returns null otherwise. 243 * @return Returns get notification agent result. 244 */ 245 ErrCode GetNotificationAgent(std::string &agent); 246 247 /** 248 * @brief Checks whether your application has permission to publish notifications by calling 249 * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the 250 * given representativeBundle. 251 * 252 * @param representativeBundle Indicates the name of application bundle your application is representing. 253 * @param canPublish Indicates whether your application has permission to publish notifications. 254 * @return Returns can publish notification as bundle result. 255 */ 256 ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish); 257 258 /** 259 * @brief Publishes a notification in the name of a specified application bundle. 260 * @note If the notification to be published has the same ID as a published notification that has not been canceled, 261 * the existing notification will be replaced by the new one. 262 * 263 * @param request Indicates the NotificationRequest object for setting the notification content. 264 * This parameter must be specified. 265 * @param representativeBundle Indicates the name of the application bundle that allows your application to publish 266 * notifications for it by calling setNotificationAgent. 267 * @return Returns publish notification as bundle result. 268 */ 269 ErrCode PublishNotificationAsBundle(const std::string &representativeBundle, const NotificationRequest &request); 270 271 /** 272 * @brief Sets the number of active notifications of the current application as the number to be displayed on the 273 * notification badge. 274 * 275 * @return Returns set notification badge num result. 276 */ 277 ErrCode SetNotificationBadgeNum(); 278 279 /** 280 * @brief Sets the number to be displayed on the notification badge of the application. 281 * 282 * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged. 283 * The value 0 indicates that no badge is displayed on the application icon. 284 * If the value is greater than 99, 99+ will be displayed. 285 * @return Returns set notification badge num result. 286 */ 287 ErrCode SetNotificationBadgeNum(int32_t num); 288 289 /** 290 * @brief Checks whether this application has permission to publish notifications. The caller must have 291 * system permissions to call this method. 292 * 293 * @param allowed True if this application has the permission; returns false otherwise 294 * @return Returns is allowed notify result. 295 */ 296 ErrCode IsAllowedNotify(bool &allowed); 297 298 /** 299 * @brief Checks whether this application has permission to publish notifications. 300 * 301 * @param allowed True if this application has the permission; returns false otherwise 302 * @return Returns is allowed notify result. 303 */ 304 ErrCode IsAllowedNotifySelf(bool &allowed); 305 306 /** 307 * @brief Checks whether this application can pop enable notification dialog. 308 * 309 * @param canPop True if can pop enable notification dialog 310 * @return Returns is canPop result. 311 */ 312 ErrCode CanPopEnableNotificationDialog(sptr<AnsDialogHostClient> &hostClient, 313 bool &canPop, std::string &bundleName); 314 315 /** 316 * @brief remove enable notification dialog. 317 * 318 * @return Returns remove dialog result. 319 */ 320 ErrCode RemoveEnableNotificationDialog(); 321 322 /** 323 * @brief Allows the current application to publish notifications on a specified device. 324 * 325 * @param deviceId Indicates the ID of the device running the application. At present, this parameter can 326 * only be null or an empty string, indicating the current device. 327 * @return Returns set notifications enabled for default bundle result. 328 */ 329 ErrCode RequestEnableNotification(std::string &deviceId, 330 sptr<AnsDialogHostClient> &hostClient, 331 sptr<IRemoteObject> &callerToken); 332 333 /** 334 * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. 335 * 336 * @param hasPermission True if this application is suspended; returns false otherwise. 337 * @return Returns has notification policy access permission. 338 */ 339 ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission); 340 341 /** 342 * @brief Obtains the importance level of this application. 343 * 344 * @param importance the importance level of this application, which can be LEVEL_NONE, 345 LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. 346 * @return Returns get bundle importance result 347 */ 348 ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance); 349 350 /** 351 * @brief Subscribes to notifications from all applications. This method can be called only by applications 352 * with required system permissions. 353 * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 354 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 355 * After the notification is published, subscribers that meet the filter criteria can receive the 356 * notification. To subscribe to notifications published only by specified sources, for example, notifications from 357 * certain applications, call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} 358 * method. 359 * @deprecated This function is deprecated, 360 * use 'SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)'. 361 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 362 * This parameter must be specified. 363 * @return Returns subscribe notification result. 364 */ 365 ErrCode SubscribeNotification(const NotificationSubscriber &subscriber); 366 367 /** 368 * @brief Subscribes to notifications from all applications. This method can be called only by applications 369 * with required system permissions. 370 * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 371 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 372 * After the notification is published, subscribers that meet the filter criteria can receive the 373 * notification. To subscribe to notifications published only by specified sources, for example, notifications from 374 * certain applications, call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} 375 * method. 376 * 377 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 378 * This parameter must be specified. 379 * @return Returns subscribe notification result. 380 */ 381 ErrCode SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber); 382 383 /** 384 * @brief Subscribes to notifications from the appliaction self. 385 * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 386 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 387 * After the notification is published, subscribers that meet the filter criteria can receive the 388 * notification. 389 * @deprecated This function is deprecated, 390 * use 'SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> &subscriber)'. 391 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 392 * This parameter must be specified. 393 * @return Returns subscribe notification result. 394 */ 395 ErrCode SubscribeNotificationSelf(const NotificationSubscriber &subscriber); 396 397 /** 398 * @brief Subscribes to notifications from the appliaction self. 399 * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 400 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 401 * After the notification is published, subscribers that meet the filter criteria can receive the 402 * notification. 403 * 404 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 405 * This parameter must be specified. 406 * @return Returns subscribe notification result. 407 */ 408 ErrCode SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> &subscriber); 409 410 /** 411 * @brief Subscribes liveView notification. This method can be called only by applications 412 * with required system permissions. 413 * @note To subscribe to a notification, inherit the {NotificationLocalLiveViewSubscriber} class, override its 414 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 415 * 416 * @param subscriber Indicates the {NotificationLocalLiveViewSubscriber} to receive notifications. 417 * This parameter must be specified. 418 * @return Returns subscribe notification result. 419 */ 420 ErrCode SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber, 421 const bool isNative = true); 422 423 /** 424 * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only 425 * by applications with required system permissions. 426 * @note After {subscribeInfo} is specified, a subscriber receives only the notifications that 427 * meet the filter criteria specified by {subscribeInfo}. 428 * To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 429 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 430 * After the notification is published, subscribers that meet the filter criteria can receive the 431 * notification. To subscribe to and receive all notifications, call the 432 * {SubscribeNotification(NotificationSubscriber)} method. 433 * @deprecated This function is deprecated, 434 * use 'SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber, 435 * const std::shared_ptr<NotificationSubscribeInfo> &subscribeInfo)'. 436 * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified. 437 * For details, see {NotificationSubscriber}. 438 * @param subscribeInfo Indicates the filters for specified notification sources, including application name, 439 * user ID, or device name. This parameter is optional. 440 * @return Returns subscribe notification result. 441 */ 442 ErrCode SubscribeNotification( 443 const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo); 444 445 /** 446 * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only 447 * by applications with required system permissions. 448 * @note After {subscribeInfo} is specified, a subscriber receives only the notifications that 449 * meet the filter criteria specified by {subscribeInfo}. 450 * To subscribe to a notification, inherit the {NotificationSubscriber} class, override its 451 * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. 452 * After the notification is published, subscribers that meet the filter criteria can receive the 453 * notification. To subscribe to and receive all notifications, call the 454 * {SubscribeNotification(NotificationSubscriber)} method. 455 * 456 * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified. 457 * For details, see {NotificationSubscriber}. 458 * @param subscribeInfo Indicates the filters for specified notification sources, including application name, 459 * user ID, or device name. This parameter is optional. 460 * @return Returns subscribe notification result. 461 */ 462 ErrCode SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber, 463 const sptr<NotificationSubscribeInfo> &subscribeInfo); 464 465 /** 466 * @brief Unsubscribes from all notifications. This method can be called only by applications with required 467 * system permissions. 468 * @note Generally, you subscribe to a notification by calling the 469 * {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application 470 * to receive a notification any longer, unsubscribe from that notification using this method. 471 * You can unsubscribe from only those notifications that your application has subscribed to. 472 * To unsubscribe from notifications published only by specified sources, for example, 473 * notifications from certain applications, call the 474 * {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method. 475 * @deprecated This function is deprecated, 476 * use 'UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)'. 477 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 478 * This parameter must be specified. 479 * @return Returns unsubscribe notification result. 480 */ 481 ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber); 482 483 /** 484 * @brief Unsubscribes from all notifications. This method can be called only by applications with required 485 * system permissions. 486 * @note Generally, you subscribe to a notification by calling the 487 * {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application 488 * to receive a notification any longer, unsubscribe from that notification using this method. 489 * You can unsubscribe from only those notifications that your application has subscribed to. 490 * To unsubscribe from notifications published only by specified sources, for example, 491 * notifications from certain applications, call the 492 * {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method. 493 * 494 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 495 * This parameter must be specified. 496 * @return Returns unsubscribe notification result. 497 */ 498 ErrCode UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber); 499 500 /** 501 * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called 502 * only by applications with required system permissions. 503 * @note A subscriber will no longer receive the notifications from specified notification sources. 504 * 505 * @deprecated This function is deprecated, 506 * use 'UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber, 507 * const std::shared_ptr<NotificationSubscribeInfo> &subscribeInfo)'. 508 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 509 * This parameter must be specified. 510 * @param subscribeInfo Indicates the filters for , including application name, 511 * user ID, or device name. This parameter is optional. 512 * @return Returns unsubscribe notification result. 513 */ 514 ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo); 515 516 /** 517 * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called 518 * only by applications with required system permissions. 519 * @note A subscriber will no longer receive the notifications from specified notification sources. 520 * 521 * @param subscriber Indicates the {NotificationSubscriber} to receive notifications. 522 * This parameter must be specified. 523 * @param subscribeInfo Indicates the filters for , including application name, 524 * user ID, or device name. This parameter is optional. 525 * @return Returns unsubscribe notification result. 526 */ 527 ErrCode UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber, 528 const sptr<NotificationSubscribeInfo> &subscribeInfo); 529 530 /** 531 * @brief Trigger the local live view after the button has been clicked. 532 * @note Your application must have platform signature to use this method. 533 * 534 * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. 535 * @param notificationId Indicates the id of the notification. 536 * @param buttonOption Indicates which button has been clicked. 537 * @return Returns trigger localLiveView result. 538 */ 539 ErrCode TriggerLocalLiveView(const NotificationBundleOption &bundleOption, 540 const int32_t notificationId, const NotificationButtonOption &buttonOption); 541 542 /** 543 * @brief Removes a specified removable notification of other applications. 544 * @note Your application must have platform signature to use this method. 545 * 546 * @param key Indicates the key of the notification to remove. 547 * @param removeReason Indicates the reason of remove notification. 548 * @return Returns remove notification result. 549 */ 550 ErrCode RemoveNotification(const std::string &key, int32_t removeReason); 551 552 /** 553 * @brief Removes a specified removable notification of other applications. 554 * @note Your application must have platform signature to use this method. 555 * 556 * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. 557 * @param notificationId Indicates the id of the notification to remove. 558 * @param label Indicates the label of the notification to remove. 559 * @param removeReason Indicates the reason of remove notification. 560 * @return Returns remove notification result. 561 */ 562 ErrCode RemoveNotification(const NotificationBundleOption &bundleOption, const int32_t notificationId, 563 const std::string &label, int32_t removeReason); 564 565 /** 566 * @brief Removes a specified removable notification of other applications. 567 * @note Your application must have platform signature to use this method. 568 * 569 * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. 570 * @return Returns remove notification result. 571 */ 572 ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption); 573 574 ErrCode RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason); 575 576 /** 577 * @brief Removes all removable notifications of a specified bundle. 578 * @note Your application must have platform signature to use this method. 579 * 580 * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. 581 * @return Returns remove notifications result. 582 */ 583 ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption); 584 585 /** 586 * @brief Removes all removable notifications in the system. 587 * @note Your application must have platform signature to use this method. 588 * 589 * @return Returns remove notifications result. 590 */ 591 ErrCode RemoveNotifications(); 592 593 /** 594 * @brief Obtains all notification slots belonging to the specified bundle. 595 * 596 * @param bundleOption Indicates the bundle name and uid of the application. 597 * @param slots Indicates a list of notification slots. 598 * @return Returns get notification slots for bundle result. 599 */ 600 ErrCode GetNotificationSlotsForBundle( 601 const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots); 602 603 /** 604 * @brief Obtains notification slot belonging to the specified bundle. 605 * 606 * @param bundleOption Indicates the bundle name and uid of the application. 607 * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot. 608 * @param slot Indicates a notification slot. 609 * @return Returns get notification slots for bundle result. 610 */ 611 ErrCode GetNotificationSlotForBundle( 612 const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, 613 sptr<NotificationSlot> &slot); 614 615 /** 616 * @brief Updates all notification slots for the specified bundle. 617 * 618 * @param bundleOption Indicates the bundle name and uid of the application. 619 * @param slots Indicates a list of new notification slots. 620 * @return Returns update notification slots for bundle result. 621 */ 622 ErrCode UpdateNotificationSlots( 623 const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots); 624 625 /** 626 * @brief Obtains all active notifications in the current system. The caller must have system permissions to 627 * call this method. 628 * 629 * @param notification Indicates all active notifications of this application. 630 * @return Returns get all active notifications 631 */ 632 ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ification); 633 634 /** 635 * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method 636 * to obtain particular active notifications, you must have received the notifications and obtained the key 637 * via {Notification::GetKey()}. 638 * 639 * @param key Indicates the key array for querying corresponding active notifications. 640 * If this parameter is null, this method returns all active notifications in the system. 641 * @param notification Indicates the set of active notifications corresponding to the specified key. 642 * @return Returns get all active notifications result. 643 */ 644 ErrCode GetAllActiveNotifications( 645 const std::vector<std::string> key, std::vector<sptr<Notification>> ¬ification); 646 647 /** 648 * @brief Obtains the live view notification extra info by the extraInfoKeys. To call this method 649 * to obtain particular live view notification extra info, you must have received the 650 * @param filter 651 * @param extraInfo 652 * @return 653 */ 654 ErrCode GetActiveNotificationByFilter( 655 const LiveViewFilter &filter, sptr<NotificationRequest> &request); 656 657 /** 658 * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies 659 * the current application, no permission is required for calling this method. If bundle specifies another 660 * application, the caller must have system permissions. 661 * 662 * @param bundleOption Indicates the bundle name and uid of the application. 663 * @param allowed True if the application has permissions; returns false otherwise. 664 * @return Returns is allowed notify result. 665 */ 666 ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed); 667 668 /** 669 * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must 670 * have system permissions to call this method. 671 * 672 * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only 673 * be null or an empty string, indicating the current device. 674 * @param enabled Specifies whether to allow all applications to publish notifications. The value true 675 * indicates that notifications are allowed, and the value false indicates that notifications are not 676 * allowed. 677 * @return Returns set notifications enabled for all bundles result. 678 */ 679 ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled); 680 681 /** 682 * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller 683 * must have system permissions to call this method. 684 * 685 * @param deviceId Indicates the ID of the device running the application. At present, this parameter can 686 * only be null or an empty string, indicating the current device. 687 * @param enabled Specifies whether to allow the current application to publish notifications. The value 688 * true indicates that notifications are allowed, and the value false indicates that 689 * notifications are not allowed. 690 * @return Returns set notifications enabled for default bundle result. 691 */ 692 ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled); 693 694 /** 695 * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller 696 * must have system permissions to call this method. 697 * 698 * @param bundleOption Indicates the bundle name and uid of the application. 699 * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only 700 * be null or an empty string, indicating the current device. 701 * @param enabled Specifies whether to allow the given application to publish notifications. The value 702 * true indicates that notifications are allowed, and the value false indicates that notifications 703 * are not allowed. 704 * @return Returns set notifications enabled for specified bundle result. 705 */ 706 ErrCode SetNotificationsEnabledForSpecifiedBundle( 707 const NotificationBundleOption &bundleOption, const std::string &deviceId, bool enabled); 708 709 /** 710 * @brief Sets whether to allow a specified application to to show badge. 711 * 712 * @param bundleOption Indicates the bundle name and uid of the application. 713 * @param enabled Specifies whether to allow the given application to show badge. 714 * @return Returns set result. 715 */ 716 ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled); 717 718 /** 719 * @brief Obtains the flag that whether to allow a specified application to to show badge. 720 * 721 * @param bundleOption Indicates the bundle name and uid of the application. 722 * @param enabled Specifies whether to allow the given application to show badge. 723 * @return Returns get result. 724 */ 725 ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled); 726 727 /** 728 * @brief Obtains the flag that whether to allow the current application to to show badge. 729 * 730 * @param enabled Specifies whether to allow the given application to show badge. 731 * @return Returns get result. 732 */ 733 ErrCode GetShowBadgeEnabled(bool &enabled); 734 735 /** 736 * @brief Cancels the notification of the specified group of this application. 737 * 738 * @param groupName the specified group name. 739 * @return Returns cancel group result. 740 */ 741 ErrCode CancelGroup(const std::string &groupName); 742 743 /** 744 * @brief Removes the notification of the specified group of the specified application. 745 * 746 * @param bundleOption Indicates the bundle name and uid of the specified application. 747 * @param groupName Indicates the specified group name. 748 * @return Returns remove group by bundle result. 749 */ 750 ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName); 751 752 /** 753 * @brief Sets the do not disturb time. 754 * @note Your application must have system signature to call this method. 755 * 756 * @param doNotDisturbDate Indicates the do not disturb time to set. 757 * @return Returns set do not disturb time result. 758 */ 759 ErrCode SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate); 760 761 /** 762 * @brief Obtains the do not disturb time. 763 * @note Your application must have system signature to call this method. 764 * 765 * @param doNotDisturbDate Indicates the do not disturb time to get. 766 * @return Returns set do not disturb time result. 767 */ 768 ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate); 769 770 /** 771 * @brief Add the do not disturb profiles. 772 * @note Your application must have system signature to call this method. 773 * 774 * @param doNotDisturbProfiles Indicates the do not disturb profiles to add. 775 * @return Returns add do not disturb profiles result. 776 */ 777 ErrCode AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles); 778 779 /** 780 * @brief Remove the do not disturb profiles. 781 * @note Your application must have system signature to call this method. 782 * 783 * @param doNotDisturbProfiles Indicates the do not disturb profiles to remove. 784 * @return Returns remove do not disturb profiles result. 785 */ 786 ErrCode RemoveDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles); 787 788 /** 789 * @brief Obtains the flag that whether to support do not disturb mode. 790 * 791 * @param doesSupport Specifies whether to support do not disturb mode. 792 * @return Returns check result. 793 */ 794 ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport); 795 796 /** 797 * @brief Is coming call need silent in do not disturb mode. 798 * 799 * @param phoneNumber the calling format number. 800 * @return Returns silent in do not disturb mode. 801 */ 802 ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType); 803 804 /** 805 * @brief Checks if the device supports distributed notification. 806 * 807 * @param enabled True if the device supports distributed notification; false otherwise. 808 * @return Returns is distributed enabled result. 809 */ 810 ErrCode IsDistributedEnabled(bool &enabled); 811 812 /** 813 * @brief Sets whether the device supports distributed notifications. 814 * 815 * @param enable Specifies whether to enable the device to support distributed notification. 816 * The value true indicates that the device is enabled to support distributed notifications, and 817 * the value false indicates that the device is forbidden to support distributed notifications. 818 * @return Returns enable distributed result. 819 */ 820 ErrCode EnableDistributed(const bool enabled); 821 822 /** 823 * @brief Sets whether an application supports distributed notifications. 824 * 825 * @param bundleOption Indicates the bundle name and uid of an application. 826 * @param enabled Specifies whether to enable an application to support distributed notification. 827 * The value true indicates that the application is enabled to support distributed notifications, 828 * and the value false indicates that the application is forbidden to support distributed 829 * notifications. 830 * @return Returns enable distributed by bundle result. 831 */ 832 ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled); 833 834 /** 835 * @brief Sets whether this application supports distributed notifications. 836 * 837 * @param enabled Specifies whether to enable this application to support distributed notification. 838 * The value true indicates that this application is enabled to support distributed notifications, 839 * and the value false indicates that this application is forbidden to support distributed 840 * notifications. 841 * @return Returns enable distributed self result. 842 */ 843 ErrCode EnableDistributedSelf(const bool enabled); 844 845 /** 846 * @brief Checks whether an application supports distributed notifications. 847 * 848 * @param bundleOption Indicates the bundle name and uid of an application. 849 * @param enabled True if the application supports distributed notification; false otherwise. 850 * @return Returns is distributed enabled by bundle result. 851 */ 852 ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled); 853 854 /** 855 * @brief Obtains the device remind type. 856 * @note Your application must have system signature to call this method. 857 * 858 * @param remindType Indicates the device remind type to get. 859 * @return Returns get device reminder type result. 860 */ 861 ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType); 862 863 /** 864 * @brief Publishes a continuous task notification. 865 * 866 * @param request Indicates the NotificationRequest object for setting the notification content. 867 * This parameter must be specified. 868 * @return Returns publish continuous task notification result. 869 */ 870 ErrCode PublishContinuousTaskNotification(const NotificationRequest &request); 871 872 /** 873 * @brief Cancels a published continuous task notification matching the specified label and notificationId. 874 * 875 * @param label Indicates the label of the continuous task notification to cancel. 876 * @param notificationId Indicates the ID of the continuous task notification to cancel. 877 * @return Returns cancel continuous task notification result. 878 */ 879 ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId); 880 881 /** 882 * @brief Obtains whether the template is supported by the system. 883 * 884 * @param support whether is it a system supported template. 885 * @return Returns check result. 886 */ 887 ErrCode IsSupportTemplate(const std::string &templateName, bool &support); 888 889 /** 890 * @brief Resets ans manager proxy when OnRemoteDied called. 891 */ 892 void ResetAnsManagerProxy(); 893 894 /** 895 * @brief try to reconnect ans SA when SA manager OnAddSystemAbility called. 896 */ 897 void Reconnect(); 898 899 /** 900 * @brief Publishes a scheduled reminder. 901 * 902 * @param reminder Indicates a reminder. 903 * @return Returns publish result. 904 */ 905 ErrCode PublishReminder(ReminderRequest &reminder); 906 907 /** 908 * @brief Cancels a specified reminder. 909 * 910 * @param reminderId Indicates reminder Id. 911 * @return Returns cancel result. 912 */ 913 ErrCode CancelReminder(const int32_t reminderId); 914 915 /** 916 * @brief Cancels all reminders of current third part application. 917 * 918 * @return Returns cancel result. 919 */ 920 ErrCode CancelAllReminders(); 921 922 /** 923 * @brief Obtains all valid reminder notifications set by the current application. 924 * 925 * @param[out] validReminders Indicates the vector to store the result. 926 * @return Returns get valid reminders result. 927 */ 928 ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &validReminders); 929 930 /** 931 * @brief Add exclude date for reminder 932 * 933 * @param reminderId Identifies the reminders id. 934 * @param date exclude date 935 * @return Returns ERR_OK on success, others on failure. 936 */ 937 ErrCode AddExcludeDate(const int32_t reminderId, const uint64_t date); 938 939 /** 940 * @brief Clear exclude date for reminder 941 * 942 * @param reminderId Identifies the reminders id. 943 * @return Returns ERR_OK on success, others on failure. 944 */ 945 ErrCode DelExcludeDates(const int32_t reminderId); 946 947 /** 948 * @brief Get exclude date for reminder 949 * 950 * @param reminderId Identifies the reminders id. 951 * @param dates exclude dates 952 * @return Returns ERR_OK on success, others on failure. 953 */ 954 ErrCode GetExcludeDates(const int32_t reminderId, std::vector<uint64_t>& dates); 955 956 /** 957 * @brief Checks whether this application has permission to publish notifications under the user. 958 * 959 * @param userId Indicates the userId of the application. 960 * @param allowed True if the application has permissions; returns false otherwise. 961 * @return Returns get allowed result. 962 */ 963 ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed); 964 965 /** 966 * @brief Sets whether to allow all applications to publish notifications on a specified user. 967 * The caller must have system permissions to call this method. 968 * 969 * @param userId Indicates the ID of the user running the application. 970 * @param enabled Specifies whether to allow all applications to publish notifications. The value true 971 * indicates that notifications are allowed, and the value false indicates that notifications 972 * are not allowed. 973 * @return Returns set notifications enabled for all bundles result. 974 */ 975 ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled); 976 977 /** 978 * @brief Removes notifications under specified user. 979 * @note Your application must have platform signature to use this method. 980 * 981 * @param userId Indicates the ID of user whose notifications are to be removed. 982 * @return Returns remove notification result. 983 */ 984 ErrCode RemoveNotifications(const int32_t &userId); 985 986 /** 987 * @brief Sets the do not disturb time on a specified user. 988 * @note Your application must have system signature to call this method. 989 * 990 * @param userId Indicates the specific user. 991 * @param doNotDisturbDate Indicates the do not disturb time to set. 992 * @return Returns set do not disturb time result. 993 */ 994 ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate); 995 996 /** 997 * @brief Obtains the do not disturb time on a specified user. 998 * @note Your application must have system signature to call this method. 999 * 1000 * @param userId Indicates the specific user. 1001 * @param doNotDisturbDate Indicates the do not disturb time to get. 1002 * @return Returns set do not disturb time result. 1003 */ 1004 ErrCode GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate); 1005 1006 /** 1007 * Set whether the application slot is enabled. 1008 * 1009 * @param bundleOption Indicates the bundle name and uid of the application. 1010 * @param slotType Indicates type of slot. 1011 * @param enable the type of slot enabled. 1012 * @param isForceControl Indicates whether the slot is affected by the notification switch. 1013 * @return Returns get slot number by bundle result. 1014 */ 1015 ErrCode SetEnabledForBundleSlot(const NotificationBundleOption &bundleOption, 1016 const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl); 1017 1018 /** 1019 * Obtains whether the application slot is enabled. 1020 * 1021 * @param bundleOption Indicates the bundle name and uid of the application. 1022 * @param slotType Indicates type of slot. 1023 * @param enable the type of slot enabled to get. 1024 * @return Returns get slot number by bundle result. 1025 */ 1026 ErrCode GetEnabledForBundleSlot( 1027 const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled); 1028 1029 /** 1030 * Obtains whether the current application slot is enabled. 1031 * 1032 * @param slotType Indicates type of slot. 1033 * @param enable the type of slot enabled to get. 1034 * @return Returns get enabled result. 1035 */ 1036 ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled); 1037 1038 /** 1039 * @brief Obtains specific datas via specified dump option. 1040 * 1041 * @param cmd Indicates the specified dump command. 1042 * @param bundle Indicates the specified bundle name. 1043 * @param userId Indicates the specified userId. 1044 * @param recvUserId Indicates the specified receiver userId. 1045 * @param dumpInfo Indicates the container containing datas. 1046 * @return Returns check result. 1047 */ 1048 ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, 1049 std::vector<std::string> &dumpInfo); 1050 1051 /** 1052 * @brief Set whether to sync notifications to devices that do not have the app installed. 1053 * 1054 * @param userId Indicates the specific user. 1055 * @param enabled Allow or disallow sync notifications. 1056 * @return Returns set enabled result. 1057 */ 1058 ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled); 1059 1060 /** 1061 * @brief Obtains whether to sync notifications to devices that do not have the app installed. 1062 * 1063 * @param userId Indicates the specific user. 1064 * @param enabled Allow or disallow sync notifications. 1065 * @return Returns get enabled result. 1066 */ 1067 ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled); 1068 1069 /** 1070 * @brief Set badge number. 1071 * 1072 * @param badgeNumber The badge number. 1073 * @return Returns set badge number result. 1074 */ 1075 ErrCode SetBadgeNumber(int32_t badgeNumber); 1076 1077 /** 1078 * @brief Set badge number by bundle. 1079 * 1080 * @param bundleOption Indicates the bundle name and uid of the application. 1081 * @param badgeNumber The badge number. 1082 * @return Returns set badge number by bundle result. 1083 */ 1084 ErrCode SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber); 1085 1086 /** 1087 * @brief Obtains allow notification application list. 1088 * 1089 * @param bundleOption Indicates the bundle bundleOption. 1090 * @return Returns ERR_OK on success, others on failure. 1091 */ 1092 ErrCode GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> &bundleOption); 1093 1094 /** 1095 * @brief Register Push Callback. 1096 * 1097 * @param pushCallback PushCallBack. 1098 * @param notificationCheckRequest Filter conditions for push check 1099 * @return Returns register PushCallback result. 1100 */ 1101 ErrCode RegisterPushCallback( 1102 const sptr<IRemoteObject> &pushCallback, const sptr<NotificationCheckRequest> ¬ificationCheckRequest); 1103 1104 /** 1105 * @brief Unregister Push Callback. 1106 * 1107 * @return Returns unregister push Callback result. 1108 */ 1109 ErrCode UnregisterPushCallback(); 1110 1111 /** 1112 * @brief Set agent relationship. 1113 * 1114 * @param key Indicates storing agent relationship if the value is "PROXY_PKG". 1115 * @param value Indicates key-value pair of agent relationship. 1116 * @return Returns set result. 1117 */ 1118 ErrCode SetAdditionConfig(const std::string &key, const std::string &value); 1119 1120 /** 1121 * @brief Sets whether to allow a specified application to publish notifications cross 1122 * device collaboration. The caller must have system permissions to call this method. 1123 * 1124 * @param bundleOption Indicates the bundle name and uid of the application. 1125 * @param deviceType Indicates the type of the device running the application. 1126 * @param enabled Specifies whether to allow the given application to publish notifications. The value 1127 * true indicates that notifications are allowed, and the value false indicates that notifications 1128 * are not allowed. 1129 * @return Returns set notifications enabled for specified bundle result. 1130 */ 1131 ErrCode SetDistributedEnabledByBundle( 1132 const NotificationBundleOption &bundleOption, const std::string &deviceType, const bool enabled); 1133 1134 /** 1135 * @brief get whether to allow a specified application to publish notifications cross 1136 * device collaboration. The caller must have system permissions to call this method. 1137 * 1138 * @param bundleOption Indicates the bundle name and uid of the application. 1139 * @param deviceType Indicates the type of the device running the application. 1140 * @param enabled Specifies whether to allow the given application to publish notifications. The value 1141 * true indicates that notifications are allowed, and the value false indicates that notifications 1142 * are not allowed. 1143 * @return Returns set notifications enabled for specified bundle result. 1144 */ 1145 ErrCode IsDistributedEnabledByBundle( 1146 const NotificationBundleOption &bundleOption, const std::string &deviceType, bool &enabled); 1147 1148 /** 1149 * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders 1150 * 1151 * @param deviceType Indicates the type of the device running the application. 1152 * @param enabled Specifies whether to allow the given application to publish notifications. 1153 * The value true indicates that notifications are allowed, and the value 1154 * false indicates that notifications are not allowed. 1155 * @return Returns set notifications enabled for specified bundle result. 1156 */ 1157 ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled); 1158 1159 /** 1160 * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders 1161 * 1162 * @param deviceType Indicates the type of the device running the application. 1163 * @param enabled Specifies whether to allow the given application to publish notifications. 1164 * The value true indicates that notifications are allowed, and the value 1165 * false indicates that notifications are not allowed. 1166 * @return Returns set notifications enabled for specified bundle result. 1167 */ 1168 ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled); 1169 1170 /** 1171 * @brief Cancels a published agent notification. 1172 * 1173 * @param bundleOption Indicates the bundle name and uid of the application. 1174 * @param id Indicates the unique notification ID in the application. 1175 * @return Returns cancel result. 1176 */ 1177 ErrCode CancelAsBundleWithAgent(const NotificationBundleOption &bundleOption, const int32_t id); 1178 1179 /** 1180 * @brief Set the status of the target device. 1181 * 1182 * @param deviceType Type of the device whose status you want to set. 1183 * @param status The status. 1184 * @return Returns set result. 1185 */ 1186 ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status); 1187 1188 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 1189 /** 1190 * @brief Register Swing swingCbFunc. 1191 * 1192 * @param swingCallback swingCbFunc. 1193 * @return Returns register swingCbFunc result. 1194 */ 1195 ErrCode RegisterSwingCallback(const std::function<void(bool, int)> swingCbFunc); 1196 #endif 1197 1198 /** 1199 * @brief Get do not disturb profile by id. 1200 * 1201 * @param id Profile id. 1202 * @param status Indicates the NotificationDoNotDisturbProfile objects. 1203 * @return Returns ERR_OK on success, others on failure. 1204 */ 1205 ErrCode GetDoNotDisturbProfile(int32_t id, sptr<NotificationDoNotDisturbProfile> &profile); 1206 1207 /** 1208 * @brief Ans service died, OnRemoteDied called. 1209 */ 1210 void OnServiceDied(); 1211 1212 /** 1213 * @brief Update Notification Timer by uid 1214 * 1215 * @param uid uid. 1216 * @return Returns Update result. 1217 */ 1218 ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused); 1219 private: 1220 /** 1221 * @brief Gets Ans Manager proxy. 1222 * 1223 * @return Returns true if succeed; returns false otherwise. 1224 */ 1225 sptr<AnsManagerInterface> GetAnsManagerProxy(); 1226 1227 /** 1228 * @brief Checks if the MediaContent can be published. 1229 * 1230 * @param request Indicates the specified request. 1231 * @return Returns true if the MediaContent can be published; returns false otherwise. 1232 */ 1233 bool CanPublishMediaContent(const NotificationRequest &request) const; 1234 1235 /** 1236 * @brief Checks whether the picture size exceeds the limit. 1237 * 1238 * @param request Indicates the specified request. 1239 * @return Returns the ErrCode. 1240 */ 1241 ErrCode CheckImageSize(const NotificationRequest &request); 1242 1243 /** 1244 * @brief Checks whether the notification doesn't support distribution. 1245 * 1246 * @param type Indicates the specified NotificationContent::Type. 1247 * @return Returns true if the notification doesn't support distribution; returns false otherwise. 1248 */ 1249 bool IsNonDistributedNotificationType(const NotificationContent::Type &type); 1250 1251 /** 1252 * @brief Checks if the LiveViewContent can be published. 1253 * 1254 * @param request Indicates the specified request. 1255 * @return Returns true if the MediaContent can be published; returns false otherwise. 1256 */ 1257 bool CanPublishLiveViewContent(const NotificationRequest &request) const; 1258 1259 bool IsValidTemplate(const NotificationRequest &request) const; 1260 bool IsValidDelayTime(const NotificationRequest &request) const; 1261 void CreateSubscribeListener(const std::shared_ptr<NotificationSubscriber> &subscriber, 1262 sptr<SubscriberListener> &listener); 1263 1264 private: 1265 std::mutex subscriberMutex_; 1266 std::map<std::shared_ptr<NotificationSubscriber>, sptr<SubscriberListener>> subscribers_; 1267 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 1268 sptr<SwingCallBackStub> swingCallBackStub_; 1269 #endif 1270 }; 1271 } // namespace Notification 1272 } // namespace OHOS 1273 1274 #endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_NOTIFICATION_H 1275