Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 156c2734 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

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
parent 4fb0875e
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -7015,4 +7015,9 @@
    <!-- Frame rate compatibility value for Wallpaper
    <!-- Frame rate compatibility value for Wallpaper
         FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
         FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
    <integer name="config_wallpaperFrameRateCompatibility">102</integer>
    <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>
</resources>
+2 −0
Original line number Original line Diff line number Diff line
@@ -5401,4 +5401,6 @@


  <!-- Frame rate compatibility value for Wallpaper -->
  <!-- Frame rate compatibility value for Wallpaper -->
  <java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />
  <java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />

  <java-symbol type="integer" name="config_defaultMinEmergencyGestureTapDurationMillis" />
</resources>
</resources>
+4 −7
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.server;
package com.android.server;


import static com.android.internal.R.integer.config_defaultMinEmergencyGestureTapDurationMillis;

import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
@@ -70,12 +72,6 @@ public class GestureLauncherService extends SystemService {
     */
     */
    @VisibleForTesting static final long CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS = 300;
    @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
     * Interval in milliseconds in which the power button must be depressed in succession to be
@@ -570,7 +566,8 @@ public class GestureLauncherService extends SystemService {
                    long emergencyGestureTapDetectionMinTimeMs = Settings.Global.getInt(
                    long emergencyGestureTapDetectionMinTimeMs = Settings.Global.getInt(
                            mContext.getContentResolver(),
                            mContext.getContentResolver(),
                            Settings.Global.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS,
                            Settings.Global.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS,
                            EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS);
                            mContext.getResources().getInteger(
                                    config_defaultMinEmergencyGestureTapDurationMillis));
                    if (emergencyGestureSpentTime <= emergencyGestureTapDetectionMinTimeMs) {
                    if (emergencyGestureSpentTime <= emergencyGestureTapDetectionMinTimeMs) {
                        Slog.i(TAG, "Emergency gesture detected but it's too fast. Gesture time: "
                        Slog.i(TAG, "Emergency gesture detected but it's too fast. Gesture time: "
                                + emergencyGestureSpentTime + " ms");
                                + emergencyGestureSpentTime + " ms");
+1 −2
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server;
package com.android.server;


import static com.android.server.GestureLauncherService.CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS;
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.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
@@ -1449,7 +1448,7 @@ public class GestureLauncherServiceTest {
        long emergencyGestureTapDetectionMinTimeMs = Settings.Global.getInt(
        long emergencyGestureTapDetectionMinTimeMs = Settings.Global.getInt(
                mContext.getContentResolver(),
                mContext.getContentResolver(),
                Settings.Global.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS,
                Settings.Global.EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS,
                EMERGENCY_GESTURE_TAP_DETECTION_MIN_TIME_MS);
                200);
        assertTrue(intercepted);
        assertTrue(intercepted);
        if (tapIntervalMs * 4 > emergencyGestureTapDetectionMinTimeMs) {
        if (tapIntervalMs * 4 > emergencyGestureTapDetectionMinTimeMs) {
            assertTrue(outLaunched.value);
            assertTrue(outLaunched.value);