diff --git a/frameworks/ans/src/notification_helper.cpp b/frameworks/ans/src/notification_helper.cpp index 0277e776700f5472022092366e5160c1d8fc2ba2..34dce1c8468455a29cafd62e9ad9d8e274401559 100644 --- a/frameworks/ans/src/notification_helper.cpp +++ b/frameworks/ans/src/notification_helper.cpp @@ -74,14 +74,14 @@ ErrCode NotificationHelper::SetNotificationSlotFlagsAsBundle(const NotificationB } ErrCode NotificationHelper::PublishNotification(const NotificationRequest &request, - std::string instanceKey) + const std::string &instanceKey) { return DelayedSingleton::GetInstance()->PublishNotification( request, instanceKey); } ErrCode NotificationHelper::PublishNotification(const std::string &label, - const NotificationRequest &request, std::string instanceKey) + const NotificationRequest &request, const std::string &instanceKey) { return DelayedSingleton::GetInstance()->PublishNotification( label, request, instanceKey); @@ -92,20 +92,20 @@ ErrCode NotificationHelper::PublishNotificationForIndirectProxy(const Notificati return DelayedSingleton::GetInstance()->PublishNotificationForIndirectProxy(request); } -ErrCode NotificationHelper::CancelNotification(int32_t notificationId, std::string instanceKey) +ErrCode NotificationHelper::CancelNotification(int32_t notificationId, const std::string &instanceKey) { return DelayedSingleton::GetInstance()->CancelNotification( notificationId, instanceKey); } ErrCode NotificationHelper::CancelNotification(const std::string &label, int32_t notificationId, - std::string instanceKey) + const std::string &instanceKey) { return DelayedSingleton::GetInstance()->CancelNotification( label, notificationId, instanceKey); } -ErrCode NotificationHelper::CancelAllNotifications(std::string instanceKey) +ErrCode NotificationHelper::CancelAllNotifications(const std::string &instanceKey) { return DelayedSingleton::GetInstance()->CancelAllNotifications(instanceKey); } @@ -130,7 +130,7 @@ ErrCode NotificationHelper::GetActiveNotificationNums(uint64_t &num) } ErrCode NotificationHelper::GetActiveNotifications( - std::vector> &request, std::string instanceKey) + std::vector> &request, const std::string &instanceKey) { return DelayedSingleton::GetInstance()->GetActiveNotifications( request, instanceKey); @@ -382,7 +382,7 @@ ErrCode NotificationHelper::GetShowBadgeEnabled(bool &enabled) return DelayedSingleton::GetInstance()->GetShowBadgeEnabled(enabled); } -ErrCode NotificationHelper::CancelGroup(const std::string &groupName, std::string instanceKey) +ErrCode NotificationHelper::CancelGroup(const std::string &groupName, const std::string &instanceKey) { return DelayedSingleton::GetInstance()->CancelGroup( groupName, instanceKey); @@ -527,7 +527,7 @@ ErrCode NotificationHelper::GetSyncNotificationEnabledWithoutApp(const int32_t u userId, enabled); } -ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber, std::string instanceKey) +ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) { return DelayedSingleton::GetInstance()->SetBadgeNumber(badgeNumber, instanceKey); } diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index 10d86a05afa49c51994793d2274b6e5b456c0cf0..1685a8d036536fca3ecabcb9e1a17b38979617af 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -134,7 +134,7 @@ public: * This parameter must be specified. * @return Returns publish notification result. */ - ErrCode PublishNotification(const NotificationRequest &request, std::string instanceKey = ""); + ErrCode PublishNotification(const NotificationRequest &request, const std::string &instanceKey = ""); /** * @brief Publishes a notification with a specified label. @@ -147,7 +147,7 @@ public: * @return Returns publish notification result. */ ErrCode PublishNotification(const std::string &label, const NotificationRequest &request, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Publishes a notification. @@ -168,7 +168,7 @@ public: * Otherwise, this method does not take effect. * @return Returns cancel notification result. */ - ErrCode CancelNotification(int32_t notificationId, std::string instanceKey = ""); + ErrCode CancelNotification(int32_t notificationId, const std::string &instanceKey = ""); /** * @brief Cancels a published notification matching the specified label and notificationId. @@ -178,7 +178,7 @@ public: * @return Returns cancel notification result. */ ErrCode CancelNotification(const std::string &label, int32_t notificationId, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Cancels all the published notifications. @@ -186,7 +186,7 @@ public: * * @return Returns cancel all notifications result. */ - ErrCode CancelAllNotifications(std::string instanceKey = ""); + ErrCode CancelAllNotifications(const std::string &instanceKey = ""); /** * @brief Cancels a published agent notification. @@ -226,7 +226,7 @@ public: * @return Returns get active notifications result. */ ErrCode GetActiveNotifications(std::vector> &request, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Checks whether your application has permission to publish notifications by calling @@ -734,7 +734,7 @@ public: * @param groupName the specified group name. * @return Returns cancel group result. */ - ErrCode CancelGroup(const std::string &groupName, std::string instanceKey = ""); + ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey = ""); /** * @brief Removes the notification of the specified group of the specified application. @@ -1010,7 +1010,7 @@ public: * @param badgeNumber The badge number. * @return Returns set badge number result. */ - ErrCode SetBadgeNumber(int32_t badgeNumber, std::string instanceKey = ""); + ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey = ""); /** * @brief Set badge number by bundle. @@ -1324,7 +1324,6 @@ private: bool IsValidDelayTime(const NotificationRequest &request) const; void CreateSubscribeListener(const std::shared_ptr &subscriber, sptr &listener); - std::string GetAppInstanceKey() const; private: std::mutex subscriberMutex_; diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 10024f68205b82b6d8504fef932847dea39d7765..ec0355a05fdfb7424bfc7deab68120da170db5ff 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -207,14 +207,14 @@ ErrCode AnsNotification::SetNotificationSlotFlagsAsBundle(const NotificationBund return proxy->SetSlotFlagsAsBundle(bo, validSlotFlag); } -ErrCode AnsNotification::PublishNotification(const NotificationRequest &request, std::string instanceKey) +ErrCode AnsNotification::PublishNotification(const NotificationRequest &request, const std::string &instanceKey) { ANS_LOGD("enter"); return PublishNotification(std::string(), request, instanceKey); } ErrCode AnsNotification::PublishNotification(const std::string &label, const NotificationRequest &request, - std::string instanceKey) + const std::string &instanceKey) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); ANS_LOGI("PublishNotification,notificationId:%{public}u", request.GetNotificationId()); @@ -317,13 +317,13 @@ ErrCode AnsNotification::PublishNotificationForIndirectProxy(const NotificationR return proxy->PublishNotificationForIndirectProxy(reqPtr); } -ErrCode AnsNotification::CancelNotification(int32_t notificationId, std::string instanceKey) +ErrCode AnsNotification::CancelNotification(int32_t notificationId, const std::string &instanceKey) { return CancelNotification("", notificationId, instanceKey); } ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t notificationId, - std::string instanceKey) + const std::string &instanceKey) { ANS_LOGI("enter CancelNotification,notificationId:%{public}d", notificationId); HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); @@ -335,7 +335,7 @@ ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t no return proxy->Cancel(notificationId, label, instanceKey); } -ErrCode AnsNotification::CancelAllNotifications(std::string instanceKey) +ErrCode AnsNotification::CancelAllNotifications(const std::string &instanceKey) { ANS_LOGI("CancelAllNotifications called."); @@ -383,7 +383,7 @@ ErrCode AnsNotification::GetActiveNotificationNums(uint64_t &num) } ErrCode AnsNotification::GetActiveNotifications(std::vector> &request, - std::string instanceKey) + const std::string &instanceKey) { sptr proxy = GetAnsManagerProxy(); if (!proxy) { @@ -1194,7 +1194,7 @@ ErrCode AnsNotification::GetShowBadgeEnabled(bool &enabled) return proxy->GetShowBadgeEnabled(enabled); } -ErrCode AnsNotification::CancelGroup(const std::string &groupName, std::string instanceKey) +ErrCode AnsNotification::CancelGroup(const std::string &groupName, const std::string &instanceKey) { ANS_LOGI("enter CancelGroup,groupName:%{public}s", groupName.c_str()); if (groupName.empty()) { @@ -1850,7 +1850,7 @@ ErrCode AnsNotification::GetSyncNotificationEnabledWithoutApp(const int32_t user return proxy->GetSyncNotificationEnabledWithoutApp(userId, enabled); } -ErrCode AnsNotification::SetBadgeNumber(int32_t badgeNumber, std::string instanceKey) +ErrCode AnsNotification::SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) { sptr proxy = GetAnsManagerProxy(); if (!proxy) { @@ -2225,11 +2225,6 @@ ErrCode AnsNotification::UpdateNotificationTimerByUid(const int32_t uid, const b return proxy->UpdateNotificationTimerByUid(uid, isPaused); } -std::string AnsNotification::GetAppInstanceKey() const -{ - return ""; -} - ErrCode AnsNotification::DisableNotificationFeature(const NotificationDisable ¬ificationDisable) { ANS_LOGD("enter DisableNotificationFeature"); diff --git a/interfaces/inner_api/notification_helper.h b/interfaces/inner_api/notification_helper.h index 0ba6ff992bfe3283d5085ef5044cf6ab012e1cdc..fc9bd295b3191c08770a0892a95e1bb38da51671 100644 --- a/interfaces/inner_api/notification_helper.h +++ b/interfaces/inner_api/notification_helper.h @@ -201,7 +201,7 @@ public: * @return Returns publish notification result. */ static ErrCode PublishNotification(const NotificationRequest &request, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Publishes a notification. @@ -225,7 +225,7 @@ public: * @return Returns publish notification result. */ static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Cancels a published notification. @@ -235,7 +235,7 @@ public: * Otherwise, this method does not take effect. * @return Returns cancel notification result. */ - static ErrCode CancelNotification(int32_t notificationId, std::string instanceKey = ""); + static ErrCode CancelNotification(int32_t notificationId, const std::string &instanceKey = ""); /** * @brief Cancels a published notification matching the specified label and notificationId. @@ -245,7 +245,7 @@ public: * @return Returns cancel notification result. */ static ErrCode CancelNotification(const std::string &label, int32_t notificationId, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Cancels all the published notifications. @@ -253,7 +253,7 @@ public: * @note To cancel a specified notification, see CancelNotification(int32_t). * @return Returns cancel all notifications result. */ - static ErrCode CancelAllNotifications(std::string instanceKey = ""); + static ErrCode CancelAllNotifications(const std::string &instanceKey = ""); /** * @brief Cancels a published agent notification. @@ -293,7 +293,7 @@ public: * @return Returns get active notifications result. */ static ErrCode GetActiveNotifications(std::vector> &request, - std::string instanceKey = ""); + const std::string &instanceKey = ""); /** * @brief Checks whether your application has permission to publish notifications by calling @@ -775,7 +775,7 @@ public: * @param groupName Indicates the specified group name. * @return Returns cancel group result. */ - static ErrCode CancelGroup(const std::string &groupName, std::string instanceKey = ""); + static ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey = ""); /** * @brief Remove the notification of the specified group of the specified application. @@ -996,7 +996,7 @@ public: * @param badgeNumber The badge number. * @return Returns set badge number result. */ - static ErrCode SetBadgeNumber(int32_t badgeNumber, std::string instanceKey = ""); + static ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey = ""); /** * @brief Set badge number by bundle.