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