From 99c8524f4b7736ad07c3d8dd147ea4e0d0877dc4 Mon Sep 17 00:00:00 2001 From: zxin8218 <7394920+zxin8218@user.noreply.gitee.com> Date: Tue, 19 Aug 2025 17:54:17 +0800 Subject: [PATCH] feat: support for configuring powerkey duration Signed-off-by: zxin8218 <7394920+zxin8218@user.noreply.gitee.com> --- etc/para/powermgr.para | 3 ++- etc/para/powermgr.para.dac | 3 ++- services/native/src/shutdown/shutdown_dialog.cpp | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/etc/para/powermgr.para b/etc/para/powermgr.para index 6097b990..ea6e6944 100644 --- a/etc/para/powermgr.para +++ b/etc/para/powermgr.para @@ -17,4 +17,5 @@ persist.dfx.userclicktime = 0 persist.dfx.shutdownactiontime = 0 persist.dfx.shutdowncompletetime = 0 persist.dfx.eventtype = 0 -const.power.during_call_state_enable = false \ No newline at end of file +const.power.during_call_state_enable = false +const.powerkey.down_duration = 3000 \ No newline at end of file diff --git a/etc/para/powermgr.para.dac b/etc/para/powermgr.para.dac index 017af2ea..5fd0222c 100644 --- a/etc/para/powermgr.para.dac +++ b/etc/para/powermgr.para.dac @@ -17,4 +17,5 @@ persist.dfx.userclicktime = powermgr:powermgr:0776 persist.dfx.shutdownactiontime = powermgr:powermgr:0776 persist.dfx.shutdowncompletetime = powermgr:powermgr:0776 persist.dfx.eventtype = powermgr:powermgr:0776 -const.power.during_call_state_enable = powermgr:powermgr:0444 \ No newline at end of file +const.power.during_call_state_enable = powermgr:powermgr:0444 +const.powerkey.down_duration = powermgr:powermgr:0444 \ No newline at end of file diff --git a/services/native/src/shutdown/shutdown_dialog.cpp b/services/native/src/shutdown/shutdown_dialog.cpp index 8a33c9ca..167ae034 100644 --- a/services/native/src/shutdown/shutdown_dialog.cpp +++ b/services/native/src/shutdown/shutdown_dialog.cpp @@ -35,6 +35,7 @@ #include "power_log.h" #include "power_mgr_service.h" #include "power_vibrator.h" +#include "sysparam.h" #ifdef POWER_MANAGER_ENABLE_BLOCK_LONG_PRESS #include "setting_helper.h" @@ -56,6 +57,7 @@ std::atomic_bool g_longPressShow = false; int32_t g_retryCount = 1; sptr g_remoteObject = nullptr; const std::string DIALOG_CONFIG_PATH = "etc/systemui/poweroff_config.json"; +const std::string KEY_DOWN_DURATION = "const.powerkey.down_duration"; #ifdef POWER_MANAGER_ENABLE_BLOCK_LONG_PRESS const std::string BLOCK_LONG_PRESS = "1"; #endif @@ -84,7 +86,9 @@ void ShutdownDialog::KeyMonitorInit() keyOption->SetPreKeys(preKeys); keyOption->SetFinalKey(KeyEvent::KEYCODE_POWER); keyOption->SetFinalKeyDown(true); - keyOption->SetFinalKeyDownDuration(LONG_PRESS_DELAY_MS); + int32_t downDuration = SysParam::GetIntValue(KEY_DOWN_DURATION, LONG_PRESS_DELAY_MS); + POWER_HILOGI(FEATURE_SHUTDOWN, "Initialize powerkey down duration %{public}d.", downDuration); + keyOption->SetFinalKeyDownDuration(downDuration); auto inputManager = InputManager::GetInstance(); if (!inputManager) { POWER_HILOGE(FEATURE_SHUTDOWN, "KeyMonitorInit inputManager is null"); -- Gitee