Fixes GestureLauncherService triggering on long press.
This change modifies the logic in GestureLauncherService which handles
key down events on the power key so that it ignores events associated
with a long press. This prevents the camera from being launched when
a long press occurs within the double-tap threshold, such as when it's
generated by ADB.
Test: atest GestureLauncherServiceTest
Change-Id: I174c338ec3f46cf338ad417bfc551729e4ecd516
Fixes: 116697919
diff --git a/services/core/java/com/android/server/GestureLauncherService.java b/services/core/java/com/android/server/GestureLauncherService.java
index b7b5bd9..8077e34 100644
--- a/services/core/java/com/android/server/GestureLauncherService.java
+++ b/services/core/java/com/android/server/GestureLauncherService.java
@@ -356,6 +356,12 @@
public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive,
MutableBoolean outLaunched) {
+ if (event.isLongPress()) {
+ // Long presses are sent as a second key down. If the long press threshold is set lower
+ // than the double tap of sequence interval thresholds, this could cause false double
+ // taps or consecutive taps, so we want to ignore the long press event.
+ return false;
+ }
boolean launched = false;
boolean intercept = false;
long powerTapInterval;