From 8913bd3be4273e74fc1199697534b9c2b00650d4 Mon Sep 17 00:00:00 2001 From: wangyantian Date: Sat, 26 Apr 2025 10:43:39 +0800 Subject: [PATCH 1/2] feat: Revert "feat: Power HDI adds OnWakeupWithTag" This reverts commit cc53bbd2f58dfe9f1602a7559f6c87c4b8de2a9b. Signed-off-by: wangyantian --- services/BUILD.gn | 2 +- services/native/include/power_hdi_callback.h | 6 ++--- services/native/src/actions/default/BUILD.gn | 2 +- .../default/system_suspend_controller.cpp | 23 ++++++------------- .../default/system_suspend_controller.h | 18 ++++++--------- services/native/src/power_hdi_callback.cpp | 7 +----- 6 files changed, 19 insertions(+), 39 deletions(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index 9d879ef0..7fce8270 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -111,7 +111,7 @@ ohos_shared_library("powermgrservice") { "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", - "drivers_interface_power:libpower_proxy_1.3", + "drivers_interface_power:libpower_proxy_1.2", "eventhandler:libeventhandler", "ffrt:libffrt", "graphic_2d:librender_service_base", diff --git a/services/native/include/power_hdi_callback.h b/services/native/include/power_hdi_callback.h index dc4d1eff..ac189da5 100644 --- a/services/native/include/power_hdi_callback.h +++ b/services/native/include/power_hdi_callback.h @@ -17,11 +17,11 @@ #define POWERMGR_POWER_MANAGER_POWER_HDI_CALLBACK_H #include -#include "v1_3/ipower_hdi_callback.h" +#include "v1_2/ipower_hdi_callback.h" namespace OHOS { namespace PowerMgr { -using namespace OHOS::HDI::Power::V1_3; +using namespace OHOS::HDI::Power::V1_2; class PowerHdiCallback : public IPowerHdiCallback { public: virtual ~PowerHdiCallback() {} @@ -29,8 +29,6 @@ public: int32_t OnSuspend() override; int32_t OnWakeup() override; - - int32_t OnWakeupWithTag(int32_t suspendTag) override; }; } // OHOS } // PowerMgr diff --git a/services/native/src/actions/default/BUILD.gn b/services/native/src/actions/default/BUILD.gn index e1ac7e2e..fe640265 100644 --- a/services/native/src/actions/default/BUILD.gn +++ b/services/native/src/actions/default/BUILD.gn @@ -62,7 +62,7 @@ ohos_source_set("${powermgr_actions_default_target}") { external_deps = [ "c_utils:utils", - "drivers_interface_power:libpower_proxy_1.3", + "drivers_interface_power:libpower_proxy_1.2", "ffrt:libffrt", "hdf_core:libhdf_utils", "hdf_core:libhdi", diff --git a/services/native/src/actions/default/system_suspend_controller.cpp b/services/native/src/actions/default/system_suspend_controller.cpp index 7c7d08cf..acbceb7c 100644 --- a/services/native/src/actions/default/system_suspend_controller.cpp +++ b/services/native/src/actions/default/system_suspend_controller.cpp @@ -28,7 +28,7 @@ const std::string HDI_SERVICE_NAME = "power_interface_service"; constexpr uint32_t RETRY_TIME = 1000; constexpr int32_t ERR_FAILED = -1; } // namespace -using namespace OHOS::HDI::Power::V1_3; +using namespace OHOS::HDI::Power::V1_2; SystemSuspendController::SystemSuspendController() {} @@ -193,11 +193,11 @@ bool SystemSuspendController::Hibernate() return true; } -OHOS::HDI::Power::V1_3::RunningLockInfo SystemSuspendController::FillRunningLockInfo(const RunningLockParam& param) +OHOS::HDI::Power::V1_2::RunningLockInfo SystemSuspendController::FillRunningLockInfo(const RunningLockParam& param) { - OHOS::HDI::Power::V1_3::RunningLockInfo filledInfo {}; + OHOS::HDI::Power::V1_2::RunningLockInfo filledInfo {}; filledInfo.name = param.name; - filledInfo.type = static_cast(param.type); + filledInfo.type = static_cast(param.type); filledInfo.timeoutMs = param.timeoutMs; filledInfo.uid = param.uid; filledInfo.pid = param.pid; @@ -212,7 +212,7 @@ int32_t SystemSuspendController::AcquireRunningLock(const RunningLockParam& para POWER_HILOGE(COMP_SVC, "The hdf interface is null"); return status; } - OHOS::HDI::Power::V1_3::RunningLockInfo filledInfo = FillRunningLockInfo(param); + OHOS::HDI::Power::V1_2::RunningLockInfo filledInfo = FillRunningLockInfo(param); status = powerInterface->HoldRunningLockExt(filledInfo, param.lockid, param.bundleName); return status; @@ -226,7 +226,7 @@ int32_t SystemSuspendController::ReleaseRunningLock(const RunningLockParam& para POWER_HILOGE(COMP_SVC, "The hdf interface is null"); return status; } - OHOS::HDI::Power::V1_3::RunningLockInfo filledInfo = FillRunningLockInfo(param); + OHOS::HDI::Power::V1_2::RunningLockInfo filledInfo = FillRunningLockInfo(param); status = powerInterface->UnholdRunningLockExt(filledInfo, param.lockid, param.bundleName); return status; @@ -288,20 +288,11 @@ int32_t SystemSuspendController::PowerHdfCallback::OnWakeup() return 0; } -int32_t SystemSuspendController::PowerHdfCallback::OnWakeupWithTag(int32_t suspendTag) -{ - if (onWakeup_ != nullptr) { - onWakeupWithTag_(suspendTag); - } - return 0; -} - void SystemSuspendController::PowerHdfCallback::SetListener( - std::function& suspend, std::function& wakeup, std::function& onWakeupWithTag) + std::function& suspend, std::function& wakeup) { onSuspend_ = suspend; onWakeup_ = wakeup; - onWakeupWithTag_ = onWakeupWithTag; } } // namespace PowerMgr } // namespace OHOS diff --git a/services/native/src/actions/default/system_suspend_controller.h b/services/native/src/actions/default/system_suspend_controller.h index ae9d4bd2..90da7340 100644 --- a/services/native/src/actions/default/system_suspend_controller.h +++ b/services/native/src/actions/default/system_suspend_controller.h @@ -26,7 +26,7 @@ #include "suspend/irunning_lock_hub.h" #include "suspend/isuspend_controller.h" #include "power_hdi_callback.h" -#include "v1_3/ipower_interface.h" +#include "v1_2/ipower_interface.h" #include "ffrt_utils.h" namespace OHOS { @@ -53,23 +53,19 @@ private: DECLARE_DELAYED_REF_SINGLETON(SystemSuspendController); inline static constexpr const char* WAKEUP_HOLDER = "OHOSPowerMgr.WakeupHolder"; - class PowerHdfCallback : public OHOS::HDI::Power::V1_3::IPowerHdiCallback { + class PowerHdfCallback : public OHOS::HDI::Power::V1_2::IPowerHdiCallback { public: PowerHdfCallback() = default; ~PowerHdfCallback() = default; int32_t OnSuspend() override; int32_t OnWakeup() override; - int32_t OnWakeupWithTag(int32_t suspendTag) override; - void SetListener(std::function& suspend, std::function& wakeup, - std::function& onWakeupWithTag); - + void SetListener(std::function& suspend, std::function& wakeup); private: - std::function onSuspend_ {nullptr}; - std::function onWakeup_ {nullptr}; - std::function onWakeupWithTag_ {nullptr}; + std::function onSuspend_; + std::function onWakeup_; }; - OHOS::HDI::Power::V1_3::RunningLockInfo FillRunningLockInfo(const RunningLockParam& param); - using IPowerInterface = OHOS::HDI::Power::V1_3::IPowerInterface; + OHOS::HDI::Power::V1_2::RunningLockInfo FillRunningLockInfo(const RunningLockParam& param); + using IPowerInterface = OHOS::HDI::Power::V1_2::IPowerInterface; sptr GetPowerInterface(); std::mutex mutex_; std::mutex interfaceMutex_; diff --git a/services/native/src/power_hdi_callback.cpp b/services/native/src/power_hdi_callback.cpp index 9ee64fe9..58418ee9 100644 --- a/services/native/src/power_hdi_callback.cpp +++ b/services/native/src/power_hdi_callback.cpp @@ -17,7 +17,7 @@ #include "hdf_base.h" #include "power_hookmgr.h" -using namespace OHOS::HDI::Power::V1_3; +using namespace OHOS::HDI::Power::V1_2; namespace OHOS { namespace PowerMgr { @@ -30,10 +30,5 @@ int32_t PowerHdiCallback::OnWakeup() { return HDF_SUCCESS; } - -int32_t PowerHdiCallback::OnWakeupWithTag(int32_t suspendTag __attribute__((unused))) -{ - return HDF_SUCCESS; -} } // OHOS } // PowerMgr -- Gitee From e9ac88b3dc231e5fd45dab7edbcf595a4941ed31 Mon Sep 17 00:00:00 2001 From: wangyantian Date: Sat, 26 Apr 2025 10:48:37 +0800 Subject: [PATCH 2/2] feat: add onWakeupWithTag Signed-off-by: wangyantian --- services/native/include/power_hdi_callback.h | 2 ++ .../actions/default/system_suspend_controller.cpp | 13 +++++++++++-- .../src/actions/default/system_suspend_controller.h | 6 +++++- services/native/src/power_hdi_callback.cpp | 6 ++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/services/native/include/power_hdi_callback.h b/services/native/include/power_hdi_callback.h index ac189da5..46a9b937 100644 --- a/services/native/include/power_hdi_callback.h +++ b/services/native/include/power_hdi_callback.h @@ -29,6 +29,8 @@ public: int32_t OnSuspend() override; int32_t OnWakeup() override; + + int32_t OnWakeupWithTag(const std::string& tag) override; }; } // OHOS } // PowerMgr diff --git a/services/native/src/actions/default/system_suspend_controller.cpp b/services/native/src/actions/default/system_suspend_controller.cpp index acbceb7c..3c978d26 100644 --- a/services/native/src/actions/default/system_suspend_controller.cpp +++ b/services/native/src/actions/default/system_suspend_controller.cpp @@ -288,11 +288,20 @@ int32_t SystemSuspendController::PowerHdfCallback::OnWakeup() return 0; } -void SystemSuspendController::PowerHdfCallback::SetListener( - std::function& suspend, std::function& wakeup) +int32_t SystemSuspendController::PowerHdfCallback::OnWakeupWithTag(const std::string& tag) +{ + if (onWakeupWithTag_ != nullptr) { + onWakeupWithTag_(tag); + } + return 0; +} + +void SystemSuspendController::PowerHdfCallback::SetListener(std::function& suspend, + std::function& wakeup, std::function& wakeupWithTag) { onSuspend_ = suspend; onWakeup_ = wakeup; + onWakeupWithTag_ = wakeupWithTag; } } // namespace PowerMgr } // namespace OHOS diff --git a/services/native/src/actions/default/system_suspend_controller.h b/services/native/src/actions/default/system_suspend_controller.h index 90da7340..55cc71a6 100644 --- a/services/native/src/actions/default/system_suspend_controller.h +++ b/services/native/src/actions/default/system_suspend_controller.h @@ -59,10 +59,14 @@ private: ~PowerHdfCallback() = default; int32_t OnSuspend() override; int32_t OnWakeup() override; - void SetListener(std::function& suspend, std::function& wakeup); + int32_t OnWakeupWithTag(const std::string& tag) override; + void SetListener(std::function& suspend, std::function& wakeup, + std::function& wakeupWithTag); + private: std::function onSuspend_; std::function onWakeup_; + std::function onWakeupWithTag_; }; OHOS::HDI::Power::V1_2::RunningLockInfo FillRunningLockInfo(const RunningLockParam& param); using IPowerInterface = OHOS::HDI::Power::V1_2::IPowerInterface; diff --git a/services/native/src/power_hdi_callback.cpp b/services/native/src/power_hdi_callback.cpp index 58418ee9..7136d4fd 100644 --- a/services/native/src/power_hdi_callback.cpp +++ b/services/native/src/power_hdi_callback.cpp @@ -30,5 +30,11 @@ int32_t PowerHdiCallback::OnWakeup() { return HDF_SUCCESS; } + +int32_t PowerHdiCallback::OnWakeupWithTag(const std::string& tag) +{ + (void)tag; + return HDF_SUCCESS; +} } // OHOS } // PowerMgr -- Gitee