Merge "Move power button cooldown period flag to Settings.Global"

This commit is contained in:
Patrick Huang
2021-12-20 23:27:54 +00:00
committed by Android (Google) Code Review
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 =
"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.

View File

@@ -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(

View File

@@ -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);

View File

@@ -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,

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.
* 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);
}

View File

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