diff --git a/services/common/include/bundle_active_power_state_callback_service.h b/services/common/include/bundle_active_power_state_callback_service.h index 06d933521c6ecbbfb4cd4144df75a2218b22f3a3..ed48265bf5d013c59fb08075eefe8ec750eea8c0 100644 --- a/services/common/include/bundle_active_power_state_callback_service.h +++ b/services/common/include/bundle_active_power_state_callback_service.h @@ -22,11 +22,13 @@ namespace OHOS { namespace DeviceUsageStats { using OHOS::PowerMgr::PowerState; +using OHOS::PowerMgr::StateChangeReason; class BundleActivePowerStateCallbackService : public PowerMgr::PowerStateCallbackStub { public: BundleActivePowerStateCallbackService(std::shared_ptr bundleActiveCore); virtual ~BundleActivePowerStateCallbackService() {} - void OnPowerStateChanged(PowerState state) override; + void OnPowerStateChanged(PowerState state, StateChangeReason __attribute__((unused)) reason) override; + private: std::shared_ptr bundleActiveCore_; }; diff --git a/services/common/src/bundle_active_power_state_callback_service.cpp b/services/common/src/bundle_active_power_state_callback_service.cpp index 77d36f4bdaf79be99fb7329c0a172bccb767d31d..76f496fd9cee3e3d6015e20a6e68449025a4acff 100644 --- a/services/common/src/bundle_active_power_state_callback_service.cpp +++ b/services/common/src/bundle_active_power_state_callback_service.cpp @@ -20,6 +20,7 @@ namespace OHOS { namespace DeviceUsageStats { using OHOS::PowerMgr::PowerState; +using OHOS::PowerMgr::StateChangeReason; BundleActivePowerStateCallbackService::BundleActivePowerStateCallbackService( std::shared_ptr bundleActiveCore) { @@ -28,7 +29,8 @@ BundleActivePowerStateCallbackService::BundleActivePowerStateCallbackService( } } -void BundleActivePowerStateCallbackService::OnPowerStateChanged(PowerState state) +void BundleActivePowerStateCallbackService::OnPowerStateChanged( + PowerState state, StateChangeReason __attribute__((unused)) reason) { int32_t eventId; BUNDLE_ACTIVE_LOGD("BundleActDvePowerStateCallbackService::OnPowerStateChanged power state is %{public}u", state); diff --git a/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer/bundleactivepowerstatecallbackproxy_fuzzer.cpp b/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer/bundleactivepowerstatecallbackproxy_fuzzer.cpp index 0a3488e2e60f9be084842d540d0b8331f2c26152..dba21c2aa54aeaabaa35696376a17fe6626936de 100644 --- a/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer/bundleactivepowerstatecallbackproxy_fuzzer.cpp +++ b/test/fuzztest/bundleactivepowerstatecallbackproxy_fuzzer/bundleactivepowerstatecallbackproxy_fuzzer.cpp @@ -91,7 +91,8 @@ namespace DeviceUsageStats { PowerMgr::PowerState state = static_cast(code); auto bundleActiveCore = std::make_shared(); BundleActivePowerStateCallbackService BundleActivePowerStateCallbackService(bundleActiveCore); - BundleActivePowerStateCallbackService.OnPowerStateChanged(state); + BundleActivePowerStateCallbackService.OnPowerStateChanged( + state, PowerMgr::StateChangeReason::STATE_CHANGE_REASON_APPLICATION); return true; } diff --git a/test/unittest/bundle_active_total_test.cpp b/test/unittest/bundle_active_total_test.cpp index 3f8c01e789a49646a10d05fbd3abb113864192e1..9a0a6c140b4e2067f753c54a19fcd699367c3a18 100644 --- a/test/unittest/bundle_active_total_test.cpp +++ b/test/unittest/bundle_active_total_test.cpp @@ -327,10 +327,10 @@ HWTEST_F(BundleActiveTotalTest, BundleActivePowerStateCallbackServiceTest_001, F std::shared_ptr bundleActiveCore = std::make_shared(); BundleActivePowerStateCallbackService test2(bundleActiveCore); - - test2.OnPowerStateChanged(PowerState::AWAKE); + + test2.OnPowerStateChanged(PowerState::AWAKE, PowerMgr::StateChangeReason::STATE_CHANGE_REASON_APPLICATION); SUCCEED(); - test2.OnPowerStateChanged(PowerState::SLEEP); + test2.OnPowerStateChanged(PowerState::SLEEP, PowerMgr::StateChangeReason::STATE_CHANGE_REASON_APPLICATION); EXPECT_TRUE(test2.bundleActiveCore_ != nullptr); #endif }