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
This commit is contained in:
Patrick Huang
2021-12-16 05:37:32 +00:00
parent e1d00c2dd9
commit 5ab8466005
6 changed files with 24 additions and 23 deletions

View File

@@ -9326,16 +9326,6 @@ public final class Settings {
public static final String EMERGENCY_GESTURE_SOUND_ENABLED = public static final String EMERGENCY_GESTURE_SOUND_ENABLED =
"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 * Whether the camera launch gesture to double tap the power button when the screen is off
* should be disabled. * should be disabled.
@@ -13924,6 +13914,16 @@ public final class Settings {
@Readable @Readable
public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed"; 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 * 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. * eng builds, not on user builds. This is set by the user and overrides the config value.

View File

@@ -85,6 +85,8 @@ public class GlobalSettingsValidators {
VALIDATORS.put(Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, ANY_STRING_VALIDATOR); VALIDATORS.put(Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, ANY_STRING_VALIDATOR);
VALIDATORS.put( VALIDATORS.put(
Global.EMERGENCY_TONE, new DiscreteValueValidator(new String[] {"0", "1", "2"})); 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.CALL_AUTO_RETRY, BOOLEAN_VALIDATOR);
VALIDATORS.put(Global.DOCK_AUDIO_MEDIA_ENABLED, BOOLEAN_VALIDATOR); VALIDATORS.put(Global.DOCK_AUDIO_MEDIA_ENABLED, BOOLEAN_VALIDATOR);
VALIDATORS.put( VALIDATORS.put(

View File

@@ -276,8 +276,6 @@ public class SecureSettingsValidators {
VALIDATORS.put(Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, BOOLEAN_VALIDATOR);
VALIDATORS.put(Secure.EMERGENCY_GESTURE_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_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.ADAPTIVE_CONNECTIVITY_ENABLED, BOOLEAN_VALIDATOR);
VALIDATORS.put( VALIDATORS.put(
Secure.ASSIST_HANDLES_LEARNING_TIME_ELAPSED_MILLIS, NONE_NEGATIVE_LONG_VALIDATOR); Secure.ASSIST_HANDLES_LEARNING_TIME_ELAPSED_MILLIS, NONE_NEGATIVE_LONG_VALIDATOR);

View File

@@ -257,6 +257,7 @@ public class SettingsBackupTest {
Settings.Global.DROPBOX_RESERVE_PERCENT, Settings.Global.DROPBOX_RESERVE_PERCENT,
Settings.Global.DROPBOX_TAG_PREFIX, Settings.Global.DROPBOX_TAG_PREFIX,
Settings.Global.EMERGENCY_AFFORDANCE_NEEDED, Settings.Global.EMERGENCY_AFFORDANCE_NEEDED,
Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
Settings.Global.EMULATE_DISPLAY_CUTOUT, Settings.Global.EMULATE_DISPLAY_CUTOUT,
Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED,
Settings.Global.ENABLE_CACHE_QUOTA_CALCULATION, Settings.Global.ENABLE_CACHE_QUOTA_CALCULATION,

View File

@@ -89,13 +89,13 @@ public class GestureLauncherService extends SystemService {
/** /**
* Default value of the power button "cooldown" period after the Emergency gesture is triggered. * 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; 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. * 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. * is capped at this maximum.
*/ */
@VisibleForTesting @VisibleForTesting
@@ -284,8 +284,8 @@ public class GestureLauncherService extends SystemService {
Settings.Secure.getUriFor(Settings.Secure.EMERGENCY_GESTURE_ENABLED), Settings.Secure.getUriFor(Settings.Secure.EMERGENCY_GESTURE_ENABLED),
false, mSettingObserver, mUserId); false, mSettingObserver, mUserId);
mContext.getContentResolver().registerContentObserver( mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor( Settings.Global.getUriFor(
Settings.Secure.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS), Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS),
false, mSettingObserver, mUserId); false, mSettingObserver, mUserId);
} }
@@ -469,9 +469,10 @@ public class GestureLauncherService extends SystemService {
*/ */
@VisibleForTesting @VisibleForTesting
static int getEmergencyGesturePowerButtonCooldownPeriodMs(Context context, int userId) { static int getEmergencyGesturePowerButtonCooldownPeriodMs(Context context, int userId) {
int cooldown = Settings.Secure.getIntForUser(context.getContentResolver(), int cooldown = Settings.Global.getInt(context.getContentResolver(),
Settings.Secure.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS, Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_DEFAULT, userId); EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_DEFAULT);
return Math.min(cooldown, EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_MAX); return Math.min(cooldown, EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS_MAX);
} }

View File

@@ -1450,11 +1450,10 @@ public class GestureLauncherServiceTest {
} }
private void withEmergencyGesturePowerButtonCooldownPeriodMsValue(int period) { private void withEmergencyGesturePowerButtonCooldownPeriodMsValue(int period) {
Settings.Secure.putIntForUser( Settings.Global.putInt(
mContentResolver, mContentResolver,
Settings.Secure.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS, Settings.Global.EMERGENCY_GESTURE_POWER_BUTTON_COOLDOWN_PERIOD_MS,
period, period);
UserHandle.USER_CURRENT);
} }
private void withUserSetupCompleteValue(boolean userSetupComplete) { private void withUserSetupCompleteValue(boolean userSetupComplete) {