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

Commit 96e9cc57 authored by Anthony Hugh's avatar Anthony Hugh
Browse files

Add panic detection to back button

Adds "panic" detection to the back button.  Implemented solution
uses 4x button presses in a short duration to detect for "panic".
The value used to determine the duration between key up and key down
that still count as a multi-button press is configurable via the
Settings Provider.

BUG: 28027764

Change-Id: Ibf1370ff3cb539a9a54002a8704922744a3ca5d7
parent f3c61333
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -5344,6 +5344,13 @@ public final class Settings {
         */
        public static final String LONG_PRESS_TIMEOUT = "long_press_timeout";

        /**
         * The duration in milliseconds between the first tap's up event and the second tap's
         * down event for an interaction to be considered part of the same multi-press.
         * @hide
         */
        public static final String MULTI_PRESS_TIMEOUT = "multi_press_timeout";

        /**
         * List of the enabled print services.
         *
+16 −0
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ public class ViewConfiguration {
     */
    private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500;

    /**
     * Defines the default duration in milliseconds between the first tap's up event and the second
     * tap's down event for an interaction to be considered part of the same multi-press.
     */
    private static final int DEFAULT_MULTI_PRESS_TIMEOUT = 300;

    /**
     * Defines the time between successive key repeats in milliseconds.
     */
@@ -440,6 +446,16 @@ public class ViewConfiguration {
                DEFAULT_LONG_PRESS_TIMEOUT);
    }

    /**
     * @return the duration in milliseconds between the first tap's up event and the second tap's
     * down event for an interaction to be considered part of the same multi-press.
     * @hide
     */
    public static int getMultiPressTimeout() {
        return AppGlobals.getIntCoreSetting(Settings.Secure.MULTI_PRESS_TIMEOUT,
                DEFAULT_MULTI_PRESS_TIMEOUT);
    }

    /**
     * @return the time before the first key repeat in milliseconds.
     */
+6 −0
Original line number Diff line number Diff line
@@ -796,6 +796,12 @@
    -->
    <integer name="config_longPressOnBackBehavior">0</integer>

    <!-- Control the behavior when the user panic presses the back button.
            0 - Nothing
            1 - Go to home
    -->
    <integer name="config_backPanicBehavior">0</integer>

    <!-- Control the behavior when the user short presses the power button.
            0 - Nothing
            1 - Go to sleep (doze)
+1 −0
Original line number Diff line number Diff line
@@ -375,6 +375,7 @@
  <java-symbol type="integer" name="config_immersive_mode_confirmation_panic" />
  <java-symbol type="integer" name="config_longPressOnPowerBehavior" />
  <java-symbol type="integer" name="config_longPressOnBackBehavior" />
  <java-symbol type="integer" name="config_backPanicBehavior" />
  <java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAdjust" />
  <java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAbsolute" />
  <java-symbol type="integer" name="config_max_pan_devices" />
+3 −0
Original line number Diff line number Diff line
@@ -155,6 +155,9 @@
    <!-- Default for Settings.Secure.LONG_PRESS_TIMEOUT_MILLIS -->
    <integer name="def_long_press_timeout_millis">400</integer>

    <!-- Default for Settings.Secure.MULTI_PRESS_TIMEOUT -->
    <integer name="def_multi_press_timeout_millis">300</integer>

    <!-- Default for Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD -->
    <bool name="def_show_ime_with_hard_keyboard">false</bool>

Loading