From 73c31dca6bb4942c54ae8741513de9b392e01f67 Mon Sep 17 00:00:00 2001 From: chenxiaobaobb <2664761650@qq.com> Date: Fri, 6 Jun 2025 03:30:39 +0000 Subject: [PATCH 1/2] fix: optimize power read datashare Signed-off-by: chenxiaobaobb <2664761650@qq.com> --- services/native/src/power_mgr_service.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/native/src/power_mgr_service.cpp b/services/native/src/power_mgr_service.cpp index f5b3c563..2966a734 100644 --- a/services/native/src/power_mgr_service.cpp +++ b/services/native/src/power_mgr_service.cpp @@ -118,7 +118,6 @@ void PowerMgrService::OnStart() AddSystemAbilityListener(SUSPEND_MANAGER_SYSTEM_ABILITY_ID); AddSystemAbilityListener(DEVICE_STANDBY_SERVICE_SYSTEM_ABILITY_ID); AddSystemAbilityListener(DISPLAY_MANAGER_SERVICE_ID); - AddSystemAbilityListener(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID); AddSystemAbilityListener(DISPLAY_MANAGER_SERVICE_SA_ID); #ifdef MSDP_MOVEMENT_ENABLE AddSystemAbilityListener(MSDP_MOVEMENT_SERVICE_ID); @@ -247,6 +246,10 @@ void PowerMgrService::PowerExternalAbilityInit() void PowerMgrService::RegisterSettingPowerModeObservers() { + auto power = DelayedSpSingleton::GetInstance(); + if (DelayedSpSingleton::GetInstance()) { + power->GetPowerModeModule().InitPowerMode(); + } SettingObserver::UpdateFunc updateFunc = [&](const std::string &key) { PowerModeSettingUpdateFunc(key); }; SettingHelper::RegisterSettingPowerModeObserver(updateFunc); } @@ -732,11 +735,6 @@ void PowerMgrService::OnAddSystemAbility(int32_t systemAbilityId, const std::str { POWER_HILOGI(COMP_SVC, "systemAbilityId=%{public}d, deviceId=%{private}s Add", systemAbilityId, deviceId.c_str()); - if (systemAbilityId == DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID) { - if (DelayedSpSingleton::GetInstance()) { - this->GetPowerModeModule().InitPowerMode(); - } - } if (systemAbilityId == DISPLAY_MANAGER_SERVICE_ID) { std::lock_guard lock(powerInitMutex_); POWER_HILOGI(COMP_SVC, "get DISPLAY_MANAGER_SERVICE_ID in PowerService"); -- Gitee From d50497d9f9feeb42d1fa0e87472174561a9d4cd2 Mon Sep 17 00:00:00 2001 From: chenxiaobaobb <2664761650@qq.com> Date: Fri, 6 Jun 2025 03:40:48 +0000 Subject: [PATCH 2/2] fix: optimize power read datashare Signed-off-by: chenxiaobaobb <2664761650@qq.com> --- services/native/src/power_mode_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/native/src/power_mode_module.cpp b/services/native/src/power_mode_module.cpp index 8fe5e67a..3b236f3b 100644 --- a/services/native/src/power_mode_module.cpp +++ b/services/native/src/power_mode_module.cpp @@ -247,7 +247,7 @@ void PowerModeModule::EnableMode(PowerMode mode, bool isBoot) /* Set action */ RunAction(isBoot); - /* Save power mode status to setting data*/ + /* Save power mode status to setting data */ SettingHelper::SaveCurrentMode(static_cast(mode)); this->lastMode_ = static_cast(mode); -- Gitee