Android12修改关机菜单按键触发方式
Android12 默认的关机菜单触发方式是 同时按电源键
和音量+
,可以通过如下方式修改为长按电源键
触发。
Android的frameworks/base/core/res/res/values/config.xml中可以配置关机菜单的按键触发方式,通过overlay的方式替换framework下面的config相关配置。可以在device下面的产品目录中的overlay目录对应的config.xml中添加要配置的项,如下:
以RK3588的产品为例:
device/rockchip/rk3588
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -152,5 +152,22 @@
2: gestures only for back, home and overview -->
<integer name="config_navBarInteractionMode">0</integer>
<bool name="config_swipe_up_gesture_setting_available">true</bool>
+
+ <!-- Control the behavior when the user long presses the power button.
+ 0 - Nothing
+ 1 - Global actions menu
+ 2 - Power off (with confirmation)
+ 3 - Power off (without confirmation)
+ 4 - Go to voice assist
+ 5 - Go to assistant (Settings.Secure.ASSISTANT)
+ -->
+ <integer name="config_longPressOnPowerBehavior">1</integer>
+
+ <!-- Control the behavior when the user presses the power and volume up buttons together.
+ 0 - Nothing
+ 1 - Mute toggle
+ 2 - Global actions menu
+ -->
+ <integer name="config_keyChordPowerVolumeUp">1</integer>
</resources>
改完重新编译android即可,烧写的时候需要烧misc.img做一下数据恢复才能生效。