介绍
在设置菜单的手势界面里,快速打开相机是默认开启的,此功能当开启时连续点击两次电源键会打开相机,现在客户需要默认关闭。
效果展示
修改
这里一开始想到的就是配置文件,在路径下果然找到了,从注释中看使我们需要的,默认写为false试试,当修改后发现双击确实无法打开相机了,但是这样会导致手势菜单消失,这样我们就暂时不考虑这种改法了。
路径:frameworks/base/core/res/res/values/config.xml
<!-- Allow the gesture to double tap the power button twice to start the camera while the deviceis non-interactive. --><bool name="config_cameraDoubleTapPowerGestureEnabled">true</bool>
接下来我就通过关键字开关属性,发现 settings的secure中有这么一条属性camera_double_tap_power_gesture_disabled当快速打开相机关闭时这条属性值为1,那么我们只需默认这个值为1即可。
路径:frameworks/base/core/java/android/provider/Settings.java
/*** Whether the camera launch gesture to double tap the power button when the screen is off* should be disabled.** @hide*/@Readablepublic static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED ="camera_double_tap_power_gesture_disabled";
路径:vendor/mediatek/proprietary/packages/apps/SettingsProvider/res/values/defaults.xml
<!--soda water.20231229 default close double camera --><integer name="camera_double_disable">1</integer>
在loadSecureSettings中加载这个值读取上面刚刚定义的integer的值
路径:vendor/mediatek/proprietary/packages/apps/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
private void loadSecureSettings(SQLiteDatabase db) {SQLiteStatement stmt = null;try {//...略//*/soda water.20231229 default close double cameraloadIntegerSetting(stmt, Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,R.integer.camera_double_disable);//*/}}