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

Commit 5ab84660 authored by Patrick Huang's avatar Patrick Huang
Browse files

Move power button cooldown period flag to Settings.Global

This is a follow up of ag/16406749

Bug: 195782998
Test: unit tests, manual test on device
Change-Id: Icb977d9a7591ffe48ae44bbe2ad521945b7b0139
parent e1d00c2d
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -9326,16 +9326,6 @@ public final class Settings {
        public static final String EMERGENCY_GESTURE_SOUND_ENABLED =
                "emergency_gesture_sound_enabled";
        /**
         * The power button "cooldown" period in milliseconds after the Emergency gesture is
         * triggered, during which single-key actions on the power button are suppressed. Cooldown
         * period is disabled if set to zero.
         *
         * @hide
         */
        public static final String EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS =
                "emergency_gesture_power_button_cooldown_period_ms";
        /**
         * Whether the camera launch gesture to double tap the power button when the screen is off
         * should be disabled.
@@ -13924,6 +13914,16 @@ public final class Settings {
        @Readable
        public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed";
        /**
         * The power button "cooldown" period in milliseconds after the Emergency gesture is
         * triggered, during which single-key actions on the power button are suppressed. Cooldown
         * period is disabled if set to zero.
         *
         * @hide
         */
        public static final String EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS =
                "emergency_gesture_power_button_cooldown_period_ms";
        /**
         * Whether to enable automatic system server heap dumps. This only works on userdebug or
         * eng builds, not on user builds. This is set by the user and overrides the config value.
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ public class GlobalSettingsValidators {
        VALIDATORS.put(Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, ANY_STRING_VALIDATOR);
        VALIDATORS.put(
                Global.EMERGENCY_TONE, new DiscreteValueValidator(new String[] {"0", "1", "2"}));
        VALIDATORS.put(Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
                NON_NEGATIVE_INTEGER_VALIDATOR);
        VALIDATORS.put(Global.CALL_AUTO_RETRY, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.DOCK_AUDIO_MEDIA_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(
+0 −2
Original line number Diff line number Diff line
@@ -276,8 +276,6 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.EMERGENCY_GESTURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.EMERGENCY_GESTURE_SOUND_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
                NON_NEGATIVE_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.ADAPTIVE_CONNECTIVITY_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(
                Secure.ASSIST_HANDLES_LEARNING_TIME_ELAPSED_MILLIS, NONE_NEGATIVE_LONG_VALIDATOR);
+1 −0
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ public class SettingsBackupTest {
                    Settings.Global.DROPBOX_RESERVE_PERCENT,
                    Settings.Global.DROPBOX_TAG_PREFIX,
                    Settings.Global.EMERGENCY_AFFORDANCE_NEEDED,
                    Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
                    Settings.Global.EMULATE_DISPLAY_CUTOUT,
                    Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED,
                    Settings.Global.ENABLE_CACHE_QUOTA_CALCULATION,
+8 −7
Original line number Diff line number Diff line
@@ -89,13 +89,13 @@ public class GestureLauncherService extends SystemService {

    /**
     * Default value of the power button "cooldown" period after the Emergency gesture is triggered.
     * See {@link Settings.Secure#EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS}
     * See {@link Settings.Global#EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS}
     */
    private static final int EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_DEFAULT = 3000;

    /**
     * Maximum value of the power button "cooldown" period after the Emergency gesture is triggered.
     * The value read from {@link Settings.Secure#EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS}
     * The value read from {@link Settings.Global#EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS}
     * is capped at this maximum.
     */
    @VisibleForTesting
@@ -284,8 +284,8 @@ public class GestureLauncherService extends SystemService {
                Settings.Secure.getUriFor(Settings.Secure.EMERGENCY_GESTURE_ENABLED),
                false, mSettingObserver, mUserId);
        mContext.getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(
                        Settings.Secure.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS),
                Settings.Global.getUriFor(
                        Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS),
                false, mSettingObserver, mUserId);
    }

@@ -469,9 +469,10 @@ public class GestureLauncherService extends SystemService {
     */
    @VisibleForTesting
    static int getEmergencyGesturePowerButtonCooldownPeriodMs(Context context, int userId) {
        int cooldown = Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
                EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_DEFAULT, userId);
        int cooldown = Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
                EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_DEFAULT);

        return Math.min(cooldown, EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_MAX);
    }

Loading