diff --git a/interfaces/innerkits/src/bundle_active_client.cpp b/interfaces/innerkits/src/bundle_active_client.cpp index 1487c37189ec9db6d240c7eeae594ec3aeb2d7b9..6a3f2825d13dc2a118819baddcd9be9b33ef3a45 100644 --- a/interfaces/innerkits/src/bundle_active_client.cpp +++ b/interfaces/innerkits/src/bundle_active_client.cpp @@ -27,19 +27,19 @@ BundleActiveClient& BundleActiveClient::GetInstance() bool BundleActiveClient::GetBundleActiveProxy() { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { + if (!samgr) { BUNDLE_ACTIVE_LOGE("Failed to get SystemAbilityManager."); return false; } sptr object = samgr->GetSystemAbility(DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID); - if (object == nullptr) { + if (!object) { BUNDLE_ACTIVE_LOGE("Failed to get SystemAbility[1920] ."); return false; } bundleActiveProxy_ = iface_cast(object); - if (bundleActiveProxy_ == nullptr) { + if (!bundleActiveProxy_) { BUNDLE_ACTIVE_LOGE("Failed to get BundleActiveClient."); return false; } diff --git a/services/common/src/bundle_active_binary_search.cpp b/services/common/src/bundle_active_binary_search.cpp index f16cf9348a07a1511d11350ca056d0064d28dc03..28ce0202dfafcef10071dd58de3b860e0dfafd72 100644 --- a/services/common/src/bundle_active_binary_search.cpp +++ b/services/common/src/bundle_active_binary_search.cpp @@ -30,8 +30,9 @@ int32_t BundleActiveBinarySearch::BinarySearch(const std::vector &table { int32_t low = 0; int32_t high = static_cast(tableNameArray.size() - 1); + int32_t divider = 2; while (low <= high) { - int32_t mid = (low + high) >> 1; + int32_t mid = (low + high) / divider; int64_t midValue = tableNameArray.at(mid); if (midValue < targetValue) { low = mid + 1; diff --git a/services/common/src/bundle_active_service.cpp b/services/common/src/bundle_active_service.cpp index 09eb93dc2f320b20b0c07cbba75066646051f830..7853b3b8eb696d48c2dc530586294f2af586feb8 100644 --- a/services/common/src/bundle_active_service.cpp +++ b/services/common/src/bundle_active_service.cpp @@ -100,7 +100,7 @@ void BundleActiveService::InitNecessaryState() } try { shutdownCallback_ = new BundleActiveShutdownCallbackService(bundleActiveCore_); - } catch(const std::bad_alloc &e) { + } catch (const std::bad_alloc &e) { BUNDLE_ACTIVE_LOGE("Memory allocation failed"); return; } diff --git a/services/packagegroup/include/bundle_active_group_controller.h b/services/packagegroup/include/bundle_active_group_controller.h index 67632020262716fde8046e027b883beb1963e9f4..a5d57b30547468fc696ae7ca058247d0457d44f0 100644 --- a/services/packagegroup/include/bundle_active_group_controller.h +++ b/services/packagegroup/include/bundle_active_group_controller.h @@ -94,7 +94,7 @@ private: int64_t timeoutForDirectlyUse_ = debug_ ? THREE_MINUTE : ONE_HOUR; int64_t timeoutForNotifySeen_ = debug_ ? ONE_MINUTE : TWELVE_HOUR; int64_t timeoutForSystemInteraction_ = debug_ ? ONE_MINUTE : TEN_MINUTE; - int64_t timeoutCalculated_; + int64_t timeoutCalculated_ = 0; sptr sptrBundleMgr_; bool calculationTimeOut(const std::shared_ptr& oneBundleHistory, const int64_t bootBasedTimeStamp); diff --git a/services/packagegroup/src/bundle_active_group_controller.cpp b/services/packagegroup/src/bundle_active_group_controller.cpp index 519311f47333923321dccdb69892355d83bf9704..82062ab89e37be10c7c2fe63a66c62de4204bb15 100644 --- a/services/packagegroup/src/bundle_active_group_controller.cpp +++ b/services/packagegroup/src/bundle_active_group_controller.cpp @@ -221,7 +221,7 @@ void BundleActiveGroupController::ReportEvent(const BundleActiveEvent& event, co return; } int64_t timeUntilNextCheck; - int eventReason = EventToGroupReason(eventId); + uint32_t eventReason = EventToGroupReason(eventId); switch (eventId) { case BundleActiveEvent::NOTIFICATION_SEEN: bundleUserHistory_->ReportUsage(bundleUsageHistory, event.bundleName_, ACTIVE_GROUP_DAILY, diff --git a/services/packagegroup/src/bundle_active_user_history.cpp b/services/packagegroup/src/bundle_active_user_history.cpp index 5179f8fec2590dc021ce82c4e28b6f5572643ddf..5055d7c98215092d044b26f98b7b933bd01285f5 100644 --- a/services/packagegroup/src/bundle_active_user_history.cpp +++ b/services/packagegroup/src/bundle_active_user_history.cpp @@ -31,6 +31,7 @@ BundleActivePackageHistory::BundleActivePackageHistory() reasonInGroup_ = DeviceUsageStatsGroupConst::GROUP_CONTROL_REASON_DEFAULT; bundleAliveTimeoutTimeStamp_ = 0; bundleDailyTimeoutTimeStamp_ = 0; + lastCalculatedGroup_ = ACTIVE_GROUP_NEVER; }; void BundleActiveUserHistory::WriteDeviceDuration() diff --git a/services/packageusage/src/bundle_active_event_stats.cpp b/services/packageusage/src/bundle_active_event_stats.cpp index 4dfa187ada9a155923a4604cf46893cf64c21095..3bb55e0e93c99d38715f263ca575abdf1d4f79db 100644 --- a/services/packageusage/src/bundle_active_event_stats.cpp +++ b/services/packageusage/src/bundle_active_event_stats.cpp @@ -19,6 +19,7 @@ namespace OHOS { namespace DeviceUsageStats { BundleActiveEventStats::BundleActiveEventStats() { + eventId_ = 0; beginTimeStamp_ = 0; endTimeStamp_ = 0; lastEventTime_ = 0;