diff --git a/services/native/include/power_mgr_service.h b/services/native/include/power_mgr_service.h index 0741f57d33f22ef0d39160d81a186be76f7defde..1f938191fbcf62c6de4753e8cc36cc0b9fe10ca0 100644 --- a/services/native/include/power_mgr_service.h +++ b/services/native/include/power_mgr_service.h @@ -150,6 +150,7 @@ public: #endif void HandleKeyEvent(int32_t keyCode); void HandlePointEvent(int32_t type); + void PowerExternalAbilityDeinit(); void KeyMonitorCancel(); void SwitchSubscriberInit(); void SwitchSubscriberCancel(); diff --git a/services/native/src/power_mgr_service.cpp b/services/native/src/power_mgr_service.cpp index f5b3c5638a1f55002ec18a8d6e5be8bec049697a..d17cf1f878f0ce3911e1cc34f5b21383c23f0794 100644 --- a/services/native/src/power_mgr_service.cpp +++ b/services/native/src/power_mgr_service.cpp @@ -173,7 +173,7 @@ void PowerMgrService::RegisterBootCompletedCallback() POWER_HILOGI(COMP_SVC, "plan to RegisterBootCompletedCallback."); g_bootCompletedCallback = []() { std::lock_guard lock(powerInitMutex_); - if (!isNeedReInit_ ) { + if (!isNeedReInit_) { POWER_HILOGW(COMP_SVC, "Power initialization is not required."); return; } @@ -631,20 +631,8 @@ void PowerMgrService::HandlePointEvent(int32_t type) #endif } -void PowerMgrService::OnStop() +void PowerMgrService::PowerExternalAbilityDeinit() { - POWER_HILOGW(COMP_SVC, "Stop service"); - if (!ready_) { - return; - } - powerStateMachine_->CancelDelayTimer(PowerStateMachine::CHECK_USER_ACTIVITY_TIMEOUT_MSG); - powerStateMachine_->CancelDelayTimer(PowerStateMachine::CHECK_USER_ACTIVITY_OFF_TIMEOUT_MSG); - powerStateMachine_->UnregisterDisplayOffTimeObserver(); - if (suspendController_) { - suspendController_->StopSleep(); - } - - SystemSuspendController::GetInstance().UnRegisterPowerHdiCallback(); KeyMonitorCancel(); HallSensorSubscriberCancel(); #ifdef POWER_MANAGER_ENABLE_EXTERNAL_SCREEN_MANAGEMENT @@ -671,6 +659,23 @@ void PowerMgrService::OnStop() #endif SettingHelper::UnRegisterSettingWakeupLidObserver(); SettingHelper::UnRegisterSettingPowerModeObserver(); +} + +void PowerMgrService::OnStop() +{ + POWER_HILOGW(COMP_SVC, "Stop service"); + if (!ready_) { + return; + } + powerStateMachine_->CancelDelayTimer(PowerStateMachine::CHECK_USER_ACTIVITY_TIMEOUT_MSG); + powerStateMachine_->CancelDelayTimer(PowerStateMachine::CHECK_USER_ACTIVITY_OFF_TIMEOUT_MSG); + powerStateMachine_->UnregisterDisplayOffTimeObserver(); + if (suspendController_) { + suspendController_->StopSleep(); + } + + SystemSuspendController::GetInstance().UnRegisterPowerHdiCallback(); + PowerExternalAbilityDeinit(); if (!OHOS::EventFwk::CommonEventManager::UnSubscribeCommonEvent(subscriberPtr_)) { POWER_HILOGE(COMP_SVC, "Power Onstop unregister to commonevent manager failed!"); }