From cf20afae88ace34c8099d9359e0034884b67cf42 Mon Sep 17 00:00:00 2001 From: zhengzhuolan Date: Wed, 11 Jun 2025 15:55:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E9=80=9A=E7=9F=A5Trace?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhengzhuolan --- ...otification_local_live_view_subscriber.cpp | 8 ++-- .../ans/src/notification_subscriber.cpp | 22 +++++---- .../core/common/include/ans_log_wrapper.h | 3 ++ frameworks/core/src/ans_notification.cpp | 47 ++++++++++--------- .../src/listener/ans_subscriber_listener.cpp | 24 +++++----- .../advanced_notification_cancel.cpp | 10 ++-- .../advanced_notification_publish.cpp | 5 +- .../advanced_notification_publish_service.cpp | 3 +- .../ans/src/advanced_notification_service.cpp | 7 +-- .../advanced_notification_slot_service.cpp | 5 +- ...vanced_notification_subscriber_service.cpp | 7 +-- .../ans/src/advanced_notification_utils.cpp | 4 +- .../ans/src/enable_manager/enable_manager.cpp | 3 +- ...ion_local_live_view_subscriber_manager.cpp | 13 ++--- services/ans/src/notification_preferences.cpp | 7 +-- .../src/notification_preferences_database.cpp | 6 +-- .../src/notification_subscriber_manager.cpp | 35 +++++++------- ..._notification_system_live_view_service.cpp | 5 +- .../src/distributed_notification_manager.cpp | 8 ++-- .../reminder/src/reminder_agent_service.cpp | 18 +++---- .../reminder/src/reminder_data_manager.cpp | 15 +++--- .../src/reminder_data_manager_inner.cpp | 3 +- services/reminder/test/unittest/BUILD.gn | 1 + 23 files changed, 142 insertions(+), 117 deletions(-) diff --git a/frameworks/ans/src/notification_local_live_view_subscriber.cpp b/frameworks/ans/src/notification_local_live_view_subscriber.cpp index cd110f22e..52209fb24 100644 --- a/frameworks/ans/src/notification_local_live_view_subscriber.cpp +++ b/frameworks/ans/src/notification_local_live_view_subscriber.cpp @@ -15,7 +15,9 @@ #include "notification_local_live_view_subscriber.h" +#include "ans_log_wrapper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -42,7 +44,7 @@ NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::SubscriberLoca ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConnected() { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->AddDeathRecipient(recipient_); @@ -54,7 +56,7 @@ ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConn ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnDisconnected() { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->RemoveDeathRecipient(recipient_); @@ -67,7 +69,7 @@ ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnDisc ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnResponse(int32_t notificationId, const sptr &buttonOption) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); subscriber_.OnResponse(notificationId, buttonOption); return ERR_OK; } diff --git a/frameworks/ans/src/notification_subscriber.cpp b/frameworks/ans/src/notification_subscriber.cpp index f789cf1ec..54ca22b86 100644 --- a/frameworks/ans/src/notification_subscriber.cpp +++ b/frameworks/ans/src/notification_subscriber.cpp @@ -15,8 +15,10 @@ #include "notification_subscriber.h" +#include "ans_log_wrapper.h" #include "notification_constant.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -134,7 +136,7 @@ NotificationSubscriber::SubscriberImpl::SubscriberImpl(NotificationSubscriber &s ErrCode NotificationSubscriber::SubscriberImpl::OnConnected() { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->AddDeathRecipient(recipient_); @@ -146,7 +148,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnConnected() ErrCode NotificationSubscriber::SubscriberImpl::OnDisconnected() { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->RemoveDeathRecipient(recipient_); @@ -159,7 +161,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnDisconnected() ErrCode NotificationSubscriber::SubscriberImpl::OnConsumed( const sptr ¬ification, const sptr ¬ificationMap) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); std::shared_ptr sharedNotification = std::make_shared(*notification); #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED if (!subscriber_.ProcessSyncDecision(subscriber_.GetDeviceType(), sharedNotification)) { @@ -191,7 +193,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnConsumedWithMaxCapacity(const ErrCode NotificationSubscriber::SubscriberImpl::OnConsumedList(const std::vector> ¬ifications, const sptr ¬ificationMap) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); for (auto notification : notifications) { OnConsumed(notification, notificationMap); } @@ -206,7 +208,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnConsumedList(const std::vector ErrCode NotificationSubscriber::SubscriberImpl::OnCanceled( const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationMap == nullptr) { subscriber_.OnCanceled(std::make_shared(*notification), std::make_shared(), deleteReason); @@ -255,7 +257,7 @@ void NotificationSubscriber::SubscriberImpl::OnBatchCanceled(const std::vector> ¬ifications, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber_.HasOnBatchCancelCallback()) { OnBatchCanceled(notifications, notificationMap, deleteReason); return ERR_OK; @@ -287,14 +289,14 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnDoNotDisturbDateChange(const s ErrCode NotificationSubscriber::SubscriberImpl::OnEnabledNotificationChanged( const sptr &callbackData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); subscriber_.OnEnabledNotificationChanged(std::make_shared(*callbackData)); return ERR_OK; } ErrCode NotificationSubscriber::SubscriberImpl::OnBadgeChanged(const sptr &badgeData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); subscriber_.OnBadgeChanged(std::make_shared(*badgeData)); return ERR_OK; } @@ -302,7 +304,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnBadgeChanged(const sptr &callbackData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); subscriber_.OnBadgeEnabledChanged(callbackData); return ERR_OK; } @@ -310,7 +312,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnBadgeEnabledChanged( ErrCode NotificationSubscriber::SubscriberImpl::OnApplicationInfoNeedChanged( const std::string& bundleName) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); subscriber_.OnApplicationInfoNeedChanged(bundleName); return ERR_OK; } diff --git a/frameworks/core/common/include/ans_log_wrapper.h b/frameworks/core/common/include/ans_log_wrapper.h index b2492b376..32830f406 100644 --- a/frameworks/core/common/include/ans_log_wrapper.h +++ b/frameworks/core/common/include/ans_log_wrapper.h @@ -38,6 +38,9 @@ namespace Notification { #define ANS_LOG_LIMIT_INTERVALS 10000 //ms +#define NOTIFICATION_HITRACE(tag) \ + HITRACE_METER_NAME_EX(HiTraceOutputLevel::HITRACE_LEVEL_INFO, tag, __PRETTY_FUNCTION__, "") + #define CUR_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) #define ANS_LOGF(fmt, ...) \ diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index fc132733f..74bec0627 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -20,6 +20,7 @@ #include "ans_manager_death_recipient.h" #include "ans_manager_proxy.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "iservice_registry.h" #include "notification_button_option.h" @@ -227,7 +228,7 @@ ErrCode AnsNotification::PublishNotification(const NotificationRequest &request, ErrCode AnsNotification::PublishNotification(const std::string &label, const NotificationRequest &request, const std::string &instanceKey) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGI("PublishNotification,notificationId:%{public}u", request.GetNotificationId()); if (request.GetContent() == nullptr || request.GetNotificationType() == NotificationContent::Type::NONE) { @@ -279,7 +280,7 @@ ErrCode AnsNotification::PublishNotification(const std::string &label, const Not ErrCode AnsNotification::PublishNotificationForIndirectProxy(const NotificationRequest &request) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGI("PublishNotificationForIndirectProxy,notificationId:%{public}u", request.GetNotificationId()); if (request.GetContent() == nullptr || request.GetNotificationType() == NotificationContent::Type::NONE) { @@ -337,7 +338,7 @@ ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t no const std::string &instanceKey) { ANS_LOGI("enter CancelNotification,notificationId:%{public}d", notificationId); - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -596,7 +597,7 @@ ErrCode AnsNotification::GetBundleImportance(NotificationSlot::NotificationLevel ErrCode AnsNotification::SubscribeNotification(const NotificationSubscriber &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -613,7 +614,7 @@ ErrCode AnsNotification::SubscribeNotification(const NotificationSubscriber &sub ErrCode AnsNotification::SubscribeNotificationSelf(const NotificationSubscriber &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -631,7 +632,7 @@ ErrCode AnsNotification::SubscribeNotificationSelf(const NotificationSubscriber ErrCode AnsNotification::SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber, const bool isNative) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -649,7 +650,7 @@ ErrCode AnsNotification::SubscribeLocalLiveViewNotification(const NotificationLo ErrCode AnsNotification::SubscribeNotification( const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Failed to GetAnsManagerProxy."); @@ -675,7 +676,7 @@ ErrCode AnsNotification::SubscribeNotification( ErrCode AnsNotification::UnSubscribeNotification(NotificationSubscriber &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -693,7 +694,7 @@ ErrCode AnsNotification::UnSubscribeNotification(NotificationSubscriber &subscri ErrCode AnsNotification::UnSubscribeNotification( NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -716,13 +717,13 @@ ErrCode AnsNotification::UnSubscribeNotification( ErrCode AnsNotification::SubscribeNotification(const std::shared_ptr &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); return SubscribeNotification(subscriber, nullptr); } ErrCode AnsNotification::SubscribeNotificationSelf(const std::shared_ptr &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr."); return ERR_ANS_INVALID_PARAM; @@ -747,7 +748,7 @@ ErrCode AnsNotification::SubscribeNotificationSelf(const std::shared_ptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr."); return ERR_ANS_INVALID_PARAM; @@ -778,14 +779,14 @@ ErrCode AnsNotification::SubscribeNotification(const std::shared_ptr &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); return UnSubscribeNotification(subscriber, nullptr); } ErrCode AnsNotification::UnSubscribeNotification(const std::shared_ptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr."); return ERR_ANS_INVALID_PARAM; @@ -818,7 +819,7 @@ ErrCode AnsNotification::UnSubscribeNotification(const std::shared_ptr& operationInfo, const sptr &callback) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (operationInfo == nullptr || callback == nullptr) { ANS_LOGE("Input hashCode is empty."); return ERR_ANS_INVALID_PARAM; @@ -2375,7 +2376,7 @@ ErrCode AnsNotification::DistributeOperation(sptr& op ErrCode AnsNotification::ReplyDistributeOperation(const std::string& hashCode, const int32_t result) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { @@ -2389,7 +2390,7 @@ ErrCode AnsNotification::GetNotificationRequestByHashCode( const std::string& hashCode, sptr& notificationRequest) { ANS_LOGI("Get notification request by hashCode, hashCode:%{public}s", hashCode.c_str()); - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { @@ -2403,7 +2404,7 @@ ErrCode AnsNotification::SetHashCodeRule( const uint32_t type) { ANS_LOGI("SetHashCodeRule type = %{public}d", type); - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); sptr proxy = GetAnsManagerProxy(); if (!proxy) { diff --git a/frameworks/core/src/listener/ans_subscriber_listener.cpp b/frameworks/core/src/listener/ans_subscriber_listener.cpp index 2ee4e4e36..a76ca72b2 100644 --- a/frameworks/core/src/listener/ans_subscriber_listener.cpp +++ b/frameworks/core/src/listener/ans_subscriber_listener.cpp @@ -13,9 +13,11 @@ * limitations under the License. */ +#include "ans_log_wrapper.h" #include "ans_subscriber_listener.h" #include "notification_constant.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -30,7 +32,7 @@ SubscriberListener::~SubscriberListener() ErrCode SubscriberListener::OnConnected() { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -42,7 +44,7 @@ ErrCode SubscriberListener::OnConnected() ErrCode SubscriberListener::OnDisconnected() { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -55,7 +57,7 @@ ErrCode SubscriberListener::OnDisconnected() ErrCode SubscriberListener::OnConsumed( const sptr ¬ification, const sptr ¬ificationMap) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -94,7 +96,7 @@ ErrCode SubscriberListener::OnConsumedWithMaxCapacity(const sptr & ErrCode SubscriberListener::OnConsumedList(const std::vector> ¬ifications, const sptr ¬ificationMap) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); for (auto notification : notifications) { OnConsumed(notification, notificationMap); } @@ -109,7 +111,7 @@ ErrCode SubscriberListener::OnConsumedList(const std::vector> ErrCode SubscriberListener::OnCanceled( const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -165,7 +167,7 @@ void SubscriberListener::OnBatchCanceled(const std::vector> & ErrCode SubscriberListener::OnCanceledList(const std::vector> ¬ifications, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -212,7 +214,7 @@ ErrCode SubscriberListener::OnDoNotDisturbDateChange(const sptr &callbackData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -224,7 +226,7 @@ ErrCode SubscriberListener::OnEnabledNotificationChanged( ErrCode SubscriberListener::OnBadgeChanged(const sptr &badgeData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -237,7 +239,7 @@ ErrCode SubscriberListener::OnBadgeChanged(const sptr & ErrCode SubscriberListener::OnBadgeEnabledChanged( const sptr &callbackData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGE("Subscriber is nullptr"); @@ -249,7 +251,7 @@ ErrCode SubscriberListener::OnBadgeEnabledChanged( ErrCode SubscriberListener::OnApplicationInfoNeedChanged(const std::string& bundleName) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGW("OnApplicationInfoNeedChanged SubscriberListener 1."); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { @@ -263,7 +265,7 @@ ErrCode SubscriberListener::OnApplicationInfoNeedChanged(const std::string& bund ErrCode SubscriberListener::OnOperationResponse( const sptr& operationInfo, int32_t& funcResult) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { ANS_LOGW("Subscriber is nullptr"); diff --git a/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp b/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp index 9b3d35d32..92b9f1376 100644 --- a/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp +++ b/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp @@ -15,10 +15,12 @@ #include "advanced_notification_service.h" +#include "ans_log_wrapper.h" #include "access_token_helper.h" #include "ans_permission_def.h" #include "bundle_manager_helper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "notification_analytics_util.h" #include "notification_bundle_option.h" @@ -305,7 +307,7 @@ ErrCode AdvancedNotificationService::CancelContinuousTaskNotification(const std: ErrCode AdvancedNotificationService::RemoveNotification(const sptr &bundleOption, int32_t notificationId, const std::string &label, int32_t removeReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); @@ -420,7 +422,7 @@ ErrCode AdvancedNotificationService::RemoveAllNotifications(const sptr &bundleOption, int32_t reason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); @@ -540,7 +542,7 @@ void AdvancedNotificationService::GetRemoveListForRemoveAll(const sptr &keys, int32_t removeReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("enter"); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); @@ -602,7 +604,7 @@ void AdvancedNotificationService::ExcuteRemoveNotifications(const std::vector &bundleOption, const sptr &slot, const int reason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); diff --git a/services/ans/src/advanced_notification_manager/advanced_notification_publish.cpp b/services/ans/src/advanced_notification_manager/advanced_notification_publish.cpp index 6ae602d31..a42823328 100644 --- a/services/ans/src/advanced_notification_manager/advanced_notification_publish.cpp +++ b/services/ans/src/advanced_notification_manager/advanced_notification_publish.cpp @@ -25,6 +25,7 @@ #include "ans_status.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "notification_analytics_util.h" #include "os_account_manager.h" #include "os_account_manager_helper.h" @@ -47,7 +48,7 @@ ErrCode AdvancedNotificationService::PublishWithMaxCapacity( ErrCode AdvancedNotificationService::Publish(const std::string &label, const sptr &request) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); TraceChainUtil traceChain = TraceChainUtil(); OHOS::HiviewDFX::HiTraceId traceId = OHOS::HiviewDFX::HiTraceChain::GetId(); ANS_LOGD("%{public}s", __FUNCTION__); @@ -161,7 +162,7 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxyWithMaxC ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const sptr &request) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_9, EventBranchId::BRANCH_0); diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index ff2ab3399..54a62f843 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -29,6 +29,7 @@ #include "notification_bundle_option.h" #include "notification_constant.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "notification_unified_group_Info.h" #include "os_account_manager.h" #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED @@ -1136,7 +1137,7 @@ void AdvancedNotificationService::PublishSubscriberExistFlagEvent(bool headsetEx ErrCode AdvancedNotificationService::RemoveAllNotificationsByBundleName(const std::string &bundleName, int32_t reason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); if (bundleName.empty()) { diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 3be89158f..ce9552df9 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -42,6 +42,7 @@ #include "common_event_support.h" #include "event_report.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "nlohmann/json.hpp" #include "notification_constant.h" @@ -410,7 +411,7 @@ ErrCode AdvancedNotificationService::AssignToNotificationList(const std::shared_ ErrCode AdvancedNotificationService::CancelPreparedNotification(int32_t notificationId, const std::string &label, const sptr &bundleOption, int32_t reason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (bundleOption == nullptr) { std::string message = "bundleOption is null"; OHOS::Notification::HaMetaMessage haMetaMessage = HaMetaMessage(1, 2) @@ -454,7 +455,7 @@ ErrCode AdvancedNotificationService::CancelPreparedNotification(int32_t notifica ErrCode AdvancedNotificationService::PrepareNotificationInfo( const sptr &request, sptr &bundleOption) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (request == nullptr) { ANS_LOGE("request is invalid."); return ERR_ANS_INVALID_PARAM; @@ -665,7 +666,7 @@ std::shared_ptr AdvancedNotificationService::MakeNotificatio ErrCode AdvancedNotificationService::PublishPreparedNotification(const sptr &request, const sptr &bundleOption, bool isUpdateByOwner) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGI("PublishPreparedNotification"); auto tokenCaller = IPCSkeleton::GetCallingTokenID(); bool isAgentController = AccessTokenHelper::VerifyCallerPermission(tokenCaller, diff --git a/services/ans/src/advanced_notification_slot_service.cpp b/services/ans/src/advanced_notification_slot_service.cpp index 139234002..02b654512 100644 --- a/services/ans/src/advanced_notification_slot_service.cpp +++ b/services/ans/src/advanced_notification_slot_service.cpp @@ -27,6 +27,7 @@ #include "common_event_manager.h" #include "common_event_support.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "os_account_manager_helper.h" #include "ipc_skeleton.h" #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED @@ -843,7 +844,7 @@ ErrCode AdvancedNotificationService::SetEnabledForBundleSlotInner( ErrCode AdvancedNotificationService::SetEnabledForBundleSlot(const sptr &bundleOption, int32_t slotTypeInt, bool enabled, bool isForceControl) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); NotificationConstant::SlotType slotType = static_cast(slotTypeInt); ANS_LOGD("slotType: %{public}d, enabled: %{public}d, isForceControl: %{public}d", slotType, enabled, isForceControl); @@ -954,7 +955,7 @@ bool AdvancedNotificationService::PublishSlotChangeCommonEvent(const sptrGetBundleName().c_str(), bundleOption->GetUid()); EventFwk::Want want; diff --git a/services/ans/src/advanced_notification_subscriber_service.cpp b/services/ans/src/advanced_notification_subscriber_service.cpp index a10934909..d4626d9c9 100644 --- a/services/ans/src/advanced_notification_subscriber_service.cpp +++ b/services/ans/src/advanced_notification_subscriber_service.cpp @@ -29,6 +29,7 @@ #include "notification_constant.h" #include "os_account_manager_helper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED #include "distributed_notification_manager.h" #include "distributed_preferences.h" @@ -49,7 +50,7 @@ ErrCode AdvancedNotificationService::Subscribe(const sptr &subsc ErrCode AdvancedNotificationService::Subscribe( const sptr &subscriber, const sptr &info) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); ErrCode errCode = ERR_OK; do { @@ -88,7 +89,7 @@ ErrCode AdvancedNotificationService::Subscribe( ErrCode AdvancedNotificationService::SubscribeSelf(const sptr &subscriber) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); sptr sptrInfo = new (std::nothrow) NotificationSubscribeInfo(); if (sptrInfo == nullptr) { @@ -145,7 +146,7 @@ ErrCode AdvancedNotificationService::Unsubscribe(const sptr &sub ErrCode AdvancedNotificationService::Unsubscribe( const sptr &subscriber, const sptr &info) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); SendUnSubscribeHiSysEvent(IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid(), info); diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index a9faf05dd..0b90e381f 100644 --- a/services/ans/src/advanced_notification_utils.cpp +++ b/services/ans/src/advanced_notification_utils.cpp @@ -1089,7 +1089,7 @@ ErrCode AdvancedNotificationService::DoDistributedPublish( ErrCode AdvancedNotificationService::DoDistributedDelete( const std::string deviceId, const std::string bundleName, const sptr notification) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (!notification->GetNotificationRequestPoint()->GetNotificationDistributedOptions().IsDistributed()) { return ERR_OK; } @@ -1139,7 +1139,7 @@ ErrCode AdvancedNotificationService::IsSupportTemplate(const std::string& templa void AdvancedNotificationService::TriggerRemoveWantAgent(const sptr &request, int32_t removeReason, bool isThirdParty) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s %{public}d %{public}d", __FUNCTION__, isThirdParty, removeReason); if ((request == nullptr) || (request->GetRemovalWantAgent() == nullptr)) { diff --git a/services/ans/src/enable_manager/enable_manager.cpp b/services/ans/src/enable_manager/enable_manager.cpp index 6023b6938..b5fd1beea 100644 --- a/services/ans/src/enable_manager/enable_manager.cpp +++ b/services/ans/src/enable_manager/enable_manager.cpp @@ -24,6 +24,7 @@ #include "bundle_manager_helper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "notification_preferences.h" @@ -228,7 +229,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( bool updateUnEnableTime) { HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_13, EventBranchId::BRANCH_5); - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); if (bundleOption == nullptr) { ANS_LOGE("BundleOption is null."); diff --git a/services/ans/src/notification_local_live_view_subscriber_manager.cpp b/services/ans/src/notification_local_live_view_subscriber_manager.cpp index 9178c95dc..28451253b 100644 --- a/services/ans/src/notification_local_live_view_subscriber_manager.cpp +++ b/services/ans/src/notification_local_live_view_subscriber_manager.cpp @@ -23,6 +23,7 @@ #include "ans_inner_errors.h" #include "ans_log_wrapper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "notification_bundle_option.h" #include "notification_button_option.h" @@ -67,7 +68,7 @@ void NotificationLocalLiveViewSubscriberManager::ResetFfrtQueue() ErrCode NotificationLocalLiveViewSubscriberManager::AddLocalLiveViewSubscriber( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("subscriber is null."); return ERR_ANS_INVALID_PARAM; @@ -105,7 +106,7 @@ ErrCode NotificationLocalLiveViewSubscriberManager::AddLocalLiveViewSubscriber( ErrCode NotificationLocalLiveViewSubscriberManager::RemoveLocalLiveViewSubscriber( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("subscriber is null."); return ERR_ANS_INVALID_PARAM; @@ -130,7 +131,7 @@ ErrCode NotificationLocalLiveViewSubscriberManager::RemoveLocalLiveViewSubscribe void NotificationLocalLiveViewSubscriberManager::NotifyTriggerResponse(const sptr ¬ification, const sptr &buttonOption) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationButtonQueue_ == nullptr) { ANS_LOGE("queue is nullptr"); return; @@ -212,7 +213,7 @@ std::shared_ptr &subscriber, const sptr &bundleOption) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); std::shared_ptr record = FindSubscriberRecord(subscriber); if (record == nullptr) { record = CreateSubscriberRecord(subscriber, bundleOption); @@ -234,7 +235,7 @@ ErrCode NotificationLocalLiveViewSubscriberManager::AddSubscriberInner( ErrCode NotificationLocalLiveViewSubscriberManager::RemoveSubscriberInner( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); std::shared_ptr record = FindSubscriberRecord(subscriber); if (record == nullptr) { @@ -256,7 +257,7 @@ void NotificationLocalLiveViewSubscriberManager::NotifyTriggerResponseInner( const sptr ¬ification, const sptr buttonOption) { ANS_LOGD("ffrt enter!"); - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); int32_t sendUserId; std::string bundleName; diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 13404d66f..30dcb71dc 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -26,6 +26,7 @@ #include "ans_permission_def.h" #include "bundle_manager_helper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "nlohmann/json.hpp" #include "os_account_manager_helper.h" #include "notification_analytics_util.h" @@ -65,7 +66,7 @@ std::shared_ptr NotificationPreferences::GetInstance() ErrCode NotificationPreferences::AddNotificationSlots( const sptr &bundleOption, const std::vector> &slots) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_5, EventBranchId::BRANCH_6) .BundleName(bundleOption == nullptr ? "" : bundleOption->GetBundleName()); @@ -120,7 +121,7 @@ ErrCode NotificationPreferences::AddNotificationBundleProperty(const sptr &bundleOption, const NotificationConstant::SlotType &slotType) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; @@ -427,7 +428,7 @@ ErrCode NotificationPreferences::GetNotificationsEnabledForBundle( ErrCode NotificationPreferences::SetNotificationsEnabledForBundle( const sptr &bundleOption, const bool enabled) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; } diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index 53f912600..1db13d5e9 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -23,7 +23,7 @@ #include "ans_inner_errors.h" #include "os_account_manager_helper.h" #include "ans_log_wrapper.h" -#include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "os_account_manager.h" #include "ipc_skeleton.h" #include "bundle_manager_helper.h" @@ -290,7 +290,7 @@ bool NotificationPreferencesDatabase::CheckRdbStore() bool NotificationPreferencesDatabase::PutSlotsToDisturbeDB( const std::string &bundleName, const int32_t &bundleUid, const std::vector> &slots) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); if (bundleName.empty()) { ANS_LOGE("Bundle name is null."); @@ -839,7 +839,7 @@ bool NotificationPreferencesDatabase::RemoveBundleFromDisturbeDB( bool NotificationPreferencesDatabase::RemoveSlotFromDisturbeDB( const std::string &bundleKey, const NotificationConstant::SlotType &type, const int32_t &bundleUid) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); int32_t userId = -1; OsAccountManagerHelper::GetInstance().GetOsAccountLocalIdFromUid(bundleUid, userId); diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index 01a0fb257..b703d4266 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -23,6 +23,7 @@ #include "ans_inner_errors.h" #include "ans_log_wrapper.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "notification_flags.h" #include "notification_constant.h" @@ -81,7 +82,7 @@ void NotificationSubscriberManager::ResetFfrtQueue() ErrCode NotificationSubscriberManager::AddSubscriber( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("subscriber is null."); return ERR_ANS_INVALID_PARAM; @@ -144,7 +145,7 @@ ErrCode NotificationSubscriberManager::AddSubscriber( ErrCode NotificationSubscriberManager::RemoveSubscriber( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (subscriber == nullptr) { ANS_LOGE("subscriber is null."); return ERR_ANS_INVALID_PARAM; @@ -175,7 +176,7 @@ ErrCode NotificationSubscriberManager::RemoveSubscriber( void NotificationSubscriberManager::NotifyConsumed( const sptr ¬ification, const sptr ¬ificationMap) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationSubQueue_ == nullptr) { ANS_LOGE("queue is nullptr"); return; @@ -188,7 +189,7 @@ void NotificationSubscriberManager::NotifyConsumed( void NotificationSubscriberManager::NotifyApplicationInfoNeedChanged(const std::string& bundleName) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationSubQueue_ == nullptr || bundleName.empty()) { ANS_LOGE("queue is nullptr"); return; @@ -202,7 +203,7 @@ void NotificationSubscriberManager::NotifyApplicationInfoNeedChanged(const std:: void NotificationSubscriberManager::NotifyApplicationInfochangedInner(const std::string& bundleName) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGI("NotifyApplicationInfochangedInner %{public}s", bundleName.c_str()); for (auto record : subscriberRecordList_) { if (record->needNotifyApplicationChanged) { @@ -214,7 +215,7 @@ void NotificationSubscriberManager::NotifyApplicationInfochangedInner(const std: void NotificationSubscriberManager::BatchNotifyConsumed(const std::vector> ¬ifications, const sptr ¬ificationMap, const std::shared_ptr &record) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGI("Start batch notifyConsumed."); if (notifications.empty() || notificationMap == nullptr || record == nullptr) { ANS_LOGE("Invalid input."); @@ -235,7 +236,7 @@ void NotificationSubscriberManager::BatchNotifyConsumed(const std::vector ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); #ifdef ENABLE_ANS_AGGREGATION std::vector> notifications; notifications.emplace_back(notification); @@ -255,7 +256,7 @@ void NotificationSubscriberManager::NotifyCanceled( void NotificationSubscriberManager::BatchNotifyCanceled(const std::vector> ¬ifications, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); #ifdef ENABLE_ANS_AGGREGATION EXTENTION_WRAPPER->UpdateByCancel(notifications, deleteReason); #endif @@ -298,7 +299,7 @@ void NotificationSubscriberManager::NotifyDoNotDisturbDateChanged(const int32_t void NotificationSubscriberManager::NotifyEnabledNotificationChanged( const sptr &callbackData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationSubQueue_ == nullptr) { ANS_LOGE("queue is nullptr"); return; @@ -311,7 +312,7 @@ void NotificationSubscriberManager::NotifyEnabledNotificationChanged( void NotificationSubscriberManager::NotifyBadgeEnabledChanged(const sptr &callbackData) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationSubQueue_ == nullptr) { ANS_LOGE("Queue is nullptr."); return; @@ -428,7 +429,7 @@ void NotificationSubscriberManager::RemoveRecordInfo( ErrCode NotificationSubscriberManager::AddSubscriberInner( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); std::shared_ptr record = FindSubscriberRecord(subscriber); if (record == nullptr) { record = CreateSubscriberRecord(subscriber); @@ -462,7 +463,7 @@ ErrCode NotificationSubscriberManager::AddSubscriberInner( ErrCode NotificationSubscriberManager::RemoveSubscriberInner( const sptr &subscriber, const sptr &subscribeInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); std::shared_ptr record = FindSubscriberRecord(subscriber); if (record == nullptr) { @@ -490,7 +491,7 @@ void NotificationSubscriberManager::NotifyConsumedInner( ANS_LOGE("[OnConsumed] fail: notification is nullptr."); return; } - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s notification->GetUserId <%{public}d>", __FUNCTION__, notification->GetUserId()); bool wearableFlag = false; @@ -582,7 +583,7 @@ ErrCode NotificationSubscriberManager::IsDeviceTypeAffordConsume( void NotificationSubscriberManager::BatchNotifyConsumedInner(const std::vector> ¬ifications, const sptr ¬ificationMap, const std::shared_ptr &record) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notifications.empty() || notificationMap == nullptr || record == nullptr) { ANS_LOGE("Invalid input."); return; @@ -626,7 +627,7 @@ void NotificationSubscriberManager::NotifyCanceledInner( ANS_LOGE("[OnCanceled] fail: notification is nullptr."); return; } - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s notification->GetUserId <%{public}d>", __FUNCTION__, notification->GetUserId()); std::shared_ptr liveViewContent = nullptr; @@ -711,7 +712,7 @@ bool NotificationSubscriberManager::ConsumeRecordFilter( void NotificationSubscriberManager::BatchNotifyCanceledInner(const std::vector> ¬ifications, const sptr ¬ificationMap, int32_t deleteReason) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("notifications size = <%{public}zu>", notifications.size()); @@ -960,7 +961,7 @@ void NotificationSubscriberManager::TrackCodeLog( ErrCode NotificationSubscriberManager::DistributeOperation(const sptr& operationInfo) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationSubQueue_ == nullptr || operationInfo == nullptr) { ANS_LOGE("queue is nullptr"); return ERR_ANS_TASK_ERR; diff --git a/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp b/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp index 9ee386ecb..db23a8805 100644 --- a/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp +++ b/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp @@ -21,6 +21,7 @@ #include "ans_inner_errors.h" #include "errors.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "notification_bundle_option.h" @@ -33,7 +34,7 @@ namespace Notification { ErrCode AdvancedNotificationService::TriggerLocalLiveView(const sptr &bundleOption, const int32_t notificationId, const sptr &buttonOption) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s", __FUNCTION__); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); @@ -101,7 +102,7 @@ ErrCode AdvancedNotificationService::SubscribeLocalLiveView( const sptr &subscriber, const sptr &info, const bool isNative) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("%{public}s, isNative: %{public}d", __FUNCTION__, isNative); ErrCode errCode = ERR_OK; diff --git a/services/distributed/src/distributed_notification_manager.cpp b/services/distributed/src/distributed_notification_manager.cpp index 426c44687..180e3f49b 100644 --- a/services/distributed/src/distributed_notification_manager.cpp +++ b/services/distributed/src/distributed_notification_manager.cpp @@ -19,7 +19,7 @@ #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" namespace OHOS { namespace Notification { @@ -314,7 +314,7 @@ bool DistributedNotificationManager::DeleteCallback( ErrCode DistributedNotificationManager::Publish( const std::string &bundleName, const std::string &label, int32_t id, const sptr &request) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("start"); std::string key; if (!GenerateLocalDistributedKey(bundleName, label, id, key)) { @@ -369,7 +369,7 @@ ErrCode DistributedNotificationManager::Update( ErrCode DistributedNotificationManager::Delete(const std::string &bundleName, const std::string &label, int32_t id) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("start"); std::string key; if (!GenerateLocalDistributedKey(bundleName, label, id, key)) { @@ -391,7 +391,7 @@ ErrCode DistributedNotificationManager::Delete(const std::string &bundleName, co ErrCode DistributedNotificationManager::DeleteRemoteNotification( const std::string &deviceId, const std::string &bundleName, const std::string &label, int32_t id) { - HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); ANS_LOGD("start"); std::string key; diff --git a/services/reminder/src/reminder_agent_service.cpp b/services/reminder/src/reminder_agent_service.cpp index e1cccb0ea..c24812079 100644 --- a/services/reminder/src/reminder_agent_service.cpp +++ b/services/reminder/src/reminder_agent_service.cpp @@ -29,7 +29,7 @@ #include "ans_inner_errors.h" #include "os_account_manager.h" #include "notification_helper.h" -#include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #include "in_process_call_wrapper.h" #include @@ -62,7 +62,7 @@ sptr ReminderAgentService::GetInstance() ErrCode ReminderAgentService::PublishReminder(const ReminderRequest& reminder, int32_t& reminderId) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGD("call."); sptr tarReminder = CreateReminderRequest(reminder); if (nullptr == tarReminder) { @@ -106,7 +106,7 @@ ErrCode ReminderAgentService::PublishReminder(const ReminderRequest& reminder, i ErrCode ReminderAgentService::UpdateReminder(const int32_t reminderId, const ReminderRequest& reminder) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGD("call."); sptr tarReminder = CreateReminderRequest(reminder); if (nullptr == tarReminder) { @@ -135,7 +135,7 @@ ErrCode ReminderAgentService::UpdateReminder(const int32_t reminderId, const Rem ErrCode ReminderAgentService::CancelReminder(const int32_t reminderId) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGD("call."); if (!CheckReminderPermission()) { ANSR_LOGE("Failed to check permission: ohos.permission.PUBLISH_AGENT_REMINDER."); @@ -151,7 +151,7 @@ ErrCode ReminderAgentService::CancelReminder(const int32_t reminderId) ErrCode ReminderAgentService::CancelAllReminders() { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGD("call."); if (!CheckReminderPermission()) { ANSR_LOGE("Failed to check permission: ohos.permission.PUBLISH_AGENT_REMINDER."); @@ -171,7 +171,7 @@ ErrCode ReminderAgentService::CancelAllReminders() ErrCode ReminderAgentService::GetValidReminders(std::vector& reminders) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGD("call."); if (!CheckReminderPermission()) { ANSR_LOGE("Failed to check permission: ohos.permission.PUBLISH_AGENT_REMINDER."); @@ -188,7 +188,7 @@ ErrCode ReminderAgentService::GetValidReminders(std::vector& dates) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGD("call."); if (!CheckReminderPermission()) { ANSR_LOGE("Failed to check permission: ohos.permission.PUBLISH_AGENT_REMINDER."); diff --git a/services/reminder/src/reminder_data_manager.cpp b/services/reminder/src/reminder_data_manager.cpp index 386bd3fb4..749df0a9d 100644 --- a/services/reminder/src/reminder_data_manager.cpp +++ b/services/reminder/src/reminder_data_manager.cpp @@ -42,6 +42,7 @@ #include "iservice_registry.h" #include "config_policy_utils.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #ifdef HAS_HISYSEVENT_PART #include "hisysevent.h" #endif @@ -94,7 +95,7 @@ ReminderDataManager::~ReminderDataManager() = default; ErrCode ReminderDataManager::PublishReminder(const sptr &reminder, const int32_t callingUid) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); uint32_t callerTokenId = IPCSkeleton::GetCallingTokenID(); if (callerTokenId == 0) { ANSR_LOGE("pushlish failed, callerTokenId is 0"); @@ -118,7 +119,7 @@ ErrCode ReminderDataManager::PublishReminder(const sptr &remind ErrCode ReminderDataManager::CancelReminder( const int32_t &reminderId, const int32_t callingUid) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); ANSR_LOGI("cancel reminder id: %{public}d", reminderId); sptr reminder = FindReminderRequestLocked(reminderId, false); if (reminder == nullptr) { @@ -152,7 +153,7 @@ ErrCode ReminderDataManager::CancelReminder( ErrCode ReminderDataManager::CancelAllReminders(const std::string& bundleName, const int32_t userId, const int32_t callingUid) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); CancelRemindersImplLocked(bundleName, userId, callingUid); return ERR_OK; } @@ -180,7 +181,7 @@ sptr ReminderDataManager::CheckExcludeDateParam(const int32_t r ErrCode ReminderDataManager::AddExcludeDate(const int32_t reminderId, const int64_t date, const int32_t callingUid) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); sptr reminder = CheckExcludeDateParam(reminderId, callingUid); if (reminder == nullptr) { return ERR_REMINDER_NOT_EXIST; @@ -197,7 +198,7 @@ ErrCode ReminderDataManager::AddExcludeDate(const int32_t reminderId, const int6 ErrCode ReminderDataManager::DelExcludeDates(const int32_t reminderId, const int32_t callingUid) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); sptr reminder = CheckExcludeDateParam(reminderId, callingUid); if (reminder == nullptr) { return ERR_REMINDER_NOT_EXIST; @@ -214,7 +215,7 @@ ErrCode ReminderDataManager::DelExcludeDates(const int32_t reminderId, ErrCode ReminderDataManager::GetExcludeDates(const int32_t reminderId, const int32_t callingUid, std::vector& dates) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); sptr reminder = CheckExcludeDateParam(reminderId, callingUid); if (reminder == nullptr) { return ERR_REMINDER_NOT_EXIST; @@ -230,7 +231,7 @@ ErrCode ReminderDataManager::GetExcludeDates(const int32_t reminderId, void ReminderDataManager::GetValidReminders( const int32_t callingUid, std::vector &reminders) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); std::lock_guard lock(ReminderDataManager::MUTEX); auto reminderVector = store_->GetAllValidReminders(); for (auto& eachReminder : reminderVector) { diff --git a/services/reminder/src/reminder_data_manager_inner.cpp b/services/reminder/src/reminder_data_manager_inner.cpp index d36cd1986..2fb53951f 100644 --- a/services/reminder/src/reminder_data_manager_inner.cpp +++ b/services/reminder/src/reminder_data_manager_inner.cpp @@ -40,6 +40,7 @@ #include "iservice_registry.h" #include "config_policy_utils.h" #include "hitrace_meter_adapter.h" +#include "hitrace_meter.h" #ifdef HAS_HISYSEVENT_PART #include "hisysevent.h" #include "reminder_utils.h" @@ -286,7 +287,7 @@ void ReminderDataManager::UpdateReminderFromDb(const std::vector& reminder, const int32_t callingUid) { - HITRACE_METER_NAME(HITRACE_TAG_OHOS, __PRETTY_FUNCTION__); + NOTIFICATION_HITRACE(HITRACE_TAG_OHOS); sptr reminderOld = FindReminderRequestLocked(reminder->GetReminderId(), false); bool existInMemory = true; if (nullptr != reminderOld) { diff --git a/services/reminder/test/unittest/BUILD.gn b/services/reminder/test/unittest/BUILD.gn index 3cd456192..c633c0b5d 100644 --- a/services/reminder/test/unittest/BUILD.gn +++ b/services/reminder/test/unittest/BUILD.gn @@ -151,6 +151,7 @@ ohos_unittest("reminder_agent_service_test") { "data_share:datashare_common", "ffrt:libffrt", "hilog:libhilog", + "hitrace:hitrace_meter", "ipc:ipc_core", "os_account:os_account_innerkits", "relational_store:native_rdb", -- Gitee