From e3e4c17ed9109031770c30c68311279822901181 Mon Sep 17 00:00:00 2001 From: zxf Date: Thu, 17 Jul 2025 23:28:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?number=E8=BD=AC=E5=85=B7=E4=BD=93=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zxf --- ...hos.resourceschedule.usageStatistics.taihe | 84 +++++++------- .../include/bundle_state_idl_common.h | 2 +- .../src/bundle_state_idl_common.cpp | 24 ++-- ....resourceschedule.usageStatistics.impl.cpp | 106 ++++++++---------- 4 files changed, 100 insertions(+), 116 deletions(-) diff --git a/interfaces/kits/bundlestats/taihe/usage_statistics/idl/ohos.resourceschedule.usageStatistics.taihe b/interfaces/kits/bundlestats/taihe/usage_statistics/idl/ohos.resourceschedule.usageStatistics.taihe index 43f8e69..1ad95b9 100644 --- a/interfaces/kits/bundlestats/taihe/usage_statistics/idl/ohos.resourceschedule.usageStatistics.taihe +++ b/interfaces/kits/bundlestats/taihe/usage_statistics/idl/ohos.resourceschedule.usageStatistics.taihe @@ -20,24 +20,24 @@ enum IntervalType: i32 {BY_OPTIMIZED = 0, BY_DAILY = 1, BY_WEEKLY = 2, BY_MONTHL enum GroupType: i32 {ALIVE_GROUP = 10, DAILY_GROUP = 20, FIXED_GROUP = 30, RARE_GROUP = 40, LIMITED_GROUP = 50, NEVER_GROUP = 60} struct BundleStatsInfo { - id: f64; - abilityInFgTotalTime: Optional; - abilityPrevAccessTime: Optional; - abilityPrevSeenTime: Optional; - abilitySeenTotalTime: Optional; + id: i32; + abilityInFgTotalTime: Optional; + abilityPrevAccessTime: Optional; + abilityPrevSeenTime: Optional; + abilitySeenTotalTime: Optional; bundleName: Optional; - fgAbilityAccessTotalTime: Optional; - fgAbilityPrevAccessTime: Optional; - infosBeginTime: Optional; - infosEndTime: Optional; - appIndex: Optional; + fgAbilityAccessTotalTime: Optional; + fgAbilityPrevAccessTime: Optional; + infosBeginTime: Optional; + infosEndTime: Optional; + appIndex: Optional; } struct HapFormInfo { formName: String; - formDimension: f64; - formId: f64; - formLastUsedTime: f64; - count: f64; + formDimension: i32; + formId: i64; + formLastUsedTime: i64; + count: i32; } struct HapModuleInfo { @@ -45,37 +45,37 @@ struct HapModuleInfo { bundleName: String; moduleName: String; abilityName: Optional; - appLabelId: Optional; - labelId: Optional; - descriptionId: Optional; - abilityLableId: Optional; - abilityDescriptionId: Optional; - abilityIconId: Optional; - launchedCount: f64; - lastModuleUsedTime: f64; + appLabelId: Optional; + labelId: Optional; + descriptionId: Optional; + abilityLableId: Optional; + abilityDescriptionId: Optional; + abilityIconId: Optional; + launchedCount: i32; + lastModuleUsedTime: i64; formRecords: Array; } struct DeviceEventStats { name: String; - eventId: f64; - count: f64; + eventId: i32; + count: i32; } struct BundleEvents { - appGroup: Optional; + appGroup: Optional; bundleName: Optional; indexOfLink: Optional; nameOfClass: Optional; - eventOccurredTime: Optional; - eventId: Optional; + eventOccurredTime: Optional; + eventId: Optional; } struct AppGroupCallbackInfo { - appOldGroup: f64; - appNewGroup: f64; - userId: f64; - changeReason: f64; + appOldGroup: i32; + appNewGroup: i32; + userId: i32; + changeReason: i64; bundleName: String; } @@ -87,12 +87,12 @@ function IsIdleStateSync(bundleName: String): bool; @gen_async("queryAppGroup") @gen_promise("queryAppGroup") @overload("queryAppGroupSync") -function QueryAppGroupSync(): f64; +function QueryAppGroupSync(): i32; @gen_async("queryAppGroup") @gen_promise("queryAppGroup") @overload("queryAppGroupSync") -function QueryAppGroupSyncByBundleName(bundleName: String): f64; +function QueryAppGroupSyncByBundleName(bundleName: String): i32; @gen_async("setAppGroup") @gen_promise("setAppGroup") @@ -100,35 +100,35 @@ function SetAppGroupSync(bundleName: String, newGroup: GroupType): void; @gen_async("queryBundleStatsInfos") @gen_promise("queryBundleStatsInfos") -function QueryBundleStatsInfosAsync(beginTime: f64, endTime: f64): @record Map; +function QueryBundleStatsInfosAsync(beginTime: i64, endTime: i64): @record Map; @gen_async("queryAppStatsInfos") @gen_promise("queryAppStatsInfos") -function QueryAppStatsInfosAsync(beginTime: f64, endTime: f64): @record Map>; +function QueryAppStatsInfosAsync(beginTime: i64, endTime: i64): @record Map>; @gen_async("queryLastUseTime") @gen_promise("queryLastUseTime") -function QueryLastUseTimeAsync(appInfos: @record Map>): @record Map>; +function QueryLastUseTimeAsync(appInfos: @record Map>): @record Map>; @gen_async("queryBundleStatsInfoByInterval") @gen_promise("queryBundleStatsInfoByInterval") -function QueryBundleStatsInfoByIntervalAsync(byInterval: IntervalType, beginTime: f64, endTime: f64): Array; +function QueryBundleStatsInfoByIntervalAsync(byInterval: IntervalType, beginTime: i64, endTime: i64): Array; @gen_async("queryBundleEvents") @gen_promise("queryBundleEvents") -function QueryBundleEventsAsync(beginTime: f64, endTime: f64): Array; +function QueryBundleEventsAsync(beginTime: i64, endTime: i64): Array; @gen_async("queryCurrentBundleEvents") @gen_promise("queryCurrentBundleEvents") -function QueryCurrentBundleEventsAsync(beginTime: f64, endTime: f64): Array; +function QueryCurrentBundleEventsAsync(beginTime: i64, endTime: i64): Array; @gen_async("queryDeviceEventStats") @gen_promise("queryDeviceEventStats") -function QueryDeviceEventStatsAsync(beginTime: f64, endTime: f64): Array; +function QueryDeviceEventStatsAsync(beginTime: i64, endTime: i64): Array; @gen_async("queryNotificationEventStats") @gen_promise("queryNotificationEventStats") -function QueryNotificationEventStatsAsync(beginTime: f64, endTime: f64): Array; +function QueryNotificationEventStatsAsync(beginTime: i64, endTime: i64): Array; @gen_async("queryModuleUsageRecords") @gen_promise("queryModuleUsageRecords") @@ -138,7 +138,7 @@ function QueryModuleUsageRecordsAsync(): Array; @gen_async("queryModuleUsageRecords") @gen_promise("queryModuleUsageRecords") @overload("queryModuleUsageRecordsAsync") -function QueryModuleUsageRecordsAsyncByMaxNum(maxNum: f64): Array; +function QueryModuleUsageRecordsAsyncByMaxNum(maxNum: i32): Array; @gen_async("registerAppGroupCallBack") @gen_promise("registerAppGroupCallBack") diff --git a/interfaces/kits/bundlestats/taihe/usage_statistics/include/bundle_state_idl_common.h b/interfaces/kits/bundlestats/taihe/usage_statistics/include/bundle_state_idl_common.h index 1e746cc..38a280c 100644 --- a/interfaces/kits/bundlestats/taihe/usage_statistics/include/bundle_state_idl_common.h +++ b/interfaces/kits/bundlestats/taihe/usage_statistics/include/bundle_state_idl_common.h @@ -33,7 +33,7 @@ public: static void ParseBundleEvents(const BundleActiveEvent& bundleActiveEvent, ::ohos::resourceschedule::usageStatistics::BundleEvents& bundleEvent); static void MergePackageStats(BundleActivePackageStats& left, const BundleActivePackageStats& right); - static void ParseQueryInfosMap(const taihe::map>& appInfos, + static void ParseQueryInfosMap(const taihe::map>& appInfos, std::map>& queryInfos); static taihe::array<::ohos::resourceschedule::usageStatistics::HapFormInfo> ParseformRecords( const std::vector& formRecords); diff --git a/interfaces/kits/bundlestats/taihe/usage_statistics/src/bundle_state_idl_common.cpp b/interfaces/kits/bundlestats/taihe/usage_statistics/src/bundle_state_idl_common.cpp index ba675ed..7e58a69 100644 --- a/interfaces/kits/bundlestats/taihe/usage_statistics/src/bundle_state_idl_common.cpp +++ b/interfaces/kits/bundlestats/taihe/usage_statistics/src/bundle_state_idl_common.cpp @@ -58,11 +58,11 @@ void BundleStateIDLCommon::ParseBundleStatsInfo(const BundleActivePackageStats& bundleStatsInfo.bundleName = taihe::optional(std::in_place, taihe::string(bundleActivePackageStats.bundleName_)); bundleStatsInfo.abilityPrevAccessTime = - taihe::optional(std::in_place, bundleActivePackageStats.lastTimeUsed_); + taihe::optional(std::in_place, bundleActivePackageStats.lastTimeUsed_); bundleStatsInfo.abilityInFgTotalTime = - taihe::optional(std::in_place, bundleActivePackageStats.totalInFrontTime_); + taihe::optional(std::in_place, bundleActivePackageStats.totalInFrontTime_); bundleStatsInfo.appIndex = - taihe::optional(std::in_place, bundleActivePackageStats.appIndex_); + taihe::optional(std::in_place, bundleActivePackageStats.appIndex_); } void BundleStateIDLCommon::ParseBundleEvents(const BundleActiveEvent& bundleActiveEvent, @@ -71,9 +71,9 @@ void BundleStateIDLCommon::ParseBundleEvents(const BundleActiveEvent& bundleActi bundleEvent.bundleName = taihe::optional(std::in_place, taihe::string(bundleActiveEvent.bundleName_)); bundleEvent.eventId = - taihe::optional(std::in_place, bundleActiveEvent.eventId_); + taihe::optional(std::in_place, bundleActiveEvent.eventId_); bundleEvent.eventOccurredTime = - taihe::optional(std::in_place, bundleActiveEvent.timeStamp_); + taihe::optional(std::in_place, bundleActiveEvent.timeStamp_); } void BundleStateIDLCommon::MergePackageStats(BundleActivePackageStats& left, const BundleActivePackageStats& right) @@ -90,13 +90,13 @@ void BundleStateIDLCommon::MergePackageStats(BundleActivePackageStats& left, con left.bundleStartedCount_ += right.bundleStartedCount_; } -void BundleStateIDLCommon::ParseQueryInfosMap(const taihe::map>& appInfos, +void BundleStateIDLCommon::ParseQueryInfosMap(const taihe::map>& appInfos, std::map>& queryInfos) { for (const auto& iter : appInfos) { std::vector appIndexVector; - for (double appIndex : iter.second) { - appIndexVector.push_back(static_cast(appIndex)); + for (int64_t appIndex : iter.second) { + appIndexVector.push_back(appIndex); } queryInfos.emplace(std::string(iter.first.c_str()), appIndexVector); } @@ -108,10 +108,10 @@ array BundleStateIDLCommon::ParseformRecords(const std::vector(formRecord.formDimension_), - .formId = static_cast(formRecord.formId_), - .formLastUsedTime = static_cast(formRecord.formLastUsedTime_), - .count = static_cast(formRecord.count_), + .formDimension = formRecord.formDimension_, + .formId = formRecord.formId_, + .formLastUsedTime = formRecord.formLastUsedTime_, + .count = formRecord.count_, }; HapFormInfoVector.push_back(HapFormInfo); } diff --git a/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp b/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp index 5a31c8f..4913a95 100644 --- a/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp +++ b/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp @@ -116,7 +116,7 @@ bool IsIdleStateSync(string bundleName) return isBundleIdle; } -double QueryAppGroupSync() +int32_t QueryAppGroupSync() { int32_t appGroup = 0; std::string bundleName = ""; @@ -125,7 +125,7 @@ double QueryAppGroupSync() set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return static_cast(DeviceUsageStats::GroupType::NEVER_GROUP); } - return static_cast(appGroup); + return appGroup; } int32_t QueryAppGroupSyncByBundleName(string bundleName) @@ -136,32 +136,29 @@ int32_t QueryAppGroupSyncByBundleName(string bundleName) set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return static_cast(DeviceUsageStats::GroupType::NEVER_GROUP); } - return static_cast(appGroup); + return appGroup; } -void SetAppGroupSync(string bundleName, double newGroup) +void SetAppGroupSync(string bundleName, int32_t newGroup) { - int32_t intNewGroup = static_cast(newGroup); - if (!CheckNewGroupType(intNewGroup)) { + if (!CheckNewGroupType(newGroup)) { return; } - int32_t errCode = BundleActiveClient::GetInstance().SetAppGroup(std::string(bundleName.c_str()), intNewGroup); + int32_t errCode = BundleActiveClient::GetInstance().SetAppGroup(std::string(bundleName.c_str()), newGroup); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return; } } -map QueryBundleStatsInfosAsync(double beginTime, double endTime) +map QueryBundleStatsInfosAsync(int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); map bundleStatsInfoMap; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return bundleStatsInfoMap; } int32_t errCode = 0; - auto packageStatsMap = BundleStateIDLCommon::QueryBundleStatsInfos(intBeginTime, intEndTime, errCode); + auto packageStatsMap = BundleStateIDLCommon::QueryBundleStatsInfos(beginTime, endTime, errCode); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return bundleStatsInfoMap; @@ -182,17 +179,15 @@ map QueryBundleStatsInfosAsync(double beginTime, double return bundleStatsInfoMap; } -map> QueryAppStatsInfosAsync(double beginTime, double endTime) +map> QueryAppStatsInfosAsync(int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); map> appStatsInfosMap; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return appStatsInfosMap; } int32_t errCode = 0; std::shared_ptr>> appStatsMap = nullptr; - appStatsMap = BundleStateIDLCommon::QueryAppStatsInfos(intBeginTime, intEndTime, errCode); + appStatsMap = BundleStateIDLCommon::QueryAppStatsInfos(beginTime, endTime, errCode); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return appStatsInfosMap; @@ -206,7 +201,7 @@ map> QueryAppStatsInfosAsync(double beginTime, do std::vector packageStatsVector; for (auto packageStats: iter.second) { BundleStatsInfo bundleStatsInfo { - .id = static_cast(packageStats.userId_), + .id = packageStats.userId_, }; BundleStateIDLCommon::ParseBundleStatsInfo(packageStats, bundleStatsInfo); packageStatsVector.push_back(bundleStatsInfo); @@ -217,7 +212,7 @@ map> QueryAppStatsInfosAsync(double beginTime, do return appStatsInfosMap; } -map> QueryLastUseTimeAsync(map> appInfos) +map> QueryLastUseTimeAsync(map> appInfos) { map> appStatsInfosMap; std::map> queryInfos; @@ -238,7 +233,7 @@ map> QueryLastUseTimeAsync(map packageStatsVector; for (auto packageStats: iter.second) { BundleStatsInfo bundleStatsInfo { - .id = static_cast(packageStats.userId_), + .id = packageStats.userId_, }; BundleStateIDLCommon::ParseBundleStatsInfo(packageStats, bundleStatsInfo); packageStatsVector.push_back(bundleStatsInfo); @@ -250,12 +245,10 @@ map> QueryLastUseTimeAsync(map QueryBundleStatsInfoByIntervalAsync( - ::ohos::resourceschedule::usageStatistics::IntervalType byInterval, double beginTime, double endTime) + ::ohos::resourceschedule::usageStatistics::IntervalType byInterval, int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); std::vector bundleStatsInfoVector; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return array(bundleStatsInfoVector); } int32_t interval = static_cast(byInterval); @@ -264,7 +257,7 @@ array QueryBundleStatsInfoByIntervalAsync( } std::vector bundleActivePackageStats; int32_t errCode = BundleActiveClient::GetInstance().QueryBundleStatsInfoByInterval(bundleActivePackageStats, - interval, intBeginTime, intEndTime); + interval, beginTime, endTime); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return array(bundleStatsInfoVector); @@ -279,17 +272,15 @@ array QueryBundleStatsInfoByIntervalAsync( return array(bundleStatsInfoVector); } -array QueryBundleEventsAsync(double beginTime, double endTime) +array QueryBundleEventsAsync(int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); std::vector bundleEventVector; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return array(bundleEventVector); } std::vector bundleActiveEvents; int32_t errCode = BundleActiveClient::GetInstance().QueryBundleEvents(bundleActiveEvents, - intBeginTime, intEndTime); + beginTime, endTime); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return array(bundleEventVector); @@ -302,17 +293,15 @@ array QueryBundleEventsAsync(double beginTime, double endTime) return array(bundleEventVector); } -array QueryCurrentBundleEventsAsync(double beginTime, double endTime) +array QueryCurrentBundleEventsAsync(int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); std::vector bundleEventVector; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return array(bundleEventVector); } std::vector bundleActiveEvents; int32_t errCode = BundleActiveClient::GetInstance().QueryCurrentBundleEvents(bundleActiveEvents, - intBeginTime, intEndTime); + beginTime, endTime); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return array(bundleEventVector); @@ -325,16 +314,14 @@ array QueryCurrentBundleEventsAsync(double beginTime, double endTi return array(bundleEventVector); } -array QueryDeviceEventStatsAsync(double beginTime, double endTime) +array QueryDeviceEventStatsAsync(int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); std::vector deviceEventStatsVector; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return array(deviceEventStatsVector); } std::vector bundleActiveEventStatsVector; - int32_t errCode = BundleActiveClient::GetInstance().QueryDeviceEventStats(intBeginTime, intEndTime, + int32_t errCode = BundleActiveClient::GetInstance().QueryDeviceEventStats(beginTime, endTime, bundleActiveEventStatsVector); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); @@ -343,25 +330,23 @@ array QueryDeviceEventStatsAsync(double beginTime, double endT for (auto &bundleActiveEventStats: bundleActiveEventStatsVector) { DeviceEventStats deviceEventStats { .name = bundleActiveEventStats.name_, - .eventId = static_cast(bundleActiveEventStats.eventId_), - .count = static_cast(bundleActiveEventStats.count_), + .eventId = bundleActiveEventStats.eventId_, + .count = bundleActiveEventStats.count_, }; deviceEventStatsVector.push_back(deviceEventStats); } return array(deviceEventStatsVector); } -array QueryNotificationEventStatsAsync(double beginTime, double endTime) +array QueryNotificationEventStatsAsync(int64_t beginTime, int64_t endTime) { - int64_t intBeginTime = static_cast(beginTime); - int64_t intEndTime = static_cast(endTime); std::vector deviceEventStatsVector; - if (!CheckBeginTimeAndEndTime(intBeginTime, intEndTime)) { + if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return array(deviceEventStatsVector); } std::vector bundleActiveEventStatsVector; - int32_t errCode = BundleActiveClient::GetInstance().QueryNotificationEventStats(intBeginTime, intEndTime, + int32_t errCode = BundleActiveClient::GetInstance().QueryNotificationEventStats(beginTime, endTime, bundleActiveEventStatsVector); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); @@ -370,8 +355,8 @@ array QueryNotificationEventStatsAsync(double beginTime, doubl for (auto &bundleActiveEventStats: bundleActiveEventStatsVector) { DeviceEventStats deviceEventStats { .name = bundleActiveEventStats.name_, - .eventId = static_cast(bundleActiveEventStats.eventId_), - .count = static_cast(bundleActiveEventStats.count_), + .eventId = bundleActiveEventStats.eventId_, + .count = bundleActiveEventStats.count_, }; deviceEventStatsVector.push_back(deviceEventStats); } @@ -392,8 +377,8 @@ array QueryModuleUsageRecordsAsync() HapModuleInfo hapModuleInfo { .bundleName = moduleRecord.bundleName_, .moduleName = moduleRecord.moduleName_, - .launchedCount = static_cast(moduleRecord.launchedCount_), - .lastModuleUsedTime = static_cast(moduleRecord.lastModuleUsedTime_), + .launchedCount = moduleRecord.launchedCount_, + .lastModuleUsedTime = moduleRecord.lastModuleUsedTime_, .formRecords = hapFromInfos, }; hapModuleInfos.emplace_back(hapModuleInfo); @@ -401,15 +386,14 @@ array QueryModuleUsageRecordsAsync() return array(hapModuleInfos); } -array QueryModuleUsageRecordsAsyncByMaxNum(double maxNum) +array QueryModuleUsageRecordsAsyncByMaxNum(int32_t maxNum) { - int32_t intMaxNum = static_cast(maxNum); std::vector hapModuleInfos; - if (!CheckMaxNum(intMaxNum)) { + if (!CheckMaxNum(maxNum)) { return array(hapModuleInfos); } std::vector moduleRecords; - int32_t errCode = BundleActiveClient::GetInstance().QueryModuleUsageRecords(intMaxNum, moduleRecords); + int32_t errCode = BundleActiveClient::GetInstance().QueryModuleUsageRecords(maxNum, moduleRecords); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return array(hapModuleInfos); @@ -419,8 +403,8 @@ array QueryModuleUsageRecordsAsyncByMaxNum(double maxNum) HapModuleInfo hapModuleInfo { .bundleName = moduleRecord.bundleName_, .moduleName = moduleRecord.moduleName_, - .launchedCount = static_cast(moduleRecord.launchedCount_), - .lastModuleUsedTime = static_cast(moduleRecord.lastModuleUsedTime_), + .launchedCount = moduleRecord.launchedCount_, + .lastModuleUsedTime = moduleRecord.lastModuleUsedTime_, .formRecords = hapFromInfos, }; hapModuleInfos.emplace_back(hapModuleInfo); @@ -432,10 +416,10 @@ ErrCode GroupChangeObserver::OnAppGroupChanged(const DeviceUsageStats::AppGroupC { std::lock_guard autoLock(GroupChangeObserver::callbackMutex_); ohos::resourceschedule::usageStatistics::AppGroupCallbackInfo innerGroupInfo { - .appOldGroup = static_cast(appGroupCallbackInfo.GetOldGroup()), - .appNewGroup = static_cast(appGroupCallbackInfo.GetNewGroup()), - .userId = static_cast(appGroupCallbackInfo.GetUserId()), - .changeReason = static_cast(appGroupCallbackInfo.GetChangeReason()), + .appOldGroup = appGroupCallbackInfo.GetOldGroup(), + .appNewGroup = appGroupCallbackInfo.GetNewGroup(), + .userId = appGroupCallbackInfo.GetUserId(), + .changeReason = static_cast(appGroupCallbackInfo.GetChangeReason()), .bundleName = appGroupCallbackInfo.GetBundleName(), }; if (innerCallback_ != nullptr) { -- Gitee From 8228b62eab022da7f8fd8ff98a4ca322a7592061 Mon Sep 17 00:00:00 2001 From: zxf Date: Sat, 19 Jul 2025 09:51:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?number=E8=BD=AC=E5=85=B7=E4=BD=93=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zxf --- .../src/ohos.resourceschedule.usageStatistics.impl.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp b/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp index 4913a95..e4cce1b 100644 --- a/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp +++ b/interfaces/kits/bundlestats/taihe/usage_statistics/src/ohos.resourceschedule.usageStatistics.impl.cpp @@ -123,7 +123,7 @@ int32_t QueryAppGroupSync() int32_t errCode = BundleActiveClient::GetInstance().QueryAppGroup(appGroup, bundleName); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); - return static_cast(DeviceUsageStats::GroupType::NEVER_GROUP); + return DeviceUsageStats::GroupType::NEVER_GROUP; } return appGroup; } @@ -134,7 +134,7 @@ int32_t QueryAppGroupSyncByBundleName(string bundleName) int32_t errCode = BundleActiveClient::GetInstance().QueryAppGroup(appGroup, std::string(bundleName.c_str())); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); - return static_cast(DeviceUsageStats::GroupType::NEVER_GROUP); + return DeviceUsageStats::GroupType::NEVER_GROUP; } return appGroup; } @@ -251,13 +251,12 @@ array QueryBundleStatsInfoByIntervalAsync( if (!CheckBeginTimeAndEndTime(beginTime, endTime)) { return array(bundleStatsInfoVector); } - int32_t interval = static_cast(byInterval); - if (!CheckInterval(interval)) { + if (!CheckInterval(byInterval)) { return array(bundleStatsInfoVector); } std::vector bundleActivePackageStats; int32_t errCode = BundleActiveClient::GetInstance().QueryBundleStatsInfoByInterval(bundleActivePackageStats, - interval, beginTime, endTime); + byInterval, beginTime, endTime); if (errCode != ERR_OK) { set_business_error(errCode, BundleStateIDLErrCode::GetErrorCode(errCode)); return array(bundleStatsInfoVector); -- Gitee