1 /* 2 * Copyright (c) 2021-2023 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_MANAGER_INTERFACE_H 17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H 18 19 #include <string> 20 #include <vector> 21 22 #include "ans_dialog_callback_interface.h" 23 #include "ans_subscriber_interface.h" 24 #include "ans_subscriber_local_live_view_interface.h" 25 #include "iremote_broker.h" 26 #include "notification_bundle_option.h" 27 #include "notification_constant.h" 28 #include "notification_do_not_disturb_date.h" 29 #include "notification_request.h" 30 #include "notification_slot.h" 31 #include "notification_subscribe_info.h" 32 #include "reminder_request.h" 33 34 namespace OHOS { 35 namespace Notification { 36 class AnsManagerInterface : public IRemoteBroker { 37 public: 38 AnsManagerInterface() = default; 39 virtual ~AnsManagerInterface() = default; 40 DISALLOW_COPY_AND_MOVE(AnsManagerInterface); 41 42 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.AnsManagerInterface"); 43 44 /** 45 * @brief Publishes a notification with a specified label. 46 * @note If a notification with the same ID has been published by the current application and has not been deleted, 47 * this method will update the notification. 48 * 49 * @param label Indicates the label of the notification to publish. 50 * @param notification Indicates the NotificationRequest object for setting the notification content. 51 * This parameter must be specified. 52 * @return Returns ERR_OK on success, others on failure. 53 */ 54 virtual ErrCode Publish(const std::string &label, const sptr<NotificationRequest> ¬ification) = 0; 55 56 /** 57 * @brief Cancels a published notification matching the specified label and notificationId. 58 * 59 * @param notificationId Indicates the ID of the notification to cancel. 60 * @param label Indicates the label of the notification to cancel. 61 * @return Returns cancel notification result. 62 */ 63 virtual ErrCode Cancel(int notificationId, const std::string &label) = 0; 64 65 /** 66 * @brief Cancels all the published notifications. 67 * 68 * @return Returns ERR_OK on success, others on failure. 69 */ 70 virtual ErrCode CancelAll() = 0; 71 72 /** 73 * @brief Cancels a published agent notification. 74 * 75 * @param notificationId Indicates the unique notification ID in the application. 76 * The value must be the ID of a published notification. 77 * Otherwise, this method does not take effect. 78 * @param representativeBundle Indicates the name of application bundle your application is representing. 79 * @param userId Indicates the specific user. 80 * @return Returns cancel notification result. 81 */ 82 virtual ErrCode CancelAsBundle( 83 int32_t notificationId, const std::string &representativeBundle, int32_t userId) = 0; 84 85 /** 86 * @brief Adds a notification slot by type. 87 * 88 * @param slotType Indicates the notification slot type to be added. 89 * @return Returns ERR_OK on success, others on failure. 90 */ 91 virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) = 0; 92 93 /** 94 * @brief Creates multiple notification slots. 95 * 96 * @param slots Indicates the notification slots to create. 97 * @return Returns ERR_OK on success, others on failure. 98 */ 99 virtual ErrCode AddSlots(const std::vector<sptr<NotificationSlot>> &slots) = 0; 100 101 /** 102 * @brief Deletes a created notification slot based on the slot ID. 103 * 104 * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot 105 * This parameter must be specified. 106 * @return Returns ERR_OK on success, others on failure. 107 */ 108 virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) = 0; 109 110 /** 111 * @brief Deletes all notification slots. 112 * 113 * @return Returns ERR_OK on success, others on failure. 114 */ 115 virtual ErrCode RemoveAllSlots() = 0; 116 117 /** 118 * @brief Queries a created notification slot. 119 * 120 * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This 121 * parameter must be specified. 122 * @param slot Indicates the created NotificationSlot. 123 * @return Returns ERR_OK on success, others on failure. 124 */ 125 virtual ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot) = 0; 126 127 /** 128 * @brief Obtains all notification slots of this application. 129 * 130 * @param slots Indicates the created NotificationSlot. 131 * @return Returns ERR_OK on success, others on failure. 132 */ 133 virtual ErrCode GetSlots(std::vector<sptr<NotificationSlot>> &slots) = 0; 134 135 /** 136 * @brief Obtains the number of slot. 137 * 138 * @param bundleOption Indicates the bundle name and uid of the application. 139 * @param num Indicates the number of slot. 140 * @return Returns ERR_OK on success, others on failure. 141 */ 142 virtual ErrCode GetSlotNumAsBundle(const sptr<NotificationBundleOption> &bundleOption, uint64_t &num) = 0; 143 144 /** 145 * @brief Obtains active notifications of the current application in the system. 146 * 147 * @param notifications Indicates active NotificationRequest objects of the current application. 148 * @return Returns ERR_OK on success, others on failure. 149 */ 150 virtual ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> ¬ifications) = 0; 151 152 /** 153 * @brief Obtains the number of active notifications of the current application in the system. 154 * 155 * @param num Indicates the number of active notifications of the current application. 156 * @return Returns ERR_OK on success, others on failure. 157 */ 158 virtual ErrCode GetActiveNotificationNums(uint64_t &num) = 0; 159 160 /** 161 * @brief Obtains all active notifications in the current system. The caller must have system permissions to 162 * call this method. 163 * 164 * @param notifications Indicates all active notifications of this application. 165 * @return Returns ERR_OK on success, others on failure. 166 */ 167 virtual ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ifications) = 0; 168 169 /** 170 * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method 171 * to obtain particular active notifications, you must have received the notifications and obtained the key 172 * via {Notification::GetKey()}. 173 * 174 * @param key Indicates the key array for querying corresponding active notifications. 175 * If this parameter is null, this method returns all active notifications in the system. 176 * @param notification Indicates the set of active notifications corresponding to the specified key. 177 * @return Returns ERR_OK on success, others on failure. 178 */ 179 virtual ErrCode GetSpecialActiveNotifications( 180 const std::vector<std::string> &key, std::vector<sptr<Notification>> ¬ifications) = 0; 181 182 /** 183 * @brief Obtains the live view notification extra info by the extraInfoKeys. To call this method 184 * to obtain particular live view notification extra info, you must have received the 185 * 186 * @param bundleOption Indicates the bundle name and uid of the application. 187 * @param notificationId Indicates the id of the notification to get the extra info by extra info keys. 188 * @param extraInfoKeys 189 * @param extraInfo 190 * @return 191 */ 192 virtual ErrCode GetActiveNotificationByFilter( 193 const sptr<NotificationBundleOption> &bundleOption, const int32_t notificationId, const std::string &label, 194 std::vector<std::string> extraInfoKeys, sptr<NotificationRequest> &request) = 0; 195 196 /** 197 * @brief Allows another application to act as an agent to publish notifications in the name of your application 198 * bundle. 199 * 200 * @param agent Indicates the name of the application bundle that can publish notifications for your application. 201 * @return Returns ERR_OK on success, others on failure. 202 */ 203 virtual ErrCode SetNotificationAgent(const std::string &agent) = 0; 204 205 /** 206 * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. 207 * 208 * @param agent Indicates the name of the application bundle that can publish notifications for your application if 209 * any; returns null otherwise. 210 * @return Returns ERR_OK on success, others on failure. 211 */ 212 virtual ErrCode GetNotificationAgent(std::string &agent) = 0; 213 214 /** 215 * @brief Checks whether your application has permission to publish notifications by calling 216 * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the 217 * given representativeBundle. 218 * 219 * @param representativeBundle Indicates the name of application bundle your application is representing. 220 * @param canPublish Indicates whether your application has permission to publish notifications. 221 * @return Returns ERR_OK on success, others on failure. 222 */ 223 virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) = 0; 224 225 /** 226 * @brief Publishes a notification in the name of a specified application bundle. 227 * @note If the notification to be published has the same ID as a published notification that has not been canceled, 228 * the existing notification will be replaced by the new one. 229 * 230 * @param notification Indicates the NotificationRequest object for setting the notification content. 231 * This parameter must be specified. 232 * @param representativeBundle Indicates the name of the application bundle that allows your application to publish 233 * notifications for it by calling setNotificationAgent. 234 * @return Returns ERR_OK on success, others on failure. 235 */ 236 virtual ErrCode PublishAsBundle( 237 const sptr<NotificationRequest> notification, const std::string &representativeBundle) = 0; 238 239 /** 240 * @brief Sets the number of active notifications of the current application as the number to be displayed on the 241 * notification badge. 242 * 243 * @param num Indicates the badge number. 244 * @return Returns ERR_OK on success, others on failure. 245 */ 246 virtual ErrCode SetNotificationBadgeNum(int num) = 0; 247 248 /** 249 * @brief Obtains the importance level of this application. 250 * 251 * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, 252 LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. 253 * @return Returns ERR_OK on success, others on failure. 254 */ 255 virtual ErrCode GetBundleImportance(int &importance) = 0; 256 257 /** 258 * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. 259 * 260 * @param granted True if the application has permission; false for otherwise. 261 * @return Returns ERR_OK on success, others on failure. 262 */ 263 virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) = 0; 264 265 /** 266 * @brief Trigger the local live view after the button has been clicked. 267 * @note Your application must have platform signature to use this method. 268 * 269 * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. 270 * @param notificationId Indicates the id of the notification. 271 * @param buttonOption Indicates which button has been clicked. 272 * @return Returns trigger localLiveView result. 273 */ 274 virtual ErrCode TriggerLocalLiveView(const sptr<NotificationBundleOption> &bundleOption, 275 const int32_t notificationId, const sptr<NotificationButtonOption> &buttonOption) = 0; 276 277 /** 278 * @brief Delete notification based on key. 279 * 280 * @param key Indicates the key to delete notification. 281 * @param removeReason Indicates the reason of remove notification. 282 * @return Returns ERR_OK on success, others on failure. 283 */ 284 virtual ErrCode Delete(const std::string &key, int32_t removeReason) = 0; 285 286 /** 287 * @brief Delete notification. 288 * 289 * @param bundleOption Indicates the NotificationBundleOption of the notification. 290 * @param notificationId Indicates the id of the notification. 291 * @param label Indicates the label of the notification. 292 * @param removeReason Indicates the reason of remove notification. 293 * @return Returns ERR_OK on success, others on failure. 294 */ 295 virtual ErrCode RemoveNotification(const sptr<NotificationBundleOption> &bundleOption, int notificationId, 296 const std::string &label, int32_t removeReason) = 0; 297 298 /** 299 * @brief Delete all notifications. 300 * 301 * @param bundleOption Indicates the NotificationBundleOption of notifications. 302 * @return Returns ERR_OK on success, others on failure. 303 */ 304 virtual ErrCode RemoveAllNotifications(const sptr<NotificationBundleOption> &bundleOption) = 0; 305 306 virtual ErrCode RemoveNotifications(const std::vector<std::string> &hashcodes, int32_t removeReason) = 0; 307 308 /** 309 * @brief Remove notifications based on bundle. 310 * 311 * @param bundleOption Indicates the NotificationBundleOption of notifications. 312 * @return Returns ERR_OK on success, others on failure. 313 */ 314 virtual ErrCode DeleteByBundle(const sptr<NotificationBundleOption> &bundleOption) = 0; 315 316 /** 317 * @brief Remove all notifications. 318 * 319 * @return Returns ERR_OK on success, others on failure. 320 */ 321 virtual ErrCode DeleteAll() = 0; 322 323 /** 324 * @brief Get all the slots corresponding to the bundle. 325 * 326 * @param bundleOption Indicates the NotificationBundleOption object. 327 * @param slots Indicates the notification slots. 328 * @return Returns ERR_OK on success, others on failure. 329 */ 330 virtual ErrCode GetSlotsByBundle( 331 const sptr<NotificationBundleOption> &bundleOption, std::vector<sptr<NotificationSlot>> &slots) = 0; 332 333 /** 334 * @brief Update slots according to bundle. 335 * 336 * @param bundleOption Indicates the NotificationBundleOption object. 337 * @param slots Indicates the notification slots to be updated. 338 * @return Returns ERR_OK on success, others on failure. 339 */ 340 virtual ErrCode UpdateSlots( 341 const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlot>> &slots) = 0; 342 343 /** 344 * @brief Allow notifications to be sent based on the deviceId. 345 * 346 * @param deviceId Indicates the device Id. 347 * @return Returns ERR_OK on success, others on failure. 348 */ 349 virtual ErrCode RequestEnableNotification(const std::string &deviceId, 350 const sptr<AnsDialogCallback> &callback, 351 const sptr<IRemoteObject> &callerToken) = 0; 352 353 /** 354 * @brief Set whether to allow the specified deviceId to send notifications for current bundle. 355 * 356 * @param deviceId Indicates the device Id. 357 * @param enabled Indicates the flag that allows notification to be pulished. 358 * @return Returns ERR_OK on success, others on failure. 359 */ 360 virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) = 0; 361 362 /** 363 * @brief Set whether to allow the specified deviceId to send notifications for all bundles. 364 * 365 * @param deviceId Indicates the device Id. 366 * @param enabled Indicates the flag that allows notification to be pulished. 367 * @return Returns ERR_OK on success, others on failure. 368 */ 369 virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) = 0; 370 371 /** 372 * @brief Set whether to allow the specified bundle to send notifications. 373 * 374 * @param bundleOption Indicates the NotificationBundleOption object. 375 * @param enabled Indicates the flag that allows notification to be pulished. 376 * @return Returns ERR_OK on success, others on failure. 377 */ 378 virtual ErrCode SetNotificationsEnabledForSpecialBundle( 379 const std::string &deviceId, const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0; 380 381 /** 382 * @brief Sets whether the bundle allows the banner to display notification. 383 * 384 * @param bundleOption Indicates the NotificationBundleOption object. 385 * @param enabled Indicates the flag that allows badge to be shown. 386 * @return Returns ERR_OK on success, others on failure. 387 */ 388 virtual ErrCode SetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0; 389 390 /** 391 * @brief Gets whether the bundle allows the badge to display the status of notifications. 392 * 393 * @param bundleOption Indicates the NotificationBundleOption object. 394 * @param enabled Indicates the flag that allows badge to be shown. 395 * @return Returns ERR_OK on success, others on failure. 396 */ 397 virtual ErrCode GetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled) = 0; 398 399 /** 400 * @brief Gets whether allows the badge to display the status of notifications. 401 * 402 * @param enabled Indicates the flag that allows badge to be shown. 403 * @return Returns ERR_OK on success, others on failure. 404 */ 405 virtual ErrCode GetShowBadgeEnabled(bool &enabled) = 0; 406 407 /** 408 * @brief Subscribes notifications. 409 * 410 * @param subscriber Indicates the subscriber. 411 * @param info Indicates the NotificationSubscribeInfo object. 412 * @return Returns ERR_OK on success, others on failure. 413 */ 414 virtual ErrCode Subscribe(const sptr<AnsSubscriberInterface> &subscriber, 415 const sptr<NotificationSubscribeInfo> &info) = 0; 416 417 /** 418 * @brief Subscribes notifications self. 419 * 420 * @param subscriber Indicates the subscriber. 421 * @return Returns ERR_OK on success, others on failure. 422 */ 423 virtual ErrCode SubscribeSelf(const sptr<AnsSubscriberInterface> &subscriber) = 0; 424 425 /** 426 * @brief Subscribes local live view notifications. 427 * 428 * @param subscriber Indicates the subscriber. 429 * @param info Indicates the NotificationSubscribeInfo object. 430 * @return Returns ERR_OK on success, others on failure. 431 */ 432 virtual ErrCode SubscribeLocalLiveView(const sptr<AnsSubscriberLocalLiveViewInterface> &subscriber, 433 const sptr<NotificationSubscribeInfo> &info) = 0; 434 435 /** 436 * @brief Unsubscribes notifications. 437 * 438 * @param subscriber Indicates the subscriber. 439 * @param info Indicates the NotificationSubscribeInfo object. 440 * @return Returns ERR_OK on success, others on failure. 441 */ 442 virtual ErrCode Unsubscribe( 443 const sptr<AnsSubscriberInterface> &subscriber, const sptr<NotificationSubscribeInfo> &info) = 0; 444 445 /** 446 * @brief Checks whether this device is allowed to publish notifications. 447 * 448 * @param allowed Indicates the flag that allows notification. 449 * @return Returns ERR_OK on success, others on failure. 450 */ 451 virtual ErrCode IsAllowedNotify(bool &allowed) = 0; 452 453 /** 454 * @brief Checks whether this application is allowed to publish notifications. 455 * 456 * @param allowed Indicates the flag that allows notification. 457 * @return Returns ERR_OK on success, others on failure. 458 */ 459 virtual ErrCode IsAllowedNotifySelf(bool &allowed) = 0; 460 461 /** 462 * @brief Checks whether notifications are allowed for a specific bundle. 463 * 464 * @param bundleOption Indicates the NotificationBundleOption object. 465 * @param allowed Indicates the flag that allows notification. 466 * @return Returns ERR_OK on success, others on failure. 467 */ 468 virtual ErrCode IsSpecialBundleAllowedNotify(const sptr<NotificationBundleOption> &bundleOption, bool &allowed) = 0; 469 470 /** 471 * @brief Set do not disturb date. 472 * 473 * @param date Indicates the NotificationDoNotDisturbDate object. 474 * @return Returns ERR_OK on success, others on failure. 475 */ 476 virtual ErrCode SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> &date) = 0; 477 478 /** 479 * @brief Get do not disturb date. 480 * 481 * @param date Indicates the NotificationDoNotDisturbDate object. 482 * @return Returns ERR_OK on success, others on failure. 483 */ 484 virtual ErrCode GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> &date) = 0; 485 486 /** 487 * @brief Get whether Do Not Disturb mode is supported. 488 * 489 * @param doesSupport Indicates the flag that supports DND mode. 490 * @return Returns ERR_OK on success, others on failure. 491 */ 492 virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) = 0; 493 494 /** 495 * @brief Cancel notifications according to group. 496 * 497 * @param groupName Indicates the group name. 498 * @return Returns ERR_OK on success, others on failure. 499 */ 500 virtual ErrCode CancelGroup(const std::string &groupName) = 0; 501 502 /** 503 * @brief Delete notifications according to bundle and group. 504 * 505 * @param bundleOption Indicates the NotificationBundleOption object. 506 * @param groupName Indicates the group name. 507 * @return Returns ERR_OK on success, others on failure. 508 */ 509 virtual ErrCode RemoveGroupByBundle( 510 const sptr<NotificationBundleOption> &bundleOption, const std::string &groupName) = 0; 511 512 /** 513 * @brief Gets whether distributed notification is enabled. 514 * 515 * @param enabled Indicates the enabled flag. 516 * @return Returns ERR_OK on success, others on failure. 517 */ 518 virtual ErrCode IsDistributedEnabled(bool &enabled) = 0; 519 520 /** 521 * @brief Sets distributed notification enabled or disabled. 522 * 523 * @param enabled Indicates the enabled flag. 524 * @return Returns ERR_OK on success, others on failure. 525 */ 526 virtual ErrCode EnableDistributed(bool enabled) = 0; 527 528 /** 529 * @brief Sets distributed notification enabled or disabled for specific bundle. 530 * 531 * @param bundleOption Indicates the NotificationBundleOption object. 532 * @param enabled Indicates the enabled flag. 533 * @return Returns ERR_OK on success, others on failure. 534 */ 535 virtual ErrCode EnableDistributedByBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0; 536 537 /** 538 * @brief Sets distributed notification enabled or disabled for current bundle. 539 * 540 * @param enabled Indicates the enabled flag. 541 * @return Returns ERR_OK on success, others on failure. 542 */ 543 virtual ErrCode EnableDistributedSelf(bool enabled) = 0; 544 545 /** 546 * @brief Gets whether distributed notification is enabled for specific bundle. 547 * 548 * @param bundleOption Indicates the NotificationBundleOption object. 549 * @param enabled Indicates the enabled flag. 550 * @return Returns ERR_OK on success, others on failure. 551 */ 552 virtual ErrCode IsDistributedEnableByBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled) = 0; 553 554 /** 555 * @brief Get the reminder type of the current device. 556 * 557 * @param remindType Reminder type for the device. 558 * @return Returns ERR_OK on success, others on failure. 559 */ 560 virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) = 0; 561 562 /** 563 * @brief Publishes a continuous notification. 564 * 565 * @param request Notification requests that need to be posted. 566 * @return Returns ERR_OK on success, others on failure. 567 */ 568 virtual ErrCode PublishContinuousTaskNotification(const sptr<NotificationRequest> &request) = 0; 569 570 /** 571 * @brief Cancels a continuous notification. 572 * 573 * @param label Identifies the label of the specified notification. 574 * @param notificationId Identifies the id of the specified notification. 575 * @return Returns ERR_OK on success, others on failure. 576 */ 577 virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) = 0; 578 579 /** 580 * @brief Publishes a reminder notification. 581 * 582 * @param reminder Identifies the reminder notification request that needs to be published. 583 * @return Returns ERR_OK on success, others on failure. 584 */ 585 virtual ErrCode PublishReminder(sptr<ReminderRequest> &reminder) = 0; 586 587 /** 588 * @brief Cancel a reminder notifications. 589 * 590 * @param reminderId Identifies the reminders id that needs to be canceled. 591 * @return Returns ERR_OK on success, others on failure. 592 */ 593 virtual ErrCode CancelReminder(const int32_t reminderId) = 0; 594 595 /** 596 * @brief Get all valid reminder notifications. 597 * 598 * @param reminders Identifies the list of all valid notifications. 599 * @return Returns ERR_OK on success, others on failure. 600 */ 601 virtual ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &reminders) = 0; 602 603 /** 604 * @brief Cancel all reminder notifications. 605 * 606 * @return Returns ERR_OK on success, others on failure. 607 */ 608 virtual ErrCode CancelAllReminders() = 0; 609 610 /** 611 * @brief Checks whether this device is support template. 612 * 613 * @param templateName Identifies the template name for searching as a condition. 614 * @param support Identifies the support flag. 615 * @return Returns ERR_OK on success, others on failure. 616 */ 617 virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) = 0; 618 619 /** 620 * @brief Checks Whether the specified users is allowed to publish notifications. 621 * 622 * @param userId Identifies the user's id. 623 * @param allowed Identifies the allowed flag. 624 * @return Returns ERR_OK on success, others on failure. 625 */ 626 virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) = 0; 627 628 /** 629 * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must 630 * have system permissions to call this method. 631 * 632 * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only 633 * be null or an empty string, indicating the current device. 634 * @param enabled Specifies whether to allow all applications to publish notifications. The value true 635 * indicates that notifications are allowed, and the value false indicates that notifications 636 * are not allowed. 637 * @return Returns ERR_OK on success, others on failure. 638 */ 639 virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) = 0; 640 641 /** 642 * @brief Delete all notifications by user. 643 * 644 * @param userId Indicates the user id. 645 * @return Returns ERR_OK on success, others on failure. 646 */ 647 virtual ErrCode DeleteAllByUser(const int32_t &userId) = 0; 648 649 /** 650 * @brief Set do not disturb date by user. 651 * 652 * @param userId Indicates the user id. 653 * @param date Indicates NotificationDoNotDisturbDate object. 654 * @return Returns ERR_OK on success, others on failure. 655 */ 656 virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr<NotificationDoNotDisturbDate> &date) = 0; 657 658 /** 659 * @brief Get the do not disturb date by user. 660 * 661 * @param userId Indicates the user id. 662 * @param date Indicates the NotificationDoNotDisturbDate object. 663 * @return Returns ERR_OK on success, others on failure. 664 */ 665 virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr<NotificationDoNotDisturbDate> &date) = 0; 666 virtual ErrCode SetEnabledForBundleSlot(const sptr<NotificationBundleOption> &bundleOption, 667 const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) = 0; 668 virtual ErrCode GetEnabledForBundleSlot(const sptr<NotificationBundleOption> &bundleOption, 669 const NotificationConstant::SlotType &slotType, bool &enabled) = 0; 670 virtual ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) = 0; 671 672 /** 673 * @brief Obtains specific datas via specified dump option. 674 * 675 * @param cmd Indicates the specified dump command. 676 * @param bundle Indicates the specified bundle name. 677 * @param userId Indicates the specified userId. 678 * @param dumpInfo Indicates the container containing datas. 679 * @return Returns check result. 680 */ 681 virtual ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, 682 std::vector<std::string> &dumpInfo) = 0; 683 684 /** 685 * @brief Set whether to sync notifications to devices that do not have the app installed. 686 * 687 * @param userId Indicates the specific user. 688 * @param enabled Allow or disallow sync notifications. 689 * @return Returns set enabled result. 690 */ 691 virtual ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) = 0; 692 693 /** 694 * @brief Obtains whether to sync notifications to devices that do not have the app installed. 695 * 696 * @param userId Indicates the specific user. 697 * @param enabled Allow or disallow sync notifications. 698 * @return Returns get enabled result. 699 */ 700 virtual ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) = 0; 701 702 /** 703 * @brief Set badge number. 704 * 705 * @param badgeNumber The badge number. 706 * @return Returns set badge number result. 707 */ 708 virtual ErrCode SetBadgeNumber(int32_t badgeNumber) = 0; 709 710 /** 711 * @brief Obtains the number of slotFlags. 712 * 713 * @param bundleOption Indicates the bundle name and uid of the application. 714 * @param slot Indicates the specified slot object 715 * @param slotFlags Indicates the slogFlags of slot. 716 * @return Returns ERR_OK on success, others on failure. 717 */ 718 virtual ErrCode GetSlotFlagsAsBundle(const sptr<NotificationBundleOption>& bundleOption, uint32_t &slotFlags) = 0; 719 720 /** 721 * @brief Set the slotFlags of slot. 722 * 723 * @param bundleOption Indicates the bundle name and uid of the application. 724 * @param slot Indicates the specified slot object 725 * @param slotFlags Indicates the slogFlags of slot to set. 726 * @return Returns ERR_OK on success, others on failure. 727 */ 728 virtual ErrCode SetSlotFlagsAsBundle(const sptr<NotificationBundleOption>& bundleOption, uint32_t slotFlags) = 0; 729 730 /** 731 * @brief Register Push Callback. 732 * 733 * @param pushCallback PushCallBack. 734 * @return Returns register PushCallback result. 735 */ 736 virtual ErrCode RegisterPushCallback( 737 const sptr<IRemoteObject> &pushCallback, const sptr<NotificationCheckRequest> ¬ificationCheckRequest) = 0; 738 739 /** 740 * @brief Unregister Push Callback. 741 * 742 * @return Returns unregister push Callback result. 743 */ 744 virtual ErrCode UnregisterPushCallback() = 0; 745 }; 746 } // namespace Notification 747 } // namespace OHOS 748 749 #endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H 750