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