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_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_disable.h" 29 #include "notification_do_not_disturb_date.h" 30 #include "notification_do_not_disturb_profile.h" 31 #include "notification_request.h" 32 #include "notification_slot.h" 33 #include "notification_subscribe_info.h" 34 #include "reminder_request.h" 35 #include "ans_operation_callback_interface.h" 36 37 namespace OHOS { 38 namespace Notification { 39 class AnsManagerInterface : public IRemoteBroker { 40 public: 41 AnsManagerInterface() = default; 42 virtual ~AnsManagerInterface() = default; 43 DISALLOW_COPY_AND_MOVE(AnsManagerInterface); 44 45 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.AnsManagerInterface"); 46 47 /** 48 * @brief Publishes a notification with a specified label. 49 * @note If a notification with the same ID has been published by the current application and has not been deleted, 50 * this method will update the notification. 51 * 52 * @param label Indicates the label of the notification to publish. 53 * @param notification Indicates the NotificationRequest object for setting the notification content. 54 * This parameter must be specified. 55 * @return Returns ERR_OK on success, others on failure. 56 */ 57 virtual ErrCode Publish(const std::string &label, const sptr<NotificationRequest> ¬ification) = 0; 58 59 /** 60 * @brief Publishes a notification. 61 * @note If a notification with the same ID has been published by the current application and has not been deleted, 62 * this method will update the notification. 63 * 64 * @param notification Indicates the NotificationRequest object for setting the notification content. 65 * This parameter must be specified. 66 * @return Returns ERR_OK on success, others on failure. 67 */ 68 virtual ErrCode PublishNotificationForIndirectProxy(const sptr<NotificationRequest> ¬ification) = 0; 69 70 /** 71 * @brief Cancels a published notification matching the specified label and notificationId. 72 * 73 * @param notificationId Indicates the ID of the notification to cancel. 74 * @param label Indicates the label of the notification to cancel. 75 * @param instanceKey Indicates the application instance key. 76 * @return Returns cancel notification result. 77 */ 78 virtual ErrCode Cancel(int notificationId, const std::string &label, const std::string &instanceKey) = 0; 79 80 /** 81 * @brief Cancels all the published notifications. 82 * 83 * @param instanceKey Indicates the application instance key. 84 * @return Returns ERR_OK on success, others on failure. 85 */ 86 virtual ErrCode CancelAll(const std::string &instanceKey) = 0; 87 88 /** 89 * @brief Cancels a published agent notification. 90 * 91 * @param notificationId Indicates the unique notification ID in the application. 92 * The value must be the ID of a published notification. 93 * Otherwise, this method does not take effect. 94 * @param representativeBundle Indicates the name of application bundle your application is representing. 95 * @param userId Indicates the specific user. 96 * @return Returns cancel notification result. 97 */ 98 virtual ErrCode CancelAsBundle( 99 int32_t notificationId, const std::string &representativeBundle, int32_t userId) = 0; 100 101 /** 102 * @brief Cancels a published agent notification. 103 * 104 * @param bundleOption Indicates the bundle of application your application is representing. 105 * @param notificationId Indicates the unique notification ID in the application. 106 * The value must be the ID of a published notification. 107 * Otherwise, this method does not take effect. 108 * @return Returns cancel notification result. 109 */ 110 virtual ErrCode CancelAsBundle(const sptr<NotificationBundleOption> &bundleOption, int32_t notificationId) = 0; 111 112 /** 113 * @brief Cancels a published agent notification. 114 * 115 * @param bundleOption Indicates the bundle of application bundle your application is representing. 116 * @param notificationId Indicates the unique notification ID in the application. 117 * The value must be the ID of a published notification. 118 * Otherwise, this method does not take effect. 119 * @param userId Indicates the specific user. 120 * @return Returns cancel notification result. 121 */ 122 virtual ErrCode CancelAsBundle( 123 const sptr<NotificationBundleOption> &bundleOption, int32_t notificationId, int32_t userId) = 0; 124 125 /** 126 * @brief Adds a notification slot by type. 127 * 128 * @param slotType Indicates the notification slot type to be added. 129 * @return Returns ERR_OK on success, others on failure. 130 */ 131 virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) = 0; 132 133 /** 134 * @brief Creates multiple notification slots. 135 * 136 * @param slots Indicates the notification slots to create. 137 * @return Returns ERR_OK on success, others on failure. 138 */ 139 virtual ErrCode AddSlots(const std::vector<sptr<NotificationSlot>> &slots) = 0; 140 141 /** 142 * @brief Deletes a created notification slot based on the slot ID. 143 * 144 * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot 145 * This parameter must be specified. 146 * @return Returns ERR_OK on success, others on failure. 147 */ 148 virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) = 0; 149 150 /** 151 * @brief Deletes all notification slots. 152 * 153 * @return Returns ERR_OK on success, others on failure. 154 */ 155 virtual ErrCode RemoveAllSlots() = 0; 156 157 /** 158 * @brief Queries a created notification slot. 159 * 160 * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This 161 * parameter must be specified. 162 * @param slot Indicates the created NotificationSlot. 163 * @return Returns ERR_OK on success, others on failure. 164 */ 165 virtual ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot) = 0; 166 167 /** 168 * @brief Obtains all notification slots of this application. 169 * 170 * @param slots Indicates the created NotificationSlot. 171 * @return Returns ERR_OK on success, others on failure. 172 */ 173 virtual ErrCode GetSlots(std::vector<sptr<NotificationSlot>> &slots) = 0; 174 175 /** 176 * @brief Obtains the number of slot. 177 * 178 * @param bundleOption Indicates the bundle name and uid of the application. 179 * @param num Indicates the number of slot. 180 * @return Returns ERR_OK on success, others on failure. 181 */ 182 virtual ErrCode GetSlotNumAsBundle(const sptr<NotificationBundleOption> &bundleOption, uint64_t &num) = 0; 183 184 /** 185 * @brief Obtains active notifications of the current application in the system. 186 * 187 * @param notifications Indicates active NotificationRequest objects of the current application. 188 * @param instanceKey Indicates the application instance key. 189 * @return Returns ERR_OK on success, others on failure. 190 */ 191 virtual ErrCode GetActiveNotifications( 192 std::vector<sptr<NotificationRequest>> ¬ifications, const std::string &instanceKey) = 0; 193 194 /** 195 * @brief Obtains the number of active notifications of the current application in the system. 196 * 197 * @param num Indicates the number of active notifications of the current application. 198 * @return Returns ERR_OK on success, others on failure. 199 */ 200 virtual ErrCode GetActiveNotificationNums(uint64_t &num) = 0; 201 202 /** 203 * @brief Obtains all active notifications in the current system. The caller must have system permissions to 204 * call this method. 205 * 206 * @param notifications Indicates all active notifications of this application. 207 * @return Returns ERR_OK on success, others on failure. 208 */ 209 virtual ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ifications) = 0; 210 211 /** 212 * @brief Obtains all active notifications by slottype in the current system. The caller must have system 213 * permissions to call this method. 214 * 215 * @param notifications Indicates all active notifications of this application. 216 * @return Returns ERR_OK on success, others on failure. 217 */ 218 virtual ErrCode GetAllNotificationsBySlotType(std::vector<sptr<Notification>> ¬ifications, 219 const NotificationConstant::SlotType slotType) = 0; 220 221 /** 222 * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method 223 * to obtain particular active notifications, you must have received the notifications and obtained the key 224 * via {Notification::GetKey()}. 225 * 226 * @param key Indicates the key array for querying corresponding active notifications. 227 * If this parameter is null, this method returns all active notifications in the system. 228 * @param notification Indicates the set of active notifications corresponding to the specified key. 229 * @return Returns ERR_OK on success, others on failure. 230 */ 231 virtual ErrCode GetSpecialActiveNotifications( 232 const std::vector<std::string> &key, std::vector<sptr<Notification>> ¬ifications) = 0; 233 234 /** 235 * @brief Obtains the live view notification extra info by the extraInfoKeys. To call this method 236 * to obtain particular live view notification extra info, you must have received the 237 * 238 * @param bundleOption Indicates the bundle name and uid of the application. 239 * @param notificationId Indicates the id of the notification to get the extra info by extra info keys. 240 * @param extraInfoKeys 241 * @param extraInfo 242 * @return 243 */ 244 virtual ErrCode GetActiveNotificationByFilter( 245 const sptr<NotificationBundleOption> &bundleOption, const int32_t notificationId, const std::string &label, 246 std::vector<std::string> extraInfoKeys, sptr<NotificationRequest> &request) = 0; 247 248 /** 249 * @brief Checks whether your application has permission to publish notifications by calling 250 * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the 251 * given representativeBundle. 252 * 253 * @param representativeBundle Indicates the name of application bundle your application is representing. 254 * @param canPublish Indicates whether your application has permission to publish notifications. 255 * @return Returns ERR_OK on success, others on failure. 256 */ 257 virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) = 0; 258 259 /** 260 * @brief Publishes a notification in the name of a specified application bundle. 261 * @note If the notification to be published has the same ID as a published notification that has not been canceled, 262 * the existing notification will be replaced by the new one. 263 * 264 * @param notification Indicates the NotificationRequest object for setting the notification content. 265 * This parameter must be specified. 266 * @param representativeBundle Indicates the name of the application bundle that allows your application to publish 267 * notifications for it by calling setNotificationAgent. 268 * @return Returns ERR_OK on success, others on failure. 269 */ 270 virtual ErrCode PublishAsBundle( 271 const sptr<NotificationRequest> notification, const std::string &representativeBundle) = 0; 272 273 /** 274 * @brief Sets the number of active notifications of the current application as the number to be displayed on the 275 * notification badge. 276 * 277 * @param num Indicates the badge number. 278 * @return Returns ERR_OK on success, others on failure. 279 */ 280 virtual ErrCode SetNotificationBadgeNum(int num) = 0; 281 282 /** 283 * @brief Obtains the importance level of this application. 284 * 285 * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, 286 LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. 287 * @return Returns ERR_OK on success, others on failure. 288 */ 289 virtual ErrCode GetBundleImportance(int &importance) = 0; 290 291 /** 292 * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. 293 * 294 * @param granted True if the application has permission; false for otherwise. 295 * @return Returns ERR_OK on success, others on failure. 296 */ 297 virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) = 0; 298 299 /** 300 * @brief Trigger the local live view after the button has been clicked. 301 * @note Your application must have platform signature to use this method. 302 * 303 * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. 304 * @param notificationId Indicates the id of the notification. 305 * @param buttonOption Indicates which button has been clicked. 306 * @return Returns trigger localLiveView result. 307 */ 308 virtual ErrCode TriggerLocalLiveView(const sptr<NotificationBundleOption> &bundleOption, 309 const int32_t notificationId, const sptr<NotificationButtonOption> &buttonOption) = 0; 310 311 /** 312 * @brief Delete notification based on key. 313 * 314 * @param key Indicates the key to delete notification. 315 * @param removeReason Indicates the reason of remove notification. 316 * @return Returns ERR_OK on success, others on failure. 317 */ 318 virtual ErrCode Delete(const std::string &key, int32_t removeReason) = 0; 319 320 /** 321 * @brief Delete notification. 322 * 323 * @param bundleOption Indicates the NotificationBundleOption of the notification. 324 * @param notificationId Indicates the id of the notification. 325 * @param label Indicates the label of the notification. 326 * @param removeReason Indicates the reason of remove notification. 327 * @return Returns ERR_OK on success, others on failure. 328 */ 329 virtual ErrCode RemoveNotification(const sptr<NotificationBundleOption> &bundleOption, int notificationId, 330 const std::string &label, int32_t removeReason) = 0; 331 332 /** 333 * @brief Delete all notifications. 334 * 335 * @param bundleOption Indicates the NotificationBundleOption of notifications. 336 * @return Returns ERR_OK on success, others on failure. 337 */ 338 virtual ErrCode RemoveAllNotifications(const sptr<NotificationBundleOption> &bundleOption) = 0; 339 340 virtual ErrCode RemoveNotifications(const std::vector<std::string> &hashcodes, int32_t removeReason) = 0; 341 342 /** 343 * @brief Remove notifications based on bundle. 344 * 345 * @param bundleOption Indicates the NotificationBundleOption of notifications. 346 * @return Returns ERR_OK on success, others on failure. 347 */ 348 virtual ErrCode DeleteByBundle(const sptr<NotificationBundleOption> &bundleOption) = 0; 349 350 /** 351 * @brief Remove all notifications. 352 * 353 * @return Returns ERR_OK on success, others on failure. 354 */ 355 virtual ErrCode DeleteAll() = 0; 356 357 /** 358 * @brief Get all the slots corresponding to the bundle. 359 * 360 * @param bundleOption Indicates the NotificationBundleOption object. 361 * @param slots Indicates the notification slots. 362 * @return Returns ERR_OK on success, others on failure. 363 */ 364 virtual ErrCode GetSlotsByBundle( 365 const sptr<NotificationBundleOption> &bundleOption, std::vector<sptr<NotificationSlot>> &slots) = 0; 366 367 /** 368 * @brief Get the specified slot corresponding to the bundle. 369 * 370 * @param bundleOption Indicates the NotificationBundleOption object. 371 * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This 372 * parameter must be specified. 373 * @param slot Indicates the notification slot. 374 * @return Returns ERR_OK on success, others on failure. 375 */ 376 virtual ErrCode GetSlotByBundle( 377 const sptr<NotificationBundleOption> &bundleOption, const NotificationConstant::SlotType &slotType, 378 sptr<NotificationSlot> &slot) = 0; 379 380 /** 381 * @brief Update slots according to bundle. 382 * 383 * @param bundleOption Indicates the NotificationBundleOption object. 384 * @param slots Indicates the notification slots to be updated. 385 * @return Returns ERR_OK on success, others on failure. 386 */ 387 virtual ErrCode UpdateSlots( 388 const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlot>> &slots) = 0; 389 390 /** 391 * @brief Allow notifications to be sent based on the deviceId. 392 * 393 * @param deviceId Indicates the device Id. 394 * @return Returns ERR_OK on success, others on failure. 395 */ 396 virtual ErrCode RequestEnableNotification(const std::string &deviceId, 397 const sptr<AnsDialogCallback> &callback, 398 const sptr<IRemoteObject> &callerToken) = 0; 399 400 /** 401 * @brief Allow application to publish notifications. 402 * 403 * @param bundleName bundle name. 404 * @param uid uid. 405 * @return Returns set notifications enabled for the bundle result. 406 */ 407 virtual ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) = 0; 408 409 /** 410 * @brief Set whether to allow the specified deviceId to send notifications for current bundle. 411 * 412 * @param deviceId Indicates the device Id. 413 * @param enabled Indicates the flag that allows notification to be pulished. 414 * @return Returns ERR_OK on success, others on failure. 415 */ 416 virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) = 0; 417 418 /** 419 * @brief Set whether to allow the specified deviceId to send notifications for all bundles. 420 * 421 * @param deviceId Indicates the device Id. 422 * @param enabled Indicates the flag that allows notification to be pulished. 423 * @return Returns ERR_OK on success, others on failure. 424 */ 425 virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) = 0; 426 427 /** 428 * @brief Set whether to allow the specified bundle to send notifications. 429 * 430 * @param bundleOption Indicates the NotificationBundleOption object. 431 * @param enabled Indicates the flag that allows notification to be pulished. 432 * @return Returns ERR_OK on success, others on failure. 433 */ 434 virtual ErrCode SetNotificationsEnabledForSpecialBundle( 435 const std::string &deviceId, const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0; 436 437 /** 438 * @brief Sets whether the bundle allows the banner to display notification. 439 * 440 * @param bundleOption Indicates the NotificationBundleOption object. 441 * @param enabled Indicates the flag that allows badge to be shown. 442 * @return Returns ERR_OK on success, others on failure. 443 */ 444 virtual ErrCode SetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0; 445 446 /** 447 * @brief Gets whether the bundle allows the badge to display the status of notifications. 448 * 449 * @param bundleOption Indicates the NotificationBundleOption object. 450 * @param enabled Indicates the flag that allows badge to be shown. 451 * @return Returns ERR_OK on success, others on failure. 452 */ 453 virtual ErrCode GetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled) = 0; 454 455 /** 456 * @brief Gets whether allows the badge to display the status of notifications. 457 * 458 * @param enabled Indicates the flag that allows badge to be shown. 459 * @return Returns ERR_OK on success, others on failure. 460 */ 461 virtual ErrCode GetShowBadgeEnabled(bool &enabled) = 0; 462 463 /** 464 * @brief Subscribes notifications. 465 * 466 * @param subscriber Indicates the subscriber. 467 * @param info Indicates the NotificationSubscribeInfo object. 468 * @return Returns ERR_OK on success, others on failure. 469 */ 470 virtual ErrCode Subscribe(const sptr<AnsSubscriberInterface> &subscriber, 471 const sptr<NotificationSubscribeInfo> &info) = 0; 472 473 /** 474 * @brief Subscribes notifications self. 475 * 476 * @param subscriber Indicates the subscriber. 477 * @return Returns ERR_OK on success, others on failure. 478 */ 479 virtual ErrCode SubscribeSelf(const sptr<AnsSubscriberInterface> &subscriber) = 0; 480 481 /** 482 * @brief Subscribes local live view notifications. 483 * 484 * @param subscriber Indicates the subscriber. 485 * @param info Indicates the NotificationSubscribeInfo object. 486 * @return Returns ERR_OK on success, others on failure. 487 */ 488 virtual ErrCode SubscribeLocalLiveView(const sptr<AnsSubscriberLocalLiveViewInterface> &subscriber, 489 const sptr<NotificationSubscribeInfo> &info, const bool isNative) = 0; 490 491 /** 492 * @brief Unsubscribes notifications. 493 * 494 * @param subscriber Indicates the subscriber. 495 * @param info Indicates the NotificationSubscribeInfo object. 496 * @return Returns ERR_OK on success, others on failure. 497 */ 498 virtual ErrCode Unsubscribe( 499 const sptr<AnsSubscriberInterface> &subscriber, const sptr<NotificationSubscribeInfo> &info) = 0; 500 501 /** 502 * @brief Checks whether this device is allowed to publish notifications. 503 * 504 * @param allowed Indicates the flag that allows notification. 505 * @return Returns ERR_OK on success, others on failure. 506 */ 507 virtual ErrCode IsAllowedNotify(bool &allowed) = 0; 508 509 /** 510 * @brief Checks whether this application is allowed to publish notifications. 511 * 512 * @param allowed Indicates the flag that allows notification. 513 * @return Returns ERR_OK on success, others on failure. 514 */ 515 virtual ErrCode IsAllowedNotifySelf(bool &allowed) = 0; 516 517 /** 518 * @brief Checks whether this application can pop enable notification dialog. 519 * 520 * @param canPop True if can pop enable notification dialog 521 * @return Returns is canPop result. 522 */ 523 virtual ErrCode CanPopEnableNotificationDialog(const sptr<AnsDialogCallback> &callback, 524 bool &canPop, std::string &bundleName) = 0; 525 526 /** 527 * @brief remove enable notification dialog. 528 * 529 * @return Returns remove dialog result. 530 */ 531 virtual ErrCode RemoveEnableNotificationDialog() = 0; 532 533 /** 534 * @brief Checks whether notifications are allowed for a specific bundle. 535 * 536 * @param bundleOption Indicates the NotificationBundleOption object. 537 * @param allowed Indicates the flag that allows notification. 538 * @return Returns ERR_OK on success, others on failure. 539 */ 540 virtual ErrCode IsSpecialBundleAllowedNotify(const sptr<NotificationBundleOption> &bundleOption, bool &allowed) = 0; 541 542 /** 543 * @brief Set do not disturb date. 544 * 545 * @param date Indicates the NotificationDoNotDisturbDate object. 546 * @return Returns ERR_OK on success, others on failure. 547 */ 548 virtual ErrCode SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> &date) = 0; 549 550 /** 551 * @brief Get do not disturb date. 552 * 553 * @param date Indicates the NotificationDoNotDisturbDate object. 554 * @return Returns ERR_OK on success, others on failure. 555 */ 556 virtual ErrCode GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> &date) = 0; 557 558 /** 559 * @brief Add do not disturb profiles. 560 * 561 * @param profiles Indicates the NotificationDoNotDisturbProfile objects. 562 * @return Returns ERR_OK on success, others on failure. 563 */ 564 virtual ErrCode AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles) = 0; 565 566 /** 567 * @brief Remove do not disturb profiles. 568 * 569 * @param profiles Indicates the NotificationDoNotDisturbProfile objects. 570 * @return Returns ERR_OK on success, others on failure. 571 */ 572 virtual ErrCode RemoveDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles) = 0; 573 574 /** 575 * @brief Get whether Do Not Disturb mode is supported. 576 * 577 * @param doesSupport Indicates the flag that supports DND mode. 578 * @return Returns ERR_OK on success, others on failure. 579 */ 580 virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) = 0; 581 582 /** 583 * @brief Is coming call need silent in do not disturb mode. 584 * 585 * @param phoneNumber the calling format number. 586 * @return Returns silent in do not disturb mode. 587 */ 588 virtual ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) = 0; 589 590 /** 591 * @brief Cancel notifications according to group. 592 * 593 * @param groupName Indicates the group name. 594 * @param instanceKey Indicates the application instance key. 595 * @return Returns ERR_OK on success, others on failure. 596 */ 597 virtual ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey) = 0; 598 599 /** 600 * @brief Delete notifications according to bundle and group. 601 * 602 * @param bundleOption Indicates the NotificationBundleOption object. 603 * @param groupName Indicates the group name. 604 * @return Returns ERR_OK on success, others on failure. 605 */ 606 virtual ErrCode RemoveGroupByBundle( 607 const sptr<NotificationBundleOption> &bundleOption, const std::string &groupName) = 0; 608 609 /** 610 * @brief Gets whether distributed notification is enabled. 611 * 612 * @param enabled Indicates the enabled flag. 613 * @return Returns ERR_OK on success, others on failure. 614 */ 615 virtual ErrCode IsDistributedEnabled(bool &enabled) = 0; 616 617 /** 618 * @brief Set the channel switch for collaborative reminders. 619 The caller must have system permissions to call this method. 620 * 621 * @param slotType Indicates the slot type of the application. 622 * @param deviceType Indicates the type of the device running the application. 623 * @param enabled Indicates slot switch status. 624 * @return Returns set channel switch result. 625 */ 626 virtual ErrCode SetDistributedEnabledBySlot( 627 const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) = 0; 628 629 /** 630 * @brief Query the channel switch for collaborative reminders. 631 The caller must have system permissions to call this method. 632 * 633 * @param slotType Indicates the slot type of the application. 634 * @param deviceType Indicates the type of the device running the application. 635 * @param enabled Indicates slot switch status. 636 * @return Returns channel switch result. 637 */ 638 virtual ErrCode IsDistributedEnabledBySlot( 639 const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) = 0; 640 641 /** 642 * @brief Sets distributed notification enabled or disabled. 643 * 644 * @param enabled Indicates the enabled flag. 645 * @return Returns ERR_OK on success, others on failure. 646 */ 647 virtual ErrCode EnableDistributed(bool enabled) = 0; 648 649 /** 650 * @brief Sets distributed notification enabled or disabled for specific bundle. 651 * 652 * @param bundleOption Indicates the NotificationBundleOption object. 653 * @param enabled Indicates the enabled flag. 654 * @return Returns ERR_OK on success, others on failure. 655 */ 656 virtual ErrCode EnableDistributedByBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0; 657 658 /** 659 * @brief Sets distributed notification enabled or disabled for current bundle. 660 * 661 * @param enabled Indicates the enabled flag. 662 * @return Returns ERR_OK on success, others on failure. 663 */ 664 virtual ErrCode EnableDistributedSelf(bool enabled) = 0; 665 666 /** 667 * @brief Gets whether distributed notification is enabled for specific bundle. 668 * 669 * @param bundleOption Indicates the NotificationBundleOption object. 670 * @param enabled Indicates the enabled flag. 671 * @return Returns ERR_OK on success, others on failure. 672 */ 673 virtual ErrCode IsDistributedEnableByBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled) = 0; 674 675 /** 676 * @brief Get the reminder type of the current device. 677 * 678 * @param remindType Reminder type for the device. 679 * @return Returns ERR_OK on success, others on failure. 680 */ 681 virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) = 0; 682 683 /** 684 * @brief Publishes a continuous notification. 685 * 686 * @param request Notification requests that need to be posted. 687 * @return Returns ERR_OK on success, others on failure. 688 */ 689 virtual ErrCode PublishContinuousTaskNotification(const sptr<NotificationRequest> &request) = 0; 690 691 /** 692 * @brief Cancels a continuous notification. 693 * 694 * @param label Identifies the label of the specified notification. 695 * @param notificationId Identifies the id of the specified notification. 696 * @return Returns ERR_OK on success, others on failure. 697 */ 698 virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) = 0; 699 700 /** 701 * @brief Checks whether this device is support template. 702 * 703 * @param templateName Identifies the template name for searching as a condition. 704 * @param support Identifies the support flag. 705 * @return Returns ERR_OK on success, others on failure. 706 */ 707 virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) = 0; 708 709 /** 710 * @brief Checks Whether the specified users is allowed to publish notifications. 711 * 712 * @param userId Identifies the user's id. 713 * @param allowed Identifies the allowed flag. 714 * @return Returns ERR_OK on success, others on failure. 715 */ 716 virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) = 0; 717 718 /** 719 * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must 720 * have system permissions to call this method. 721 * 722 * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only 723 * be null or an empty string, indicating the current device. 724 * @param enabled Specifies whether to allow all applications to publish notifications. The value true 725 * indicates that notifications are allowed, and the value false indicates that notifications 726 * are not allowed. 727 * @return Returns ERR_OK on success, others on failure. 728 */ 729 virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) = 0; 730 731 /** 732 * @brief Delete all notifications by user. 733 * 734 * @param userId Indicates the user id. 735 * @return Returns ERR_OK on success, others on failure. 736 */ 737 virtual ErrCode DeleteAllByUser(const int32_t &userId) = 0; 738 739 /** 740 * @brief Set do not disturb date by user. 741 * 742 * @param userId Indicates the user id. 743 * @param date Indicates NotificationDoNotDisturbDate object. 744 * @return Returns ERR_OK on success, others on failure. 745 */ 746 virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr<NotificationDoNotDisturbDate> &date) = 0; 747 748 /** 749 * @brief Get the do not disturb date by user. 750 * 751 * @param userId Indicates the user id. 752 * @param date Indicates the NotificationDoNotDisturbDate object. 753 * @return Returns ERR_OK on success, others on failure. 754 */ 755 virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr<NotificationDoNotDisturbDate> &date) = 0; 756 virtual ErrCode SetEnabledForBundleSlot(const sptr<NotificationBundleOption> &bundleOption, 757 const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) = 0; 758 virtual ErrCode GetEnabledForBundleSlot(const sptr<NotificationBundleOption> &bundleOption, 759 const NotificationConstant::SlotType &slotType, bool &enabled) = 0; 760 virtual ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) = 0; 761 762 /** 763 * @brief Obtains specific datas via specified dump option. 764 * 765 * @param cmd Indicates the specified dump command. 766 * @param bundle Indicates the specified bundle name. 767 * @param userId Indicates the specified userId. 768 * @param recvUserId Indicates the specified receiver UserId 769 * @param dumpInfo Indicates the container containing datas. 770 * @return Returns check result. 771 */ 772 virtual ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, 773 std::vector<std::string> &dumpInfo) = 0; 774 775 /** 776 * @brief Set whether to sync notifications to devices that do not have the app installed. 777 * 778 * @param userId Indicates the specific user. 779 * @param enabled Allow or disallow sync notifications. 780 * @return Returns set enabled result. 781 */ 782 virtual ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) = 0; 783 784 /** 785 * @brief Obtains whether to sync notifications to devices that do not have the app installed. 786 * 787 * @param userId Indicates the specific user. 788 * @param enabled Allow or disallow sync notifications. 789 * @return Returns get enabled result. 790 */ 791 virtual ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) = 0; 792 793 /** 794 * @brief Set badge number. 795 * 796 * @param badgeNumber The badge number. 797 * @return Returns set badge number result. 798 */ 799 virtual ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) = 0; 800 801 /** 802 * @brief Set badge number by bundle. 803 * 804 * @param bundleOption Indicates the bundle name and uid of the application. 805 * @param badgeNumber The badge number. 806 * @return Returns set badge number by bundle result. 807 */ 808 virtual ErrCode SetBadgeNumberByBundle(const sptr<NotificationBundleOption> &bundleOption, int32_t badgeNumber) = 0; 809 810 /** 811 * @brief Set badge number for dh by bundle. 812 * 813 * @param bundleOption Indicates the bundle name and uid of the application. 814 * @param badgeNumber The badge number. 815 * @return Returns set badge number by bundle result. 816 */ 817 virtual ErrCode SetBadgeNumberForDhByBundle( 818 const sptr<NotificationBundleOption> &bundleOption, int32_t badgeNumber) = 0; 819 820 /** 821 * @brief Obtains the number of slotFlags. 822 * 823 * @param bundleOption Indicates the bundle name and uid of the application. 824 * @param slot Indicates the specified slot object 825 * @param slotFlags Indicates the slogFlags of slot. 826 * @return Returns ERR_OK on success, others on failure. 827 */ 828 virtual ErrCode GetSlotFlagsAsBundle(const sptr<NotificationBundleOption>& bundleOption, uint32_t &slotFlags) = 0; 829 830 /** 831 * @brief Set the slotFlags of slot. 832 * 833 * @param bundleOption Indicates the bundle name and uid of the application. 834 * @param slot Indicates the specified slot object 835 * @param slotFlags Indicates the slogFlags of slot to set. 836 * @return Returns ERR_OK on success, others on failure. 837 */ 838 virtual ErrCode SetSlotFlagsAsBundle(const sptr<NotificationBundleOption>& bundleOption, uint32_t slotFlags) = 0; 839 840 /** 841 * @brief Obtains allow notification application list. 842 * 843 * @param bundleOption Indicates the bundle bundleOption. 844 * @return Returns ERR_OK on success, others on failure. 845 */ 846 virtual ErrCode GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> &bundleOption) = 0; 847 848 /** 849 * @brief Obtains allow liveview application list. 850 * 851 * @param bundleOption Indicates the bundle bundleOption. 852 * @return Returns ERR_OK on success, others on failure. 853 */ 854 virtual ErrCode GetAllLiveViewEnabledBundles(std::vector<NotificationBundleOption> &bundleOption) = 0; 855 856 /** 857 * @brief Obtains allow distributed application list. 858 * 859 * @param deviceType Indicates device type. 860 * @param bundleOption Indicates the bundle bundleOption. 861 * @return Returns ERR_OK on success, others on failure. 862 */ 863 virtual ErrCode GetAllDistribuedEnabledBundles(const std::string& deviceType, 864 std::vector<NotificationBundleOption> &bundleOption) = 0; 865 866 /** 867 * @brief Register Push Callback. 868 * 869 * @param pushCallback PushCallBack. 870 * @return Returns register PushCallback result. 871 */ 872 virtual ErrCode RegisterPushCallback( 873 const sptr<IRemoteObject> &pushCallback, const sptr<NotificationCheckRequest> ¬ificationCheckRequest) = 0; 874 875 /** 876 * @brief Unregister Push Callback. 877 * 878 * @return Returns unregister push Callback result. 879 */ 880 virtual ErrCode UnregisterPushCallback() = 0; 881 882 /** 883 * @brief Set agent relationship. 884 * 885 * @param key Indicates storing agent relationship if the value is "PROXY_PKG". 886 * @param value Indicates key-value pair of agent relationship. 887 * @return Returns set result. 888 */ 889 virtual ErrCode SetAdditionConfig(const std::string &key, const std::string &value) = 0; 890 891 /** 892 * @brief Sets whether to allow a specified application to publish notifications cross 893 * device collaboration. The caller must have system permissions to call this method. 894 * 895 * @param bundleOption Indicates the bundle name and uid of the application. 896 * @param deviceType Indicates the type of the device running the application. 897 * @param enabled Specifies whether to allow the given application to publish notifications. 898 * The value true indicates that notifications are allowed, and the value 899 * false indicates that notifications are not allowed. 900 * @return Returns set notifications enabled for specified bundle result. 901 */ 902 virtual ErrCode SetDistributedEnabledByBundle( 903 const sptr<NotificationBundleOption> &bundleOption, const std::string &deviceType, const bool enabled) = 0; 904 905 /** 906 * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders 907 * 908 * @param deviceType Indicates the type of the device running the application. 909 * @param enabled Specifies whether to allow the given device to publish notifications. 910 * The value true indicates that notifications are allowed, and the value 911 * false indicates that notifications are not allowed. 912 * @return Returns set notifications enabled for specified bundle result. 913 */ 914 virtual ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) = 0; 915 916 /** 917 * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders 918 * 919 * @param deviceType Indicates the type of the device running the application. 920 * @param enabled Specifies whether to allow the given device to publish notifications. 921 * The value true indicates that notifications are allowed, and the value 922 * false indicates that notifications are not allowed. 923 * @return Returns set notifications enabled for specified bundle result. 924 */ 925 virtual ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) = 0; 926 927 /** 928 * @brief get whether to allow a specified application to publish notifications cross 929 * device collaboration. The caller must have system permissions to call this method. 930 * 931 * @param bundleOption Indicates the bundle name and uid of the application. 932 * @param deviceType Indicates the type of the device running the application. 933 * @param enabled Specifies whether to allow the given application to publish notifications. 934 * The value true indicates that notifications are allowed, and the value 935 * false indicates that notifications are not allowed. 936 * @return Returns set notifications enabled for specified bundle result. 937 */ 938 virtual ErrCode IsDistributedEnabledByBundle( 939 const sptr<NotificationBundleOption> &bundleOption, const std::string &deviceType, bool &enabled) = 0; 940 941 /** 942 * @brief Cancels a published agent notification. 943 * 944 * @param bundleOption Indicates the bundle name and uid of the application. 945 * @param id Indicates the unique notification ID in the application. 946 * @return Returns cancel result. 947 */ 948 virtual ErrCode CancelAsBundleWithAgent(const sptr<NotificationBundleOption> &bundleOption, const int32_t id) = 0; 949 950 /** 951 * @brief Set the status of the target device. 952 * 953 * @param deviceType Type of the device whose status you want to set. 954 * @param status The status. 955 * @return Returns set result. 956 */ 957 virtual ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status) = 0; 958 959 /** 960 * @brief Set the status of the target device. 961 * 962 * @param deviceType Type of the device whose status you want to set. 963 * @param status The status. 964 * @param controlFlag The control flag. 965 * @return Returns set result. 966 */ 967 virtual ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, 968 const uint32_t controlFlag) = 0; 969 970 /** 971 * @brief Get do not disturb profile by id. 972 * 973 * @param id Profile id. 974 * @param status Indicates the NotificationDoNotDisturbProfile objects. 975 * @return Returns ERR_OK on success, others on failure. 976 */ 977 virtual ErrCode GetDoNotDisturbProfile(int32_t id, sptr<NotificationDoNotDisturbProfile> &profile) = 0; 978 979 /** 980 * @brief Whether reminders are allowed. 981 * 982 * @param bundleName app bundleName 983 * @param isAllowUseReminder is allow use reminder 984 * @return Returns ERR_OK on success, others on failure. 985 */ 986 virtual ErrCode AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) = 0; 987 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 988 /** 989 * @brief Register Swing Callback. 990 * 991 * @param swingCallback SwingCallBack. 992 * @return Returns register SwingCallback result. 993 */ 994 virtual ErrCode RegisterSwingCallback(const sptr<IRemoteObject>& swingCallback) = 0; 995 #endif 996 997 /** 998 * @brief Update Notification Timer by uid. 999 * 1000 * @param uid uid. 1001 * @return Returns Update result. 1002 */ 1003 virtual ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) = 0; 1004 1005 /** 1006 * @brief Set switch and bundle list of disable notification feature. 1007 * 1008 * @param notificationDisable Switch and bundle list of disable notification feature. 1009 * @return Returns set result. 1010 */ 1011 virtual ErrCode DisableNotificationFeature(const sptr<NotificationDisable> ¬ificationDisable) = 0; 1012 1013 /** 1014 * @brief Get the status of the target device. 1015 * 1016 * @param deviceType Type of the device whose status you want to set. 1017 * @param status The status. 1018 * @return Returns set result. 1019 */ 1020 virtual ErrCode GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) = 0; 1021 1022 /** 1023 * @brief Distribution operation based on hashCode. 1024 * 1025 * @param hashCode Unique ID of the notification. 1026 * @return Returns ERR_OK on success, others on failure. 1027 */ 1028 virtual ErrCode DistributeOperation(sptr<NotificationOperationInfo>& operationInfo, 1029 const sptr<OperationCallbackInterface> &callback) = 0; 1030 1031 /** 1032 * @brief Reply distribute operation. 1033 * 1034 * @param hashCode Unique ID of the notification. 1035 * @param result The result of the distribute operation. 1036 * @return Returns ERR_OK on success, others on failure. 1037 */ 1038 virtual ErrCode ReplyDistributeOperation(const std::string& hashCode, const int32_t result) = 0; 1039 1040 /** 1041 * @brief Get notificationRequest by hashCode. 1042 * 1043 * @param hashCode Unique ID of the notification. 1044 * @param notificationRequest The request of of the notification. 1045 * @return Returns ERR_OK on success, others on failure. 1046 */ 1047 virtual ErrCode GetNotificationRequestByHashCode( 1048 const std::string& hashCode, sptr<NotificationRequest>& notificationRequest) = 0; 1049 1050 /** 1051 * @brief set rule of generate hashCode. 1052 * 1053 * @param type generate hashCode. 1054 * @return Returns ERR_OK on success, others on failure. 1055 */ 1056 virtual ErrCode SetHashCodeRule(const uint32_t type) = 0; 1057 }; 1058 } // namespace Notification 1059 } // namespace OHOS 1060 1061 #endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H 1062