From 17a0da48763d9eec205c121840fe64e0155cb16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E5=B0=8F=E5=B8=85?= Date: Sun, 3 Apr 2022 08:25:26 +0800 Subject: [PATCH 1/2] Fix build for 64 bit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 贺小帅 Change-Id: Iae19f0866c2c7405e2fb2f64c04f77dd716b53fa --- frameworks/src/bundle_state_query.cpp | 24 ++++++------ .../innerkits/src/bundle_active_proxy.cpp | 12 +++--- services/common/src/bundle_active_core.cpp | 13 ++++--- services/common/src/bundle_active_service.cpp | 4 +- .../src/bundle_active_usage_database.cpp | 10 +++-- .../src/bundle_active_group_controller.cpp | 7 ++-- .../src/bundle_active_user_history.cpp | 12 +++--- .../packageusage/src/bundle_active_event.cpp | 4 +- .../src/bundle_active_user_service.cpp | 39 ++++++++++--------- 9 files changed, 70 insertions(+), 55 deletions(-) mode change 100644 => 100755 frameworks/src/bundle_state_query.cpp mode change 100644 => 100755 services/common/src/bundle_active_service.cpp mode change 100644 => 100755 services/common/src/bundle_active_usage_database.cpp mode change 100644 => 100755 services/packagegroup/src/bundle_active_group_controller.cpp mode change 100644 => 100755 services/packagegroup/src/bundle_active_user_history.cpp mode change 100644 => 100755 services/packageusage/src/bundle_active_user_service.cpp diff --git a/frameworks/src/bundle_state_query.cpp b/frameworks/src/bundle_state_query.cpp old mode 100644 new mode 100755 index 278d2bf..c3ffb5d --- a/frameworks/src/bundle_state_query.cpp +++ b/frameworks/src/bundle_state_query.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include #include "securec.h" @@ -339,7 +340,7 @@ napi_value ParseStatesParameters(const napi_env &env, const napi_callback_info & params.errorCode = ERR_USAGE_STATS_END_TIME_INVALID; } if ((params.errorCode == ERR_OK) && (params.endTime <= params.beginTime)) { - BUNDLE_ACTIVE_LOGE("ParseStatesParameters endTime(%{public}lld) <= beginTime(%{public}lld)", + BUNDLE_ACTIVE_LOGE("ParseStatesParameters endTime(%{public}" PRId64") <= beginTime(%{public}" PRId64")", params.endTime, params.beginTime); params.errorCode = ERR_USAGE_STATS_TIME_INTERVAL; } @@ -379,10 +380,10 @@ napi_value QueryCurrentBundleActiveStates(napi_env env, napi_callback_info info) asyncCallbackInfo->env = env; asyncCallbackInfo->asyncWork = nullptr; asyncCallbackInfo->beginTime = params.beginTime; - BUNDLE_ACTIVE_LOGI("QueryCurrentBundleActiveStates asyncCallbackInfo->beginTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryCurrentBundleActiveStates asyncCallbackInfo->beginTime: %{public}" PRId64, asyncCallbackInfo->beginTime); asyncCallbackInfo->endTime = params.endTime; - BUNDLE_ACTIVE_LOGI("QueryCurrentBundleActiveStates asyncCallbackInfo->endTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryCurrentBundleActiveStates asyncCallbackInfo->endTime: %{public}" PRId64, asyncCallbackInfo->endTime); BundleStateCommon::SettingCallbackPromiseInfo(env, params.callback, asyncCallbackInfo->info, promise); @@ -454,10 +455,10 @@ napi_value QueryBundleActiveStates(napi_env env, napi_callback_info info) asyncCallbackInfo->env = env; asyncCallbackInfo->asyncWork = nullptr; asyncCallbackInfo->beginTime = params.beginTime; - BUNDLE_ACTIVE_LOGI("QueryBundleActiveStates asyncCallbackInfo->beginTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryBundleActiveStates asyncCallbackInfo->beginTime: %{public}" PRId64, asyncCallbackInfo->beginTime); asyncCallbackInfo->endTime = params.endTime; - BUNDLE_ACTIVE_LOGI("QueryBundleActiveStates asyncCallbackInfo->endTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryBundleActiveStates asyncCallbackInfo->endTime: %{public}" PRId64, asyncCallbackInfo->endTime); BundleStateCommon::SettingCallbackPromiseInfo(env, params.callback, asyncCallbackInfo->info, promise); @@ -546,7 +547,8 @@ napi_value ParseAppUsageParametersByInterval(const napi_env &env, const napi_cal params.errorCode = ERR_USAGE_STATS_END_TIME_INVALID; } if ((params.errorCode == ERR_OK) && (params.endTime <= params.beginTime)) { - BUNDLE_ACTIVE_LOGE("ParseAppUsageParametersByInterval endTime(%{public}lld) <= beginTime(%{public}lld)", + BUNDLE_ACTIVE_LOGE("ParseAppUsageParametersByInterval endTime(%{public}" PRId64") <= " + "beginTime(%{public}" PRId64")", params.endTime, params.beginTime); params.errorCode = ERR_USAGE_STATS_TIME_INTERVAL; } @@ -589,10 +591,10 @@ napi_value QueryBundleStateInfoByInterval(napi_env env, napi_callback_info info) BUNDLE_ACTIVE_LOGI("QueryBundleStateInfoByInterval asyncCallbackInfo->intervalType: %{public}d", asyncCallbackInfo->intervalType); asyncCallbackInfo->beginTime = params.beginTime; - BUNDLE_ACTIVE_LOGI("QueryBundleStateInfoByInterval asyncCallbackInfo->beginTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryBundleStateInfoByInterval asyncCallbackInfo->beginTime: %{public}" PRId64, asyncCallbackInfo->beginTime); asyncCallbackInfo->endTime = params.endTime; - BUNDLE_ACTIVE_LOGI("QueryBundleStateInfoByInterval asyncCallbackInfo->endTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryBundleStateInfoByInterval asyncCallbackInfo->endTime: %{public}" PRId64, asyncCallbackInfo->endTime); BundleStateCommon::SettingCallbackPromiseInfo(env, params.callback, asyncCallbackInfo->info, promise); napi_value resourceName = nullptr; @@ -668,7 +670,7 @@ napi_value ParseAppUsageParameters(const napi_env &env, const napi_callback_info params.errorCode = ERR_USAGE_STATS_END_TIME_INVALID; } if ((params.errorCode == ERR_OK) && (params.endTime <= params.beginTime)) { - BUNDLE_ACTIVE_LOGE("ParseAppUsageParameters endTime(%{public}lld) <= beginTime(%{public}lld)", + BUNDLE_ACTIVE_LOGE("ParseAppUsageParameters endTime(%{public}" PRId64") <= beginTime(%{public}" PRId64")", params.endTime, params.beginTime); params.errorCode = ERR_USAGE_STATS_TIME_INTERVAL; } @@ -708,10 +710,10 @@ napi_value QueryBundleStateInfos(napi_env env, napi_callback_info info) asyncCallbackInfo->env = env; asyncCallbackInfo->asyncWork = nullptr; asyncCallbackInfo->beginTime = params.beginTime; - BUNDLE_ACTIVE_LOGI("QueryBundleStateInfos asyncCallbackInfo->beginTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryBundleStateInfos asyncCallbackInfo->beginTime: %{public}" PRId64, asyncCallbackInfo->beginTime); asyncCallbackInfo->endTime = params.endTime; - BUNDLE_ACTIVE_LOGI("QueryBundleStateInfos asyncCallbackInfo->endTime: %{public}lld", + BUNDLE_ACTIVE_LOGI("QueryBundleStateInfos asyncCallbackInfo->endTime: %{public}" PRId64, asyncCallbackInfo->endTime); BundleStateCommon::SettingCallbackPromiseInfo(env, params.callback, asyncCallbackInfo->info, promise); napi_value resourceName = nullptr; diff --git a/interfaces/innerkits/src/bundle_active_proxy.cpp b/interfaces/innerkits/src/bundle_active_proxy.cpp index 440e8e6..921d858 100644 --- a/interfaces/innerkits/src/bundle_active_proxy.cpp +++ b/interfaces/innerkits/src/bundle_active_proxy.cpp @@ -15,6 +15,8 @@ #include "bundle_active_proxy.h" +#include + namespace OHOS { namespace DeviceUsageStats { int BundleActiveProxy::ReportEvent(BundleActiveEvent& event, const int userId) @@ -75,8 +77,8 @@ std::vector BundleActiveProxy::QueryPackageStats(const } for (uint32_t i = 0; i < result.size(); i++) { BUNDLE_ACTIVE_LOGI("QueryPackageStats result idx is %{public}d, bundleName_ is %{public}s, " - "lastTimeUsed_ is %{public}lld, lastContiniousTaskUsed_ is %{public}lld, " - "totalInFrontTime_ is %{public}lld, totalContiniousTaskUsedTime_ is %{public}lld", + "lastTimeUsed_ is %{public}" PRId64", lastContiniousTaskUsed_ is %{public}" PRId64", " + "totalInFrontTime_ is %{public}" PRId64", totalContiniousTaskUsedTime_ is %{public}" PRId64, i + 1, result[i].bundleName_.c_str(), result[i].lastTimeUsed_, result[i].lastContiniousTaskUsed_, result[i].totalInFrontTime_, result[i].totalContiniousTaskUsedTime_); } @@ -152,8 +154,8 @@ std::vector BundleActiveProxy::QueryCurrentPackageStat } for (uint32_t i = 0; i < result.size(); i++) { BUNDLE_ACTIVE_LOGI("QueryPackageStats result idx is %{public}d, bundleName_ is %{public}s, " - "lastTimeUsed_ is %{public}lld, lastContiniousTaskUsed_ is %{public}lld, " - "totalInFrontTime_ is %{public}lld, totalContiniousTaskUsedTime_ is %{public}lld", + "lastTimeUsed_ is %{public}" PRId64", lastContiniousTaskUsed_ is %{public}" PRId64", " + "totalInFrontTime_ is %{public}" PRId64", totalContiniousTaskUsedTime_ is %{public}" PRId64, i + 1, result[i].bundleName_.c_str(), result[i].lastTimeUsed_, result[i].lastContiniousTaskUsed_, result[i].totalInFrontTime_, result[i].totalContiniousTaskUsedTime_); } @@ -183,7 +185,7 @@ std::vector BundleActiveProxy::QueryCurrentEvents(const int64 } for (uint32_t i = 0; i < result.size(); i++) { BUNDLE_ACTIVE_LOGI("QueryCurrentEvents event id is %{public}d, bundle name is %{public}s," - "time stamp is %{public}lld", + "time stamp is %{public}" PRId64, result[i].eventId_, result[i].bundleName_.c_str(), result[i].timeStamp_); } return result; diff --git a/services/common/src/bundle_active_core.cpp b/services/common/src/bundle_active_core.cpp index 49a3efa..ba0213b 100644 --- a/services/common/src/bundle_active_core.cpp +++ b/services/common/src/bundle_active_core.cpp @@ -15,6 +15,7 @@ #include "time_service_client.h" +#include #include "bundle_active_event.h" #include "bundle_active_report_handler.h" #include "bundle_active_group_common.h" @@ -142,7 +143,7 @@ void BundleActiveCore::Init() realTimeShot_ = timer->GetBootTimeMs(); systemTimeShot_ = GetSystemTimeMs(); bundleGroupController_ = std::make_shared(debugCore_); - BUNDLE_ACTIVE_LOGI("system time shot is %{public}lld", systemTimeShot_); + BUNDLE_ACTIVE_LOGI("system time shot is %{public}" PRId64, systemTimeShot_); } void BundleActiveCore::InitBundleGroupController() @@ -331,8 +332,8 @@ int64_t BundleActiveCore::CheckTimeChangeAndGetWallTime(int userId) if (actualSystemTime == -1 || actualRealTime == -1) { return -1; } - BUNDLE_ACTIVE_LOGI("asystime is %{public}lld, artime is %{public}lld, esystime is %{public}lld, " - "diff is %{public}lld", + BUNDLE_ACTIVE_LOGI("asystime is %{public}" PRId64", artime is %{public}" PRId64", esystime is %{public}" PRId64", " + "diff is %{public}" PRId64, actualSystemTime, actualRealTime, expectedSystemTime, diffSystemTime); if (std::abs(diffSystemTime) > TIME_CHANGE_THRESHOLD_MILLIS) { // 时区变换逻辑 @@ -407,7 +408,7 @@ void BundleActiveCore::OnUserSwitched(const int userId) int BundleActiveCore::ReportEvent(BundleActiveEvent& event, const int userId) { - BUNDLE_ACTIVE_LOGI("FLUSH interval is %{public}lld, debug is %{public}d", flushInterval_, debugCore_); + BUNDLE_ACTIVE_LOGI("FLUSH interval is %{public}" PRId64", debug is %{public}d", flushInterval_, debugCore_); std::lock_guard lock(mutex_); if (userId == 0 || userId == -1) { return -1; @@ -425,7 +426,7 @@ int BundleActiveCore::ReportEvent(BundleActiveEvent& event, const int userId) return 0; } - BUNDLE_ACTIVE_LOGI("report event called, bundle name %{public}s time %{public}lld userId %{public}d, " + BUNDLE_ACTIVE_LOGI("report event called, bundle name %{public}s time %{public}" PRId64" userId %{public}d, " "eventid %{public}d, in lock range", event.bundleName_.c_str(), event.timeStamp_, userId, event.eventId_); int64_t timeNow = CheckTimeChangeAndGetWallTime(userId); if (timeNow == -1) { @@ -484,7 +485,7 @@ std::vector BundleActiveCore::QueryPackageStats(const if (timeNow == -1) { return result; } - BUNDLE_ACTIVE_LOGI("QueryPackageStats begin time is %{public}lld, end time is %{public}lld, " + BUNDLE_ACTIVE_LOGI("QueryPackageStats begin time is %{public}" PRId64", end time is %{public}" PRId64", " "intervaltype is %{public}d", beginTime, endTime, intervalType); if (beginTime > timeNow || beginTime >= endTime) { BUNDLE_ACTIVE_LOGI("QueryPackageStats time span illegal"); diff --git a/services/common/src/bundle_active_service.cpp b/services/common/src/bundle_active_service.cpp old mode 100644 new mode 100755 index 786e978..ff42fe9 --- a/services/common/src/bundle_active_service.cpp +++ b/services/common/src/bundle_active_service.cpp @@ -316,7 +316,7 @@ std::vector BundleActiveService::QueryCurrentPackageSt bundleName); } } - BUNDLE_ACTIVE_LOGI("QueryCurrentPackageStats result size is %{public}d", result.size()); + BUNDLE_ACTIVE_LOGI("QueryCurrentPackageStats result size is %{public}zu", result.size()); return result; } @@ -340,7 +340,7 @@ std::vector BundleActiveService::QueryCurrentEvents(const int result = bundleActiveCore_->QueryEvents(userId, beginTime, endTime, bundleName); } } - BUNDLE_ACTIVE_LOGI("QueryCurrentEvents result size is %{public}d", result.size()); + BUNDLE_ACTIVE_LOGI("QueryCurrentEvents result size is %{public}zu", result.size()); return result; } diff --git a/services/common/src/bundle_active_usage_database.cpp b/services/common/src/bundle_active_usage_database.cpp old mode 100644 new mode 100755 index d765491..58a5ee8 --- a/services/common/src/bundle_active_usage_database.cpp +++ b/services/common/src/bundle_active_usage_database.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include #include #include @@ -1130,7 +1131,7 @@ void BundleActiveUsageDatabase::RenewTableTime(int64_t changedTime) vector tableArray = sortedTableArray_.at(i); for (unsigned int j = 0; j < tableArray.size(); j++) { int64_t newTime = tableArray.at(j) + changedTime; - BUNDLE_ACTIVE_LOGI("new table time is %{public}lld", newTime); + BUNDLE_ACTIVE_LOGI("new table time is %{public}" PRId64, newTime); if (newTime < 0) { DeleteInvalidTable(i, tableArray.at(j)); } else { @@ -1209,7 +1210,7 @@ vector BundleActiveUsageDatabase::QueryDatabaseUsageSt return databaseUsageStats; } if (endTime <= beginTime) { - BUNDLE_ACTIVE_LOGE("endTime(%{public}lld) <= beginTime(%{public}lld)", endTime, beginTime); + BUNDLE_ACTIVE_LOGE("endTime(%{public}" PRId64") <= beginTime(%{public}" PRId64")", endTime, beginTime); return databaseUsageStats; } int32_t startIndex = NearIndexOnOrBeforeCurrentTime(beginTime, sortedTableArray_.at(databaseType)); @@ -1301,12 +1302,13 @@ vector BundleActiveUsageDatabase::QueryDatabaseEvents(int64_t return databaseEvents; } if (endTime <= beginTime) { - BUNDLE_ACTIVE_LOGE("endTime(%{public}lld) <= beginTime(%{public}lld)", endTime, beginTime); + BUNDLE_ACTIVE_LOGE("endTime(%{public}" PRId64") <= beginTime(%{public}" PRId64")", endTime, beginTime); return databaseEvents; } int64_t eventTableTime = ParseStartTime(eventTableName_); if (endTime < eventTableTime) { - BUNDLE_ACTIVE_LOGE("endTime(%{public}lld) <= eventTableTime(%{public}lld)", endTime, eventTableTime); + BUNDLE_ACTIVE_LOGE("endTime(%{public}" PRId64") <= eventTableTime(%{public}" PRId64")", + endTime, eventTableTime); return databaseEvents; } vector queryCondition; diff --git a/services/packagegroup/src/bundle_active_group_controller.cpp b/services/packagegroup/src/bundle_active_group_controller.cpp old mode 100644 new mode 100755 index e11ec5d..7ff8586 --- a/services/packagegroup/src/bundle_active_group_controller.cpp +++ b/services/packagegroup/src/bundle_active_group_controller.cpp @@ -15,6 +15,7 @@ #include "time_service_client.h" +#include #include "bundle_active_user_history.h" #include "bundle_active_group_handler.h" #include "ibundle_active_service.h" @@ -84,7 +85,7 @@ void BundleActiveGroupController::SetHandlerAndCreateUserHistory( { if (bundleUserHistory_ == nullptr) { BUNDLE_ACTIVE_LOGI("SetHandlerAndCreateUserHistory bundleUserHistory_ is null, " - "called constructor, bootstamp is %{public}lld", bootFromTimeStamp); + "called constructor, bootstamp is %{public}" PRId64, bootFromTimeStamp); bundleUserHistory_ = std::make_shared(bootFromTimeStamp); } OnScreenChanged(IsScreenOn(), bootFromTimeStamp); @@ -324,8 +325,8 @@ void BundleActiveGroupController::SetBundleGroup(const std::string& bundleName, int64_t bootBasedTimeStampAdjusted = bundleUserHistory_->GetBootBasedTimeStamp(bootBasedTimeStamp); if (newGroup > ACTIVE_GROUP_ALIVE && oneBundleHistory->bundleAliveTimeoutTimeStamp_ > bootBasedTimeStampAdjusted) { - BUNDLE_ACTIVE_LOGI("%{public}s should be decreased, but time out in alive is not expire! now is %{public}lld," - "timeout is %{public}lld", + BUNDLE_ACTIVE_LOGI("%{public}s should be decreased, but time out in alive is not expire! " + "now is %{public}" PRId64", timeout is %{public}" PRId64, bundleName.c_str(), bootBasedTimeStampAdjusted, oneBundleHistory->bundleAliveTimeoutTimeStamp_); newGroup = ACTIVE_GROUP_ALIVE; reason = oneBundleHistory->reasonInGroup_; diff --git a/services/packagegroup/src/bundle_active_user_history.cpp b/services/packagegroup/src/bundle_active_user_history.cpp old mode 100644 new mode 100755 index c8f0a8b..7c8ab8f --- a/services/packagegroup/src/bundle_active_user_history.cpp +++ b/services/packagegroup/src/bundle_active_user_history.cpp @@ -14,6 +14,7 @@ */ #include "bundle_active_user_history.h" +#include #include "bundle_active_group_common.h" #include "bundle_active_constant.h" @@ -76,8 +77,8 @@ int BundleActiveUserHistory::GetLevelIndex(const string& bundleName, const int u } int64_t screenDiff = GetScreenOnTimeStamp(bootBasedTimeStamp) - oneBundleHistory->lastScreenUsedTimeStamp_; int64_t bootFromDiff = GetBootBasedTimeStamp(bootBasedTimeStamp) - oneBundleHistory->lastBootFromUsedTimeStamp_; - BUNDLE_ACTIVE_LOGI("screendiff is %{public}lld, bootfromdiff is %{public}lld, bundle name is %{public}s," - "userid is %{public}d", + BUNDLE_ACTIVE_LOGI("screendiff is %{public}" PRId64", bootfromdiff is %{public}" PRId64", " + "bundle name is %{public}s, userid is %{public}d", screenDiff, bootFromDiff, bundleName.c_str(), userId); for (int i = 3; i >= 0; i--) { if (screenDiff >= screenTimeLevel[i] && bootFromDiff >= bootFromTimeLevel[i]) { @@ -237,9 +238,10 @@ void BundleActiveUserHistory::PrintData(int userId) return; } for (auto oneBundleUsage : (*oneUserHistory)) { - BUNDLE_ACTIVE_LOGI("bundle name is %{public}s, lastBootFromUsedTimeStamp_ is %{public}lld, " - "lastScreenUsedTimeStamp_ is %{public}lld, currentGroup_ is %{public}d, reasonInGroup_ is %{public}d, " - "daily time out %{public}lld, alive time out %{public}lld", oneBundleUsage.first.c_str(), + BUNDLE_ACTIVE_LOGI("bundle name is %{public}s, lastBootFromUsedTimeStamp_ is %{public}" PRId64", " + "lastScreenUsedTimeStamp_ is %{public}" PRId64", currentGroup_ is %{public}d, " + "reasonInGroup_ is %{public}d, daily time out %{public}" PRId64", alive time out %{public}" PRId64, + oneBundleUsage.first.c_str(), oneBundleUsage.second->lastBootFromUsedTimeStamp_, oneBundleUsage.second->lastScreenUsedTimeStamp_, oneBundleUsage.second->currentGroup_, oneBundleUsage.second->reasonInGroup_, oneBundleUsage.second->bundleDailyTimeoutTimeStamp_, oneBundleUsage.second->bundleAliveTimeoutTimeStamp_); diff --git a/services/packageusage/src/bundle_active_event.cpp b/services/packageusage/src/bundle_active_event.cpp index eb55933..6b0a0fd 100644 --- a/services/packageusage/src/bundle_active_event.cpp +++ b/services/packageusage/src/bundle_active_event.cpp @@ -15,6 +15,8 @@ #include "bundle_active_event.h" +#include + namespace OHOS { namespace DeviceUsageStats { BundleActiveEvent::BundleActiveEvent() @@ -118,7 +120,7 @@ void BundleActiveEvent::PrintEvent() const { BUNDLE_ACTIVE_LOGI("bundle name is %{public}s, ability name is %{public}s, continue task ability is %{public}s, " "module name is %{public}s, " - "form name is %{public}s, form dimension is %{public}d, form id is %{public}lld, event id is %{public}d", + "form name is %{public}s, form dimension is %{public}d, form id is %{public}" PRId64", event id is %{public}d", bundleName_.c_str(), abilityName_.c_str(), continuousTaskAbilityName_.c_str(), moduleName_.c_str(), formName_.c_str(), formDimension_, formId_, eventId_); } diff --git a/services/packageusage/src/bundle_active_user_service.cpp b/services/packageusage/src/bundle_active_user_service.cpp old mode 100644 new mode 100755 index bc6605d..34aa97d --- a/services/packageusage/src/bundle_active_user_service.cpp +++ b/services/packageusage/src/bundle_active_user_service.cpp @@ -14,6 +14,7 @@ */ #include "bundle_active_user_service.h" +#include #include "bundle_active_core.h" namespace OHOS { @@ -36,11 +37,11 @@ void BundleActiveUserService::Init(const int64_t timeStamp) startupEvent.bundleName_ = BundleActiveEvent::DEVICE_EVENT_PACKAGE_NAME; currentDailyStats->AddEvent(startupEvent); for (auto it : currentDailyStats->events_.events_) { - BUNDLE_ACTIVE_LOGI("Init event id is %{public}d, time stamp is %{public}lld", + BUNDLE_ACTIVE_LOGI("Init event id is %{public}d, time stamp is %{public}" PRId64, it.eventId_, it.timeStamp_); } - BUNDLE_ACTIVE_LOGI("Init currentDailyStats begintime is %{public}lld, " - "expire time is %{public}lld", currentDailyStats->beginTime_, dailyExpiryDate_.GetMilliseconds()); + BUNDLE_ACTIVE_LOGI("Init currentDailyStats begintime is %{public}" PRId64", " + "expire time is %{public}" PRId64, currentDailyStats->beginTime_, dailyExpiryDate_.GetMilliseconds()); } } @@ -93,7 +94,7 @@ void BundleActiveUserService::NotifyNewUpdate() void BundleActiveUserService::ReportEvent(const BundleActiveEvent& event) { - BUNDLE_ACTIVE_LOGI("ReportEvent, B time is %{public}lld, E time is %{public}lld, userId is %{public}d,", + BUNDLE_ACTIVE_LOGI("ReportEvent, B time is %{public}" PRId64", E time is %{public}" PRId64", userId is %{public}d,", currentStats_[0]->beginTime_, dailyExpiryDate_.GetMilliseconds(), userId_); event.PrintEvent(); if (event.timeStamp_ >= dailyExpiryDate_.GetMilliseconds()) { @@ -205,10 +206,10 @@ void BundleActiveUserService::LoadActiveStats(const int64_t timeStamp, const boo currentStats_[intervalType].reset(); // 当前interval stat置空 if (stats != nullptr) { // 找出最近的stats BUNDLE_ACTIVE_LOGI("LoadActiveStats inter type is %{public}d, " - "bundle size is %{public}d", intervalType, stats->bundleStats_.size()); + "bundle size is %{public}zu", intervalType, stats->bundleStats_.size()); // 如果当前时间在stats的统计时间范围内,则可以从数据库加载数据 - BUNDLE_ACTIVE_LOGI("interval type is %{public}d, database stat BEGIN time is %{public}lld, " - "timestamp is %{public}lld, expect end is %{public}lld", + BUNDLE_ACTIVE_LOGI("interval type is %{public}d, database stat BEGIN time is %{public}" PRId64", " + "timestamp is %{public}" PRId64", expect end is %{public}" PRId64, intervalType, stats->beginTime_, timeStamp, stats->beginTime_ + periodLength_[intervalType]); if (timeStamp > stats->beginTime_ && timeStamp < stats->beginTime_ + periodLength_[intervalType]) { currentStats_[intervalType] = stats; @@ -235,8 +236,8 @@ void BundleActiveUserService::LoadActiveStats(const int64_t timeStamp, const boo dailyExpiryDate_.TruncateToDay(); } listener_.OnStatsReload(); - BUNDLE_ACTIVE_LOGI("LoadActiveStats current expire time is %{public}lld, " - "begin time is %{public}lld", dailyExpiryDate_.GetMilliseconds(), tmpCalendar.GetMilliseconds()); + BUNDLE_ACTIVE_LOGI("LoadActiveStats current expire time is %{public}" PRId64", " + "begin time is %{public}" PRId64, dailyExpiryDate_.GetMilliseconds(), tmpCalendar.GetMilliseconds()); } void BundleActiveUserService::RenewStatsInMemory(const int64_t timeStamp) @@ -324,7 +325,8 @@ std::vector BundleActiveUserService::QueryPackageStats return result; } int64_t truncatedEndTime = std::min(currentStats->beginTime_, endTime); - BUNDLE_ACTIVE_LOGI("Query package data in db from %{public}lld to %{public}lld", beginTime, truncatedEndTime); + BUNDLE_ACTIVE_LOGI("Query package data in db from %{public}" PRId64" to %{public}" PRId64, + beginTime, truncatedEndTime); result = database_.QueryDatabaseUsageStats(intervalType, beginTime, truncatedEndTime, userId); BUNDLE_ACTIVE_LOGI("Query package data in db result size is %{public}d", static_cast(result.size())); if (debugUserService_) { @@ -366,7 +368,7 @@ std::vector BundleActiveUserService::QueryEvents(const int64_ } BUNDLE_ACTIVE_LOGI("Query event bundle name is %{public}s", bundleName.c_str()); result = database_.QueryDatabaseEvents(beginTime, endTime, userId, bundleName); - BUNDLE_ACTIVE_LOGI("Query event data in db result size is %{public}d", result.size()); + BUNDLE_ACTIVE_LOGI("Query event data in db result size is %{public}zu", result.size()); if (debugUserService_) { PrintInMemEventStats(); } @@ -413,8 +415,8 @@ void BundleActiveUserService::PrintInMemPackageStats(const int idx) int64_t totalUsedTime = it.second->totalInFrontTime_; int64_t lastTimeContinuousTaskUsed = it.second->lastContiniousTaskUsed_; int64_t totalTimeContinuousTaskUsed = it.second->totalContiniousTaskUsedTime_; - BUNDLE_ACTIVE_LOGI("bundle stat is, totaltime is %{public}lld, lastTimeUsed is %{public}lld" - "total continuous task is %{public}lld, lastTimeContinuousTaskUsed is %{public}lld", + BUNDLE_ACTIVE_LOGI("bundle stat is, totaltime is %{public}" PRId64", lastTimeUsed is %{public}" PRId64 + "total continuous task is %{public}" PRId64", lastTimeContinuousTaskUsed is %{public}" PRId64, totalUsedTime, lastTimeUsed, totalTimeContinuousTaskUsed, lastTimeContinuousTaskUsed); } } @@ -431,7 +433,7 @@ void BundleActiveUserService::PrintInMemEventStats() int eventid = currentStats_[idx]->events_.events_[i].eventId_; int64_t timestamp = currentStats_[idx]->events_.events_[i].timeStamp_; BUNDLE_ACTIVE_LOGI("In mem, event stat is, abilityid is %{public}s, abilityname is %{public}s, " - "bundlename is %{public}s, eventid is %{public}d, timestamp is %{public}lld", + "bundlename is %{public}s, eventid is %{public}d, timestamp is %{public}" PRId64, abilityId.c_str(), abilityname.c_str(), bundlename.c_str(), eventid, timestamp); } } @@ -441,14 +443,15 @@ void BundleActiveUserService::PrintInMemFormStats() for (const auto& oneModule : moduleRecords_) { if (oneModule.second) { BUNDLE_ACTIVE_LOGI("bundle name is %{public}s, module name is %{public}s, " - "lastusedtime is %{public}lld, launchcount is %{public}d", oneModule.second->bundleName_.c_str(), + "lastusedtime is %{public}" PRId64", launchcount is %{public}d", oneModule.second->bundleName_.c_str(), oneModule.second->moduleName_.c_str(), oneModule.second->lastModuleUsedTime_, oneModule.second->launchedCount_); BUNDLE_ACTIVE_LOGI("combined info is %{public}s", oneModule.first.c_str()); for (const auto& oneForm : oneModule.second->formRecords_) { - BUNDLE_ACTIVE_LOGI("form name is %{public}s, form dimension is %{public}d, form id is %{public}lld, " - "lasttouchtime is %{public}lld, touchcount is %{public}d", oneForm.formName_.c_str(), - oneForm.formDimension_, oneForm.formId_, oneForm.formLastUsedTime_, oneForm.count_); + BUNDLE_ACTIVE_LOGI("form name is %{public}s, form dimension is %{public}d, " + "form id is %{public}" PRId64", lasttouchtime is %{public}" PRId64", touchcount is %{public}d", + oneForm.formName_.c_str(), oneForm.formDimension_, oneForm.formId_, oneForm.formLastUsedTime_, + oneForm.count_); } } } -- Gitee From 2ffd771160635ab8100141c49a9650184a2f813c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E5=B0=8F=E5=B8=85?= Date: Mon, 4 Apr 2022 08:41:21 +0800 Subject: [PATCH 2/2] Fix code check. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 贺小帅 Change-Id: I448e233f8eb6882b6de3086e08befef579ae897c --- services/packageusage/src/bundle_active_user_service.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/packageusage/src/bundle_active_user_service.cpp b/services/packageusage/src/bundle_active_user_service.cpp index 34aa97d..009dab8 100755 --- a/services/packageusage/src/bundle_active_user_service.cpp +++ b/services/packageusage/src/bundle_active_user_service.cpp @@ -315,12 +315,10 @@ std::vector BundleActiveUserService::QueryPackageStats return result; } if (currentStats->endTime_ == 0) { - if (beginTime > currentStats->beginTime_ + periodLength_[intervalType]) { - return result; - } else { + if (beginTime <= currentStats->beginTime_ + periodLength_[intervalType]) { result = database_.QueryDatabaseUsageStats(intervalType, beginTime, endTime, userId); - return result; } + return result; } else if (beginTime >= currentStats->endTime_) { return result; } -- Gitee