From b8f32e6a96bc58e8bc816ff521c051ca6916ea47 Mon Sep 17 00:00:00 2001 From: yanxuejun12 Date: Fri, 11 Jul 2025 09:38:15 +0800 Subject: [PATCH] fix: improve Hibernate Signed-off-by: yanxuejun12 --- services/native/src/power_mgr_service.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/native/src/power_mgr_service.cpp b/services/native/src/power_mgr_service.cpp index 002f82a1..ae310095 100644 --- a/services/native/src/power_mgr_service.cpp +++ b/services/native/src/power_mgr_service.cpp @@ -1275,6 +1275,11 @@ PowerErrors PowerMgrService::Hibernate(bool clearMemory, const std::string& reas POWER_HILOGI(FEATURE_SUSPEND, "System is shutting down, can't hibernate"); return PowerErrors::ERR_FAILURE; } + if (started_) { + POWER_HILOGI(FEATURE_SUSPEND, "System is hibernating, can't hibernate"); + return PowerErrors::ERR_FAILURE; + } + started_ = true; POWER_HILOGI(FEATURE_SUSPEND, "[UL_POWER] Try to hibernate, pid: %{public}d, uid: %{public}d, clearMemory: %{public}d, reason: %{public}s", pid, uid, static_cast(clearMemory), reason.c_str()); -- Gitee