From 62e8eb8eadc40dc7ca422feeb33bb34f3b20e673 Mon Sep 17 00:00:00 2001 From: gaojiaqi Date: Fri, 19 Jan 2024 14:24:24 +0800 Subject: [PATCH 1/4] =?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: gaojiaqi --- .../src/bundle_active_report_handler.cpp | 6 +--- utils/include/bundle_active_log.h | 35 +++++-------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/services/packageusage/src/bundle_active_report_handler.cpp b/services/packageusage/src/bundle_active_report_handler.cpp index 8a3b226..7b6497a 100644 --- a/services/packageusage/src/bundle_active_report_handler.cpp +++ b/services/packageusage/src/bundle_active_report_handler.cpp @@ -34,17 +34,16 @@ void BundleActiveReportHandler::ProcessEvent(const AppExecFwk::InnerEvent::Point BUNDLE_ACTIVE_LOGE("event is null, exit ProcessEvent"); return; } + auto ptrToHandlerobj = event->GetSharedObject(); switch (event->GetInnerEventId()) { case MSG_REPORT_EVENT: { BUNDLE_ACTIVE_LOGI("MSG_REPORT_EVENT CALLED"); - auto ptrToHandlerobj = event->GetSharedObject(); BundleActiveReportHandlerObject tmpHandlerobj = *ptrToHandlerobj; bundleActiveCore_->ReportEvent(tmpHandlerobj.event_, tmpHandlerobj.userId_); break; } case MSG_FLUSH_TO_DISK: { BUNDLE_ACTIVE_LOGI("FLUSH TO DISK HANDLE"); - auto ptrToHandlerobj = event->GetSharedObject(); BundleActiveReportHandlerObject tmpHandlerobj = *ptrToHandlerobj; if (tmpHandlerobj.userId_ != bundleActiveCore_->currentUsedUser_) { BUNDLE_ACTIVE_LOGE("flush user is %{public}d, not last user %{public}d, return", @@ -56,21 +55,18 @@ void BundleActiveReportHandler::ProcessEvent(const AppExecFwk::InnerEvent::Point break; } case MSG_REMOVE_USER: { - auto ptrToHandlerobj = event->GetSharedObject(); BundleActiveReportHandlerObject tmpHandlerobj = *ptrToHandlerobj; bundleActiveCore_->OnUserRemoved(tmpHandlerobj.userId_); break; } case MSG_BUNDLE_UNINSTALLED: { BUNDLE_ACTIVE_LOGI("MSG_BUNDLE_UNINSTALLED CALLED"); - auto ptrToHandlerobj = event->GetSharedObject(); BundleActiveReportHandlerObject tmpHandlerobj = *ptrToHandlerobj; bundleActiveCore_->OnBundleUninstalled(tmpHandlerobj.userId_, tmpHandlerobj.bundleName_); break; } case MSG_SWITCH_USER: { BUNDLE_ACTIVE_LOGI("MSG_SWITCH_USER CALLED"); - auto ptrToHandlerobj = event->GetSharedObject(); BundleActiveReportHandlerObject tmpHandlerobj = *ptrToHandlerobj; bundleActiveCore_->OnUserSwitched(tmpHandlerobj.userId_); break; diff --git a/utils/include/bundle_active_log.h b/utils/include/bundle_active_log.h index 68f5282..8f9e628 100644 --- a/utils/include/bundle_active_log.h +++ b/utils/include/bundle_active_log.h @@ -21,19 +21,11 @@ namespace OHOS { namespace DeviceUsageStats { -#ifndef LOG_TAG_DOMAIN_ID_BUNDLE_ACTIVE -#define LOG_TAG_DOMAIN_ID_BUNDLE_ACTIVE 0xD001710 -#endif +#undef LOG_DOMAIN +#define LOG_DOMAIN 0xD001710 -#ifndef LOG_TAG_BUNDLE_ACTIVE -#define LOG_TAG_BUNDLE_ACTIVE "BUNDLE_ACTIVE" -#endif - -static constexpr OHOS::HiviewDFX::HiLogLabel BUNDLE_ACTIVE_LOG_LABEL = { - LOG_CORE, - LOG_TAG_DOMAIN_ID_BUNDLE_ACTIVE, - LOG_TAG_BUNDLE_ACTIVE -}; +#undef LOG_TAG +#define LOG_TAG "BUNDLE_ACTIVE" enum class BundleActiveLogLevel : uint8_t { DEBUG = 0, INFO, WARN, ERROR, FATAL }; @@ -60,20 +52,11 @@ private: static BundleActiveLogLevel logLevel_; }; -#define BUNDLE_ACTIVE_PRINT_LOG(LEVEL, Level, fmt, ...) \ - if (BundleActiveLog::JudgeValidLevel(BundleActiveLogLevel::LEVEL)) \ - OHOS::HiviewDFX::HiLog::Level(BUNDLE_ACTIVE_LOG_LABEL, \ - "[%{public}s(%{public}s):%{public}d] " fmt, \ - BundleActiveLog::GetCurrFileName(__FILE__).c_str(), \ - __FUNCTION__, \ - __LINE__, \ - ##__VA_ARGS__) - -#define BUNDLE_ACTIVE_LOGD(fmt, ...) BUNDLE_ACTIVE_PRINT_LOG(DEBUG, Debug, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGI(fmt, ...) BUNDLE_ACTIVE_PRINT_LOG(INFO, Info, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGW(fmt, ...) BUNDLE_ACTIVE_PRINT_LOG(WARN, Warn, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGE(fmt, ...) BUNDLE_ACTIVE_PRINT_LOG(ERROR, Error, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGF(fmt, ...) BUNDLE_ACTIVE_PRINT_LOG(FATAL, Fatal, fmt, ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, fmt, ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, fmt, ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, fmt, ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, fmt, ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, fmt, ##__VA_ARGS__) } // namespace DeviceUsageStats } // namespace OHOS #endif // BUNDLE_ACTIVE_LOG_H -- Gitee From 4883a1fa01b9bf123a44e2df621a99ecba16bc65 Mon Sep 17 00:00:00 2001 From: gaojiaqi Date: Fri, 19 Jan 2024 19:24:58 +0800 Subject: [PATCH 2/4] =?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: gaojiaqi --- utils/include/bundle_active_log.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utils/include/bundle_active_log.h b/utils/include/bundle_active_log.h index 8f9e628..60887d1 100644 --- a/utils/include/bundle_active_log.h +++ b/utils/include/bundle_active_log.h @@ -52,11 +52,16 @@ private: static BundleActiveLogLevel logLevel_; }; -#define BUNDLE_ACTIVE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, fmt, ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, fmt, ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) +#define BUNDLE_ACTIVE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) } // namespace DeviceUsageStats } // namespace OHOS #endif // BUNDLE_ACTIVE_LOG_H -- Gitee From bd9a4e8541accdc5030f0b4808f6ce5e997497bb Mon Sep 17 00:00:00 2001 From: gaojiaqi Date: Fri, 19 Jan 2024 19:33:58 +0800 Subject: [PATCH 3/4] =?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: gaojiaqi --- utils/include/bundle_active_log.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/include/bundle_active_log.h b/utils/include/bundle_active_log.h index 60887d1..5abd31e 100644 --- a/utils/include/bundle_active_log.h +++ b/utils/include/bundle_active_log.h @@ -52,15 +52,15 @@ private: static BundleActiveLogLevel logLevel_; }; -#define BUNDLE_ACTIVE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ +#define BUNDLE_ACTIVE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ +#define BUNDLE_ACTIVE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ +#define BUNDLE_ACTIVE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ +#define BUNDLE_ACTIVE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) -#define BUNDLE_ACTIVE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt,\ +#define BUNDLE_ACTIVE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) } // namespace DeviceUsageStats } // namespace OHOS -- Gitee From 5f56203e23b58e37af8fea378eb4d55c7e20fef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=98=8E=E6=9D=B0?= <1490297456@qq.com> Date: Fri, 19 Jan 2024 11:54:08 +0000 Subject: [PATCH 4/4] update utils/include/bundle_active_log.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱明杰 <1490297456@qq.com> --- utils/include/bundle_active_log.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/include/bundle_active_log.h b/utils/include/bundle_active_log.h index 5abd31e..22fc8b7 100644 --- a/utils/include/bundle_active_log.h +++ b/utils/include/bundle_active_log.h @@ -53,15 +53,15 @@ private: }; #define BUNDLE_ACTIVE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ - BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define BUNDLE_ACTIVE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ - BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define BUNDLE_ACTIVE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ - BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define BUNDLE_ACTIVE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ - BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__) #define BUNDLE_ACTIVE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s):%{public}d]" fmt, \ - BundleActiveLog::GetCurrFileName(__FILE__).c_str(), ##__VA_ARGS__) + BundleActiveLog::GetCurrFileName(__FILE__).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__) } // namespace DeviceUsageStats } // namespace OHOS #endif // BUNDLE_ACTIVE_LOG_H -- Gitee