From fa9f3dd9f76687f55e512da6018181a51e2526cd Mon Sep 17 00:00:00 2001 From: zxin8218 <7394920+zxin8218@user.noreply.gitee.com> Date: Tue, 19 Aug 2025 16:10:05 +0800 Subject: [PATCH 1/2] feat: support for configuring powerkey duration --- 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 From 4ccaf14fd4dd74ec7dbe35a1b1aafbf72385cd3f Mon Sep 17 00:00:00 2001 From: zxin8218 <15929048406@163.com> Date: Tue, 19 Aug 2025 09:03:06 +0000 Subject: [PATCH 2/2] Revert "feat: support for configuring powerkey duration" This reverts commit fa9f3dd9f76687f55e512da6018181a51e2526cd. --- etc/para/powermgr.para | 3 +-- etc/para/powermgr.para.dac | 3 +-- services/native/src/shutdown/shutdown_dialog.cpp | 6 +----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/etc/para/powermgr.para b/etc/para/powermgr.para index ea6e6944..6097b990 100644 --- a/etc/para/powermgr.para +++ b/etc/para/powermgr.para @@ -17,5 +17,4 @@ persist.dfx.userclicktime = 0 persist.dfx.shutdownactiontime = 0 persist.dfx.shutdowncompletetime = 0 persist.dfx.eventtype = 0 -const.power.during_call_state_enable = false -const.powerkey.down_duration = 3000 \ No newline at end of file +const.power.during_call_state_enable = false \ No newline at end of file diff --git a/etc/para/powermgr.para.dac b/etc/para/powermgr.para.dac index 5fd0222c..017af2ea 100644 --- a/etc/para/powermgr.para.dac +++ b/etc/para/powermgr.para.dac @@ -17,5 +17,4 @@ 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 -const.powerkey.down_duration = powermgr:powermgr:0444 \ No newline at end of file +const.power.during_call_state_enable = 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 167ae034..8a33c9ca 100644 --- a/services/native/src/shutdown/shutdown_dialog.cpp +++ b/services/native/src/shutdown/shutdown_dialog.cpp @@ -35,7 +35,6 @@ #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" @@ -57,7 +56,6 @@ 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 @@ -86,9 +84,7 @@ void ShutdownDialog::KeyMonitorInit() keyOption->SetPreKeys(preKeys); keyOption->SetFinalKey(KeyEvent::KEYCODE_POWER); keyOption->SetFinalKeyDown(true); - 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); + keyOption->SetFinalKeyDownDuration(LONG_PRESS_DELAY_MS); auto inputManager = InputManager::GetInstance(); if (!inputManager) { POWER_HILOGE(FEATURE_SHUTDOWN, "KeyMonitorInit inputManager is null"); -- Gitee