Make default minimum emergency gesture duration configurable
This is so that devices can configure the default duration
during build time.
Bug: 333652190
Test: manual, presubmit
Change-Id: I6f60a67b7013d59611d3af92a90840bbf9a848e9
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 2115f64..a622d36 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -7015,4 +7015,9 @@
<!-- Frame rate compatibility value for Wallpaper
FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
<integer name="config_wallpaperFrameRateCompatibility">102</integer>
+
+ <!-- Min time in milliseconds to complete an emergency gesture for it count.
+ If the gesture is completed faster than this, we assume it's not performed by human and the
+ event gets ignored. -->
+ <integer name="config_defaultMinEmergencyGestureTapDurationMillis">200</integer>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 9e09540..eccd7bf 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -5401,4 +5401,6 @@
<!-- Frame rate compatibility value for Wallpaper -->
<java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />
+
+ <java-symbol type="integer" name="config_defaultMinEmergencyGestureTapDurationMillis" />
</resources>
diff --git a/services/core/java/com/android/server/GestureLauncherService.java b/services/core/java/com/android/server/GestureLauncherService.java
index 1741593..ccc44a4 100644
--- a/services/core/java/com/android/server/GestureLauncherService.java
+++ b/services/core/java/com/android/server/GestureLauncherService.java
@@ -16,6 +16,8 @@
package com.android.server;
+import static com.android.internal.R.integer.config_defaultMinEmergencyGestureTapDurationMillis;
+
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
@@ -70,12 +72,6 @@
*/
@VisibleForTesting static final long CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS = 300;
- /**
- * Min time in milliseconds to complete the emergency gesture for it count. If the gesture is
- * completed faster than this, we assume it's not performed by human and the
- * event gets ignored.
- */
- @VisibleForTesting static final int EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS = 200;
/**
* Interval in milliseconds in which the power button must be depressed in succession to be
@@ -570,7 +566,8 @@
long emergencyGestureTapDetectionMinTimeMs = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS,
- EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS);
+ mContext.getResources().getInteger(
+ config_defaultMinEmergencyGestureTapDurationMillis));
if (emergencyGestureSpentTime <= emergencyGestureTapDetectionMinTimeMs) {
Slog.i(TAG, "Emergency gesture detected but it's too fast. Gesture time: "
+ emergencyGestureSpentTime + " ms");
diff --git a/services/tests/servicestests/src/com/android/server/GestureLauncherServiceTest.java b/services/tests/servicestests/src/com/android/server/GestureLauncherServiceTest.java
index 4e059b4..fe883e4 100644
--- a/services/tests/servicestests/src/com/android/server/GestureLauncherServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/GestureLauncherServiceTest.java
@@ -17,7 +17,6 @@
package com.android.server;
import static com.android.server.GestureLauncherService.CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS;
-import static com.android.server.GestureLauncherService.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -1449,7 +1448,7 @@
long emergencyGestureTapDetectionMinTimeMs = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS,
- EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS);
+ 200);
assertTrue(intercepted);
if (tapIntervalMs * 4 > emergencyGestureTapDetectionMinTimeMs) {
assertTrue(outLaunched.value);