diff options
18 files changed, 650 insertions, 1154 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index f573d8771178..fecb7f15a021 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -16,20 +16,6 @@ package android.provider; -import static android.provider.settings.validators.SettingsValidators.ANY_INTEGER_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.ANY_STRING_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.BOOLEAN_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.COMPONENT_NAME_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.JSON_OBJECT_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.LENIENT_IP_ADDRESS_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.LOCALE_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.NULLABLE_COMPONENT_NAME_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.PACKAGE_NAME_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.TILE_LIST_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.TTS_LIST_VALIDATOR; -import static android.provider.settings.validators.SettingsValidators.URI_VALIDATOR; - import android.Manifest; import android.annotation.IntDef; import android.annotation.IntRange; @@ -63,9 +49,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.database.SQLException; -import android.hardware.display.ColorDisplayManager; import android.location.LocationManager; -import android.media.AudioFormat; import android.net.ConnectivityManager; import android.net.NetworkScoreManager; import android.net.Uri; @@ -83,12 +67,6 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; import android.os.UserHandle; -import android.provider.settings.validators.ComponentNameListValidator; -import android.provider.settings.validators.DiscreteValueValidator; -import android.provider.settings.validators.InclusiveFloatRangeValidator; -import android.provider.settings.validators.InclusiveIntegerRangeValidator; -import android.provider.settings.validators.PackageNameListValidator; -import android.provider.settings.validators.Validator; import android.speech.tts.TextToSpeech; import android.telephony.SubscriptionManager; import android.text.TextUtils; @@ -106,7 +84,6 @@ import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.net.URISyntaxException; -import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; @@ -3120,30 +3097,6 @@ public final class Settings { @Deprecated public static final String STAY_ON_WHILE_PLUGGED_IN = Global.STAY_ON_WHILE_PLUGGED_IN; - private static final Validator STAY_ON_WHILE_PLUGGED_IN_VALIDATOR = new Validator() { - @Override - public boolean validate(String value) { - try { - int val = Integer.parseInt(value); - return (val == 0) - || (val == BatteryManager.BATTERY_PLUGGED_AC) - || (val == BatteryManager.BATTERY_PLUGGED_USB) - || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS) - || (val == (BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_USB)) - || (val == (BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_WIRELESS)) - || (val == (BatteryManager.BATTERY_PLUGGED_USB - | BatteryManager.BATTERY_PLUGGED_WIRELESS)) - || (val == (BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_USB - | BatteryManager.BATTERY_PLUGGED_WIRELESS)); - } catch (NumberFormatException e) { - return false; - } - } - }; - /** * What happens when the user presses the end call button if they're not * on a call.<br/> @@ -3156,9 +3109,6 @@ public final class Settings { */ public static final String END_BUTTON_BEHAVIOR = "end_button_behavior"; - private static final Validator END_BUTTON_BEHAVIOR_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 3); - /** * END_BUTTON_BEHAVIOR value for "go home". * @hide @@ -3183,8 +3133,6 @@ public final class Settings { */ public static final String ADVANCED_SETTINGS = "advanced_settings"; - private static final Validator ADVANCED_SETTINGS_VALIDATOR = BOOLEAN_VALIDATOR; - /** * ADVANCED_SETTINGS default value. * @hide @@ -3285,8 +3233,6 @@ public final class Settings { @Deprecated public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip"; - private static final Validator WIFI_USE_STATIC_IP_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The static IP address. * <p> @@ -3297,8 +3243,6 @@ public final class Settings { @Deprecated public static final String WIFI_STATIC_IP = "wifi_static_ip"; - private static final Validator WIFI_STATIC_IP_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR; - /** * If using static IP, the gateway's IP address. * <p> @@ -3309,8 +3253,6 @@ public final class Settings { @Deprecated public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway"; - private static final Validator WIFI_STATIC_GATEWAY_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR; - /** * If using static IP, the net mask. * <p> @@ -3321,8 +3263,6 @@ public final class Settings { @Deprecated public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask"; - private static final Validator WIFI_STATIC_NETMASK_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR; - /** * If using static IP, the primary DNS's IP address. * <p> @@ -3333,8 +3273,6 @@ public final class Settings { @Deprecated public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1"; - private static final Validator WIFI_STATIC_DNS1_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR; - /** * If using static IP, the secondary DNS's IP address. * <p> @@ -3345,8 +3283,6 @@ public final class Settings { @Deprecated public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2"; - private static final Validator WIFI_STATIC_DNS2_VALIDATOR = LENIENT_IP_ADDRESS_VALIDATOR; - /** * Determines whether remote devices may discover and/or connect to * this device. @@ -3358,9 +3294,6 @@ public final class Settings { public static final String BLUETOOTH_DISCOVERABILITY = "bluetooth_discoverability"; - private static final Validator BLUETOOTH_DISCOVERABILITY_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 2); - /** * Bluetooth discoverability timeout. If this value is nonzero, then * Bluetooth becomes discoverable for a certain number of seconds, @@ -3369,9 +3302,6 @@ public final class Settings { public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT = "bluetooth_discoverability_timeout"; - private static final Validator BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED} * instead @@ -3404,32 +3334,11 @@ public final class Settings { @Deprecated public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted"; - private static final Validator NEXT_ALARM_FORMATTED_VALIDATOR = new Validator() { - private static final int MAX_LENGTH = 1000; - - @Override - public boolean validate(String value) { - // TODO: No idea what the correct format is. - return value == null || value.length() < MAX_LENGTH; - } - }; - /** * Scaling factor for fonts, float. */ public static final String FONT_SCALE = "font_scale"; - private static final Validator FONT_SCALE_VALIDATOR = new Validator() { - @Override - public boolean validate(@Nullable String value) { - try { - return Float.parseFloat(value) >= 0; - } catch (NumberFormatException | NullPointerException e) { - return false; - } - } - }; - /** * The serialized system locale value. * @@ -3466,34 +3375,12 @@ public final class Settings { @Deprecated public static final String DIM_SCREEN = "dim_screen"; - private static final Validator DIM_SCREEN_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The display color mode. * @hide */ public static final String DISPLAY_COLOR_MODE = "display_color_mode"; - private static final Validator DISPLAY_COLOR_MODE_VALIDATOR = new Validator() { - @Override - public boolean validate(@Nullable String value) { - // Assume the actual validation that this device can properly handle this kind of - // color mode further down in ColorDisplayManager / ColorDisplayService. - try { - final int setting = Integer.parseInt(value); - final boolean isInFrameworkRange = - setting >= ColorDisplayManager.COLOR_MODE_NATURAL - && setting <= ColorDisplayManager.COLOR_MODE_AUTOMATIC; - final boolean isInVendorRange = - setting >= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MIN - && setting <= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MAX; - return isInFrameworkRange || isInVendorRange; - } catch (NumberFormatException | NullPointerException e) { - return false; - } - } - }; - /** * The user selected min refresh rate in frames per second. * @@ -3510,9 +3397,6 @@ public final class Settings { */ public static final String PEAK_REFRESH_RATE = "peak_refresh_rate"; - private static final Validator PEAK_REFRESH_RATE_VALIDATOR = - new InclusiveFloatRangeValidator(24f, Float.MAX_VALUE); - /** * The amount of time in milliseconds before the device goes to sleep or begins * to dream after a period of inactivity. This value is also known as the @@ -3525,9 +3409,6 @@ public final class Settings { */ public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout"; - private static final Validator SCREEN_OFF_TIMEOUT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * The screen backlight brightness between 0 and 255. */ @@ -3539,16 +3420,11 @@ public final class Settings { */ public static final String SCREEN_BRIGHTNESS_FOR_VR = "screen_brightness_for_vr"; - private static final Validator SCREEN_BRIGHTNESS_FOR_VR_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 255); - /** * Control whether to enable automatic brightness mode. */ public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode"; - private static final Validator SCREEN_BRIGHTNESS_MODE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Adjustment to auto-brightness to make it generally more (>0.0 <1.0) * or less (<0.0 >-1.0) bright. @@ -3557,9 +3433,6 @@ public final class Settings { @UnsupportedAppUsage public static final String SCREEN_AUTO_BRIGHTNESS_ADJ = "screen_auto_brightness_adj"; - private static final Validator SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR = - new InclusiveFloatRangeValidator(-1, 1); - /** * SCREEN_BRIGHTNESS_MODE value for manual mode. */ @@ -3576,8 +3449,6 @@ public final class Settings { */ public static final String ADAPTIVE_SLEEP = "adaptive_sleep"; - private static final Validator ADAPTIVE_SLEEP_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Control whether the process CPU usage meter should be shown. * @@ -3604,9 +3475,6 @@ public final class Settings { */ public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected"; - private static final Validator MODE_RINGER_STREAMS_AFFECTED_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Determines which streams are affected by mute. The * stream type's bit should be set to 1 if it should be muted when a mute request @@ -3614,17 +3482,12 @@ public final class Settings { */ public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected"; - private static final Validator MUTE_STREAMS_AFFECTED_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Whether vibrate is on for different events. This is used internally, * changing this value will not change the vibrate. See AudioManager. */ public static final String VIBRATE_ON = "vibrate_on"; - private static final Validator VIBRATE_ON_VALIDATOR = BOOLEAN_VALIDATOR; - /** * If 1, redirects the system vibrator to all currently attached input devices * that support vibration. If there are no such input devices, then the system @@ -3639,8 +3502,6 @@ public final class Settings { */ public static final String VIBRATE_INPUT_DEVICES = "vibrate_input_devices"; - private static final Validator VIBRATE_INPUT_DEVICES_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The intensity of notification vibrations, if configurable. * @@ -3691,9 +3552,6 @@ public final class Settings { public static final String HAPTIC_FEEDBACK_INTENSITY = "haptic_feedback_intensity"; - private static final Validator VIBRATION_INTENSITY_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 3); - /** * Ringer volume. This is used internally, changing this value will not * change the volume. See AudioManager. @@ -3772,8 +3630,6 @@ public final class Settings { @UnsupportedAppUsage public static final String MASTER_MONO = "master_mono"; - private static final Validator MASTER_MONO_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Master balance (float -1.f = 100% left, 0.f = dead center, 1.f = 100% right). * @@ -3781,9 +3637,6 @@ public final class Settings { */ public static final String MASTER_BALANCE = "master_balance"; - private static final Validator MASTER_BALANCE_VALIDATOR = - new InclusiveFloatRangeValidator(-1.f, 1.f); - /** * Whether the notifications should use the ring volume (value of 1) or * a separate notification volume (value of 0). In most cases, users @@ -3802,8 +3655,6 @@ public final class Settings { public static final String NOTIFICATIONS_USE_RING_VOLUME = "notifications_use_ring_volume"; - private static final Validator NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether silent mode should allow vibration feedback. This is used * internally in AudioService and the Sound settings activity to @@ -3819,8 +3670,6 @@ public final class Settings { @UnsupportedAppUsage public static final String VIBRATE_IN_SILENT = "vibrate_in_silent"; - private static final Validator VIBRATE_IN_SILENT_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The mapping of stream type (integer) to its setting. * @@ -3867,8 +3716,6 @@ public final class Settings { */ public static final String RINGTONE = "ringtone"; - private static final Validator RINGTONE_VALIDATOR = URI_VALIDATOR; - /** * A {@link Uri} that will point to the current default ringtone at any * given time. @@ -3892,8 +3739,6 @@ public final class Settings { */ public static final String NOTIFICATION_SOUND = "notification_sound"; - private static final Validator NOTIFICATION_SOUND_VALIDATOR = URI_VALIDATOR; - /** * A {@link Uri} that will point to the current default notification * sound at any given time. @@ -3915,8 +3760,6 @@ public final class Settings { */ public static final String ALARM_ALERT = "alarm_alert"; - private static final Validator ALARM_ALERT_VALIDATOR = URI_VALIDATOR; - /** * A {@link Uri} that will point to the current default alarm alert at * any given time. @@ -3937,42 +3780,30 @@ public final class Settings { */ public static final String MEDIA_BUTTON_RECEIVER = "media_button_receiver"; - private static final Validator MEDIA_BUTTON_RECEIVER_VALIDATOR = COMPONENT_NAME_VALIDATOR; - /** * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off */ public static final String TEXT_AUTO_REPLACE = "auto_replace"; - private static final Validator TEXT_AUTO_REPLACE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off */ public static final String TEXT_AUTO_CAPS = "auto_caps"; - private static final Validator TEXT_AUTO_CAPS_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This * feature converts two spaces to a "." and space. */ public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate"; - private static final Validator TEXT_AUTO_PUNCTUATE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting to showing password characters in text editors. 1 = On, 0 = Off */ public static final String TEXT_SHOW_PASSWORD = "show_password"; - private static final Validator TEXT_SHOW_PASSWORD_VALIDATOR = BOOLEAN_VALIDATOR; - public static final String SHOW_GTALK_SERVICE_STATUS = "SHOW_GTALK_SERVICE_STATUS"; - private static final Validator SHOW_GTALK_SERVICE_STATUS_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Name of activity to use for wallpaper on the home screen. * @@ -3981,18 +3812,6 @@ public final class Settings { @Deprecated public static final String WALLPAPER_ACTIVITY = "wallpaper_activity"; - private static final Validator WALLPAPER_ACTIVITY_VALIDATOR = new Validator() { - private static final int MAX_LENGTH = 1000; - - @Override - public boolean validate(String value) { - if (value != null && value.length() > MAX_LENGTH) { - return false; - } - return ComponentName.unflattenFromString(value) != null; - } - }; - /** * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME} * instead @@ -4000,8 +3819,6 @@ public final class Settings { @Deprecated public static final String AUTO_TIME = Global.AUTO_TIME; - private static final Validator AUTO_TIME_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#AUTO_TIME_ZONE} * instead @@ -4009,8 +3826,6 @@ public final class Settings { @Deprecated public static final String AUTO_TIME_ZONE = Global.AUTO_TIME_ZONE; - private static final Validator AUTO_TIME_ZONE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Display times as 12 or 24 hours * 12 @@ -4018,10 +3833,6 @@ public final class Settings { */ public static final String TIME_12_24 = "time_12_24"; - /** @hide */ - public static final Validator TIME_12_24_VALIDATOR = - new DiscreteValueValidator(new String[] {"12", "24", null}); - /** * Date format string * mm/dd/yyyy @@ -4030,19 +3841,6 @@ public final class Settings { */ public static final String DATE_FORMAT = "date_format"; - /** @hide */ - public static final Validator DATE_FORMAT_VALIDATOR = new Validator() { - @Override - public boolean validate(@Nullable String value) { - try { - new SimpleDateFormat(value); - return true; - } catch (IllegalArgumentException | NullPointerException e) { - return false; - } - } - }; - /** * Whether the setup wizard has been run before (on first boot), or if * it still needs to be run. @@ -4052,9 +3850,6 @@ public final class Settings { */ public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run"; - /** @hide */ - public static final Validator SETUP_WIZARD_HAS_RUN_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Scaling factor for normal window animations. Setting to 0 will disable window * animations. @@ -4091,9 +3886,6 @@ public final class Settings { */ public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation"; - /** @hide */ - public static final Validator ACCELEROMETER_ROTATION_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Default screen rotation when no other policy applies. * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a @@ -4104,10 +3896,6 @@ public final class Settings { */ public static final String USER_ROTATION = "user_rotation"; - /** @hide */ - public static final Validator USER_ROTATION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 3); - /** * Control whether the rotation lock toggle in the System UI should be hidden. * Typically this is done for accessibility purposes to make it harder for @@ -4123,10 +3911,6 @@ public final class Settings { public static final String HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY = "hide_rotation_lock_toggle_for_accessibility"; - /** @hide */ - public static final Validator HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether the phone vibrates when it is ringing due to an incoming call. This will * be used by Phone and Setting apps; it shouldn't affect other apps. @@ -4139,9 +3923,6 @@ public final class Settings { */ public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing"; - /** @hide */ - public static final Validator VIBRATE_WHEN_RINGING_VALIDATOR = BOOLEAN_VALIDATOR; - /** * When {@code 1}, Telecom enhanced call blocking functionality is enabled. When * {@code 0}, enhanced call blocking functionality is disabled. @@ -4156,9 +3937,6 @@ public final class Settings { */ public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone"; - /** @hide */ - public static final Validator DTMF_TONE_WHEN_DIALING_VALIDATOR = BOOLEAN_VALIDATOR; - /** * CDMA only settings * DTMF tone type played by the dialer when dialing. @@ -4167,9 +3945,6 @@ public final class Settings { */ public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type"; - /** @hide */ - public static final Validator DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the hearing aid is enabled. The value is * boolean (1 or 0). @@ -4178,9 +3953,6 @@ public final class Settings { @UnsupportedAppUsage public static final String HEARING_AID = "hearing_aid"; - /** @hide */ - public static final Validator HEARING_AID_VALIDATOR = BOOLEAN_VALIDATOR; - /** * CDMA only settings * TTY Mode @@ -4193,28 +3965,18 @@ public final class Settings { @UnsupportedAppUsage public static final String TTY_MODE = "tty_mode"; - /** @hide */ - public static final Validator TTY_MODE_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 3); - /** * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is * boolean (1 or 0). */ public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled"; - /** @hide */ - public static final Validator SOUND_EFFECTS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether haptic feedback (Vibrate on tap) is enabled. The value is * boolean (1 or 0). */ public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled"; - /** @hide */ - public static final Validator HAPTIC_FEEDBACK_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Each application that shows web suggestions should have its own * setting for this. @@ -4222,9 +3984,6 @@ public final class Settings { @Deprecated public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions"; - /** @hide */ - public static final Validator SHOW_WEB_SUGGESTIONS_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the notification LED should repeatedly flash when a notification is * pending. The value is boolean (1 or 0). @@ -4233,9 +3992,6 @@ public final class Settings { @UnsupportedAppUsage public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse"; - /** @hide */ - public static final Validator NOTIFICATION_LIGHT_PULSE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Show pointer location on screen? * 0 = no @@ -4245,9 +4001,6 @@ public final class Settings { @UnsupportedAppUsage public static final String POINTER_LOCATION = "pointer_location"; - /** @hide */ - public static final Validator POINTER_LOCATION_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Show touch positions on screen? * 0 = no @@ -4257,9 +4010,6 @@ public final class Settings { @UnsupportedAppUsage public static final String SHOW_TOUCHES = "show_touches"; - /** @hide */ - public static final Validator SHOW_TOUCHES_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Log raw orientation data from * {@link com.android.server.policy.WindowOrientationListener} for use with the @@ -4271,9 +4021,6 @@ public final class Settings { public static final String WINDOW_ORIENTATION_LISTENER_LOG = "window_orientation_listener_log"; - /** @hide */ - public static final Validator WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#POWER_SOUNDS_ENABLED} * instead @@ -4282,8 +4029,6 @@ public final class Settings { @Deprecated public static final String POWER_SOUNDS_ENABLED = Global.POWER_SOUNDS_ENABLED; - private static final Validator POWER_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#DOCK_SOUNDS_ENABLED} * instead @@ -4293,8 +4038,6 @@ public final class Settings { @UnsupportedAppUsage public static final String DOCK_SOUNDS_ENABLED = Global.DOCK_SOUNDS_ENABLED; - private static final Validator DOCK_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether to play sounds when the keyguard is shown and dismissed. * @hide @@ -4302,18 +4045,12 @@ public final class Settings { @UnsupportedAppUsage public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled"; - /** @hide */ - public static final Validator LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the lockscreen should be completely disabled. * @hide */ public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled"; - /** @hide */ - public static final Validator LOCKSCREEN_DISABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND} * instead @@ -4384,9 +4121,6 @@ public final class Settings { */ public static final String SIP_RECEIVE_CALLS = "sip_receive_calls"; - /** @hide */ - public static final Validator SIP_RECEIVE_CALLS_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Call Preference String. * "SIP_ALWAYS" : Always use SIP with network access @@ -4395,29 +4129,18 @@ public final class Settings { */ public static final String SIP_CALL_OPTIONS = "sip_call_options"; - /** @hide */ - public static final Validator SIP_CALL_OPTIONS_VALIDATOR = - new DiscreteValueValidator( - new String[] {"SIP_ALWAYS", "SIP_ADDRESS_ONLY"}); - /** * One of the sip call options: Always use SIP with network access. * @hide */ public static final String SIP_ALWAYS = "SIP_ALWAYS"; - /** @hide */ - public static final Validator SIP_ALWAYS_VALIDATOR = BOOLEAN_VALIDATOR; - /** * One of the sip call options: Only if destination is a SIP address. * @hide */ public static final String SIP_ADDRESS_ONLY = "SIP_ADDRESS_ONLY"; - /** @hide */ - public static final Validator SIP_ADDRESS_ONLY_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use SIP_ALWAYS or SIP_ADDRESS_ONLY instead. Formerly used to indicate that * the user should be prompted each time a call is made whether it should be placed using @@ -4428,9 +4151,6 @@ public final class Settings { @Deprecated public static final String SIP_ASK_ME_EACH_TIME = "SIP_ASK_ME_EACH_TIME"; - /** @hide */ - public static final Validator SIP_ASK_ME_EACH_TIME_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Pointer speed setting. * This is an integer value in a range between -7 and +7, so there are 15 possible values. @@ -4442,19 +4162,12 @@ public final class Settings { @UnsupportedAppUsage public static final String POINTER_SPEED = "pointer_speed"; - /** @hide */ - public static final Validator POINTER_SPEED_VALIDATOR = - new InclusiveFloatRangeValidator(-7, 7); - /** * Whether lock-to-app will be triggered by long-press on recents. * @hide */ public static final String LOCK_TO_APP_ENABLED = "lock_to_app_enabled"; - /** @hide */ - public static final Validator LOCK_TO_APP_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * I am the lolrus. * <p> @@ -4464,18 +4177,6 @@ public final class Settings { */ public static final String EGG_MODE = "egg_mode"; - /** @hide */ - public static final Validator EGG_MODE_VALIDATOR = new Validator() { - @Override - public boolean validate(@Nullable String value) { - try { - return Long.parseLong(value) >= 0; - } catch (NumberFormatException e) { - return false; - } - } - }; - /** * Setting to determine whether or not to show the battery percentage in the status bar. * 0 - Don't show percentage @@ -4484,9 +4185,6 @@ public final class Settings { */ public static final String SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent"; - /** @hide */ - private static final Validator SHOW_BATTERY_PERCENT_VALIDATOR = BOOLEAN_VALIDATOR; - /** * IMPORTANT: If you add a new public settings you also have to add it to * PUBLIC_SETTINGS below. If the new setting is hidden you have to add @@ -4681,99 +4379,6 @@ public final class Settings { } /** - * These are all public system settings - * - * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator, - * otherwise they won't be restored. - * - * @hide - */ - @UnsupportedAppUsage - public static final Map<String, Validator> VALIDATORS = new ArrayMap<>(); - static { - VALIDATORS.put(STAY_ON_WHILE_PLUGGED_IN, STAY_ON_WHILE_PLUGGED_IN_VALIDATOR); - VALIDATORS.put(END_BUTTON_BEHAVIOR, END_BUTTON_BEHAVIOR_VALIDATOR); - VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR); - VALIDATORS.put(BLUETOOTH_DISCOVERABILITY, BLUETOOTH_DISCOVERABILITY_VALIDATOR); - VALIDATORS.put(BLUETOOTH_DISCOVERABILITY_TIMEOUT, - BLUETOOTH_DISCOVERABILITY_TIMEOUT_VALIDATOR); - VALIDATORS.put(NEXT_ALARM_FORMATTED, NEXT_ALARM_FORMATTED_VALIDATOR); - VALIDATORS.put(FONT_SCALE, FONT_SCALE_VALIDATOR); - VALIDATORS.put(DIM_SCREEN, DIM_SCREEN_VALIDATOR); - VALIDATORS.put(DISPLAY_COLOR_MODE, DISPLAY_COLOR_MODE_VALIDATOR); - VALIDATORS.put(SCREEN_OFF_TIMEOUT, SCREEN_OFF_TIMEOUT_VALIDATOR); - VALIDATORS.put(SCREEN_BRIGHTNESS_FOR_VR, SCREEN_BRIGHTNESS_FOR_VR_VALIDATOR); - VALIDATORS.put(SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_VALIDATOR); - VALIDATORS.put(ADAPTIVE_SLEEP, ADAPTIVE_SLEEP_VALIDATOR); - VALIDATORS.put(MODE_RINGER_STREAMS_AFFECTED, MODE_RINGER_STREAMS_AFFECTED_VALIDATOR); - VALIDATORS.put(MUTE_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED_VALIDATOR); - VALIDATORS.put(VIBRATE_ON, VIBRATE_ON_VALIDATOR); - VALIDATORS.put(NOTIFICATION_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR); - VALIDATORS.put(RING_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR); - VALIDATORS.put(HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR); - VALIDATORS.put(RINGTONE, RINGTONE_VALIDATOR); - VALIDATORS.put(NOTIFICATION_SOUND, NOTIFICATION_SOUND_VALIDATOR); - VALIDATORS.put(ALARM_ALERT, ALARM_ALERT_VALIDATOR); - VALIDATORS.put(TEXT_AUTO_REPLACE, TEXT_AUTO_REPLACE_VALIDATOR); - VALIDATORS.put(TEXT_AUTO_CAPS, TEXT_AUTO_CAPS_VALIDATOR); - VALIDATORS.put(TEXT_AUTO_PUNCTUATE, TEXT_AUTO_PUNCTUATE_VALIDATOR); - VALIDATORS.put(TEXT_SHOW_PASSWORD, TEXT_SHOW_PASSWORD_VALIDATOR); - VALIDATORS.put(AUTO_TIME, AUTO_TIME_VALIDATOR); - VALIDATORS.put(AUTO_TIME_ZONE, AUTO_TIME_ZONE_VALIDATOR); - VALIDATORS.put(SHOW_GTALK_SERVICE_STATUS, SHOW_GTALK_SERVICE_STATUS_VALIDATOR); - VALIDATORS.put(WALLPAPER_ACTIVITY, WALLPAPER_ACTIVITY_VALIDATOR); - VALIDATORS.put(TIME_12_24, TIME_12_24_VALIDATOR); - VALIDATORS.put(DATE_FORMAT, DATE_FORMAT_VALIDATOR); - VALIDATORS.put(SETUP_WIZARD_HAS_RUN, SETUP_WIZARD_HAS_RUN_VALIDATOR); - VALIDATORS.put(ACCELEROMETER_ROTATION, ACCELEROMETER_ROTATION_VALIDATOR); - VALIDATORS.put(USER_ROTATION, USER_ROTATION_VALIDATOR); - VALIDATORS.put(DTMF_TONE_WHEN_DIALING, DTMF_TONE_WHEN_DIALING_VALIDATOR); - VALIDATORS.put(SOUND_EFFECTS_ENABLED, SOUND_EFFECTS_ENABLED_VALIDATOR); - VALIDATORS.put(HAPTIC_FEEDBACK_ENABLED, HAPTIC_FEEDBACK_ENABLED_VALIDATOR); - VALIDATORS.put(POWER_SOUNDS_ENABLED, POWER_SOUNDS_ENABLED_VALIDATOR); - VALIDATORS.put(DOCK_SOUNDS_ENABLED, DOCK_SOUNDS_ENABLED_VALIDATOR); - VALIDATORS.put(SHOW_WEB_SUGGESTIONS, SHOW_WEB_SUGGESTIONS_VALIDATOR); - VALIDATORS.put(WIFI_USE_STATIC_IP, WIFI_USE_STATIC_IP_VALIDATOR); - VALIDATORS.put(END_BUTTON_BEHAVIOR, END_BUTTON_BEHAVIOR_VALIDATOR); - VALIDATORS.put(ADVANCED_SETTINGS, ADVANCED_SETTINGS_VALIDATOR); - VALIDATORS.put(SCREEN_AUTO_BRIGHTNESS_ADJ, SCREEN_AUTO_BRIGHTNESS_ADJ_VALIDATOR); - VALIDATORS.put(VIBRATE_INPUT_DEVICES, VIBRATE_INPUT_DEVICES_VALIDATOR); - VALIDATORS.put(MASTER_MONO, MASTER_MONO_VALIDATOR); - VALIDATORS.put(MASTER_BALANCE, MASTER_BALANCE_VALIDATOR); - VALIDATORS.put(NOTIFICATIONS_USE_RING_VOLUME, NOTIFICATIONS_USE_RING_VOLUME_VALIDATOR); - VALIDATORS.put(VIBRATE_IN_SILENT, VIBRATE_IN_SILENT_VALIDATOR); - VALIDATORS.put(MEDIA_BUTTON_RECEIVER, MEDIA_BUTTON_RECEIVER_VALIDATOR); - VALIDATORS.put(HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, - HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY_VALIDATOR); - VALIDATORS.put(VIBRATE_WHEN_RINGING, VIBRATE_WHEN_RINGING_VALIDATOR); - VALIDATORS.put(DTMF_TONE_TYPE_WHEN_DIALING, DTMF_TONE_TYPE_WHEN_DIALING_VALIDATOR); - VALIDATORS.put(HEARING_AID, HEARING_AID_VALIDATOR); - VALIDATORS.put(TTY_MODE, TTY_MODE_VALIDATOR); - VALIDATORS.put(NOTIFICATION_LIGHT_PULSE, NOTIFICATION_LIGHT_PULSE_VALIDATOR); - VALIDATORS.put(POINTER_LOCATION, POINTER_LOCATION_VALIDATOR); - VALIDATORS.put(SHOW_TOUCHES, SHOW_TOUCHES_VALIDATOR); - VALIDATORS.put(WINDOW_ORIENTATION_LISTENER_LOG, - WINDOW_ORIENTATION_LISTENER_LOG_VALIDATOR); - VALIDATORS.put(LOCKSCREEN_SOUNDS_ENABLED, LOCKSCREEN_SOUNDS_ENABLED_VALIDATOR); - VALIDATORS.put(LOCKSCREEN_DISABLED, LOCKSCREEN_DISABLED_VALIDATOR); - VALIDATORS.put(SIP_RECEIVE_CALLS, SIP_RECEIVE_CALLS_VALIDATOR); - VALIDATORS.put(SIP_CALL_OPTIONS, SIP_CALL_OPTIONS_VALIDATOR); - VALIDATORS.put(SIP_ALWAYS, SIP_ALWAYS_VALIDATOR); - VALIDATORS.put(SIP_ADDRESS_ONLY, SIP_ADDRESS_ONLY_VALIDATOR); - VALIDATORS.put(SIP_ASK_ME_EACH_TIME, SIP_ASK_ME_EACH_TIME_VALIDATOR); - VALIDATORS.put(POINTER_SPEED, POINTER_SPEED_VALIDATOR); - VALIDATORS.put(LOCK_TO_APP_ENABLED, LOCK_TO_APP_ENABLED_VALIDATOR); - VALIDATORS.put(EGG_MODE, EGG_MODE_VALIDATOR); - VALIDATORS.put(WIFI_STATIC_IP, WIFI_STATIC_IP_VALIDATOR); - VALIDATORS.put(WIFI_STATIC_GATEWAY, WIFI_STATIC_GATEWAY_VALIDATOR); - VALIDATORS.put(WIFI_STATIC_NETMASK, WIFI_STATIC_NETMASK_VALIDATOR); - VALIDATORS.put(WIFI_STATIC_DNS1, WIFI_STATIC_DNS1_VALIDATOR); - VALIDATORS.put(WIFI_STATIC_DNS2, WIFI_STATIC_DNS2_VALIDATOR); - VALIDATORS.put(SHOW_BATTERY_PERCENT, SHOW_BATTERY_PERCENT_VALIDATOR); - VALIDATORS.put(NOTIFICATION_LIGHT_PULSE, BOOLEAN_VALIDATOR); - } - - /** * These entries are considered common between the personal and the managed profile, * since the managed profile doesn't get to change them. */ @@ -4859,8 +4464,6 @@ public final class Settings { @Deprecated public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON; - private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead */ @@ -4938,8 +4541,6 @@ public final class Settings { @Deprecated public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED; - private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead */ @@ -4969,9 +4570,6 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON; - private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * @deprecated Use * {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead @@ -4980,9 +4578,6 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY; - private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT} * instead @@ -4990,9 +4585,6 @@ public final class Settings { @Deprecated public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT; - private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} instead */ @@ -5757,8 +5349,6 @@ public final class Settings { @Deprecated public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu"; - private static final Validator BUGREPORT_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead */ @@ -5776,8 +5366,6 @@ public final class Settings { @Deprecated public static final String ALLOW_MOCK_LOCATION = "mock_location"; - private static final Validator ALLOW_MOCK_LOCATION_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting to indicate that on device captions are enabled. * @@ -5786,8 +5374,6 @@ public final class Settings { @SystemApi public static final String ODI_CAPTIONS_ENABLED = "odi_captions_enabled"; - private static final Validator ODI_CAPTIONS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * On Android 8.0 (API level 26) and higher versions of the platform, * a 64-bit number (expressed as a hexadecimal string), unique to @@ -5833,8 +5419,6 @@ public final class Settings { @Deprecated public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON; - private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead */ @@ -5882,9 +5466,6 @@ public final class Settings { @TestApi public static final String AUTOFILL_SERVICE = "autofill_service"; - private static final Validator AUTOFILL_SERVICE_VALIDATOR = - NULLABLE_COMPONENT_NAME_VALIDATOR; - /** * Boolean indicating if Autofill supports field classification. * @@ -6098,8 +5679,6 @@ public final class Settings { */ public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard"; - private static final Validator SHOW_IME_WITH_HARD_KEYBOARD_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Host name and port for global http proxy. Uses ':' seperator for * between host and port. @@ -6367,9 +5946,6 @@ public final class Settings { */ public static final String LOCK_SCREEN_CUSTOM_CLOCK_FACE = "lock_screen_custom_clock_face"; - private static final Validator LOCK_SCREEN_CUSTOM_CLOCK_FACE_VALIDATOR = - JSON_OBJECT_VALIDATOR; - /** * Indicates which clock face to show on lock screen and AOD while docked. * @hide @@ -6435,8 +6011,6 @@ public final class Settings { @Deprecated public static final String USB_MASS_STORAGE_ENABLED = Global.USB_MASS_STORAGE_ENABLED; - private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#USE_GOOGLE_MAIL} instead */ @@ -6448,8 +6022,6 @@ public final class Settings { */ public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled"; - private static final Validator ACCESSIBILITY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting specifying if the accessibility shortcut is enabled. * @hide @@ -6457,8 +6029,6 @@ public final class Settings { public static final String ACCESSIBILITY_SHORTCUT_ENABLED = "accessibility_shortcut_enabled"; - private static final Validator ACCESSIBILITY_SHORTCUT_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting specifying if the accessibility shortcut is enabled. * @hide @@ -6466,9 +6036,6 @@ public final class Settings { public static final String ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN = "accessibility_shortcut_on_lock_screen"; - private static final Validator ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting specifying if the accessibility shortcut dialog has been shown to this user. * @hide @@ -6476,9 +6043,6 @@ public final class Settings { public static final String ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN = "accessibility_shortcut_dialog_shown"; - private static final Validator ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting specifying the accessibility service to be toggled via the accessibility * shortcut. Must be its flattened {@link ComponentName}. @@ -6488,9 +6052,6 @@ public final class Settings { public static final String ACCESSIBILITY_SHORTCUT_TARGET_SERVICE = "accessibility_shortcut_target_service"; - private static final Validator ACCESSIBILITY_SHORTCUT_TARGET_SERVICE_VALIDATOR = - NULLABLE_COMPONENT_NAME_VALIDATOR; - /** * Setting specifying the accessibility service or feature to be toggled via the * accessibility button in the navigation bar. This is either a flattened @@ -6501,32 +6062,17 @@ public final class Settings { public static final String ACCESSIBILITY_BUTTON_TARGET_COMPONENT = "accessibility_button_target_component"; - private static final Validator ACCESSIBILITY_BUTTON_TARGET_COMPONENT_VALIDATOR = - new Validator() { - @Override - public boolean validate(@Nullable String value) { - // technically either ComponentName or class name, but there's proper value - // validation at callsites, so allow any non-null string - return value != null; - } - }; - /** * If touch exploration is enabled. */ public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled"; - private static final Validator TOUCH_EXPLORATION_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * List of the enabled accessibility providers. */ public static final String ENABLED_ACCESSIBILITY_SERVICES = "enabled_accessibility_services"; - private static final Validator ENABLED_ACCESSIBILITY_SERVICES_VALIDATOR = - new ComponentNameListValidator(":"); - /** * List of the accessibility services to which the user has granted * permission to put the device into touch exploration mode. @@ -6536,17 +6082,12 @@ public final class Settings { public static final String TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES = "touch_exploration_granted_accessibility_services"; - private static final Validator TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES_VALIDATOR = - new ComponentNameListValidator(":"); - /** * Whether the Global Actions Panel is enabled. * @hide */ public static final String GLOBAL_ACTIONS_PANEL_ENABLED = "global_actions_panel_enabled"; - private static final Validator GLOBAL_ACTIONS_PANEL_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the Global Actions Panel can be toggled on or off in Settings. * @hide @@ -6568,17 +6109,12 @@ public final class Settings { @SystemApi public static final String HUSH_GESTURE_USED = "hush_gesture_used"; - private static final Validator HUSH_GESTURE_USED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Number of times the user has manually clicked the ringer toggle * @hide */ public static final String MANUAL_RINGER_TOGGLE_COUNT = "manual_ringer_toggle_count"; - private static final Validator MANUAL_RINGER_TOGGLE_COUNT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Whether to play a sound for charging events. * @hide @@ -6600,8 +6136,6 @@ public final class Settings { */ public static final String ZEN_DURATION = "zen_duration"; - private static final Validator ZEN_DURATION_VALIDATOR = ANY_INTEGER_VALIDATOR; - /** @hide */ public static final int ZEN_DURATION_PROMPT = -1; /** @hide */ public static final int ZEN_DURATION_FOREVER = 0; @@ -6637,8 +6171,6 @@ public final class Settings { */ public static final String IN_CALL_NOTIFICATION_ENABLED = "in_call_notification_enabled"; - private static final Validator IN_CALL_NOTIFICATION_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Uri of the slice that's presented on the keyguard. * Defaults to a slice with the date and next alarm. @@ -6665,9 +6197,6 @@ public final class Settings { public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED = "high_text_contrast_enabled"; - private static final Validator ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting that specifies whether the display magnification is enabled via a system-wide * triple tap gesture. Display magnifications allows the user to zoom in the display content @@ -6680,9 +6209,6 @@ public final class Settings { public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED = "accessibility_display_magnification_enabled"; - private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting that specifies whether the display magnification is enabled via a shortcut * affordance within the system's navigation area. Display magnifications allows the user to @@ -6695,9 +6221,6 @@ public final class Settings { public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED = "accessibility_display_magnification_navbar_enabled"; - private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED_VALIDATOR - = BOOLEAN_VALIDATOR; - /** * Setting that specifies what the display magnification scale is. * Display magnifications allows the user to zoom in the display @@ -6711,9 +6234,6 @@ public final class Settings { public static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE = "accessibility_display_magnification_scale"; - private static final Validator ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE_VALIDATOR = - new InclusiveFloatRangeValidator(1.0f, Float.MAX_VALUE); - /** * Unused mangnification setting * @@ -6766,9 +6286,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_ENABLED = "accessibility_captioning_enabled"; - private static final Validator ACCESSIBILITY_CAPTIONING_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting that specifies the language for captions as a locale string, * e.g. en_US. @@ -6779,8 +6296,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_LOCALE = "accessibility_captioning_locale"; - private static final Validator ACCESSIBILITY_CAPTIONING_LOCALE_VALIDATOR = LOCALE_VALIDATOR; - /** * Integer property that specifies the preset style for captions, one * of: @@ -6795,10 +6310,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_PRESET = "accessibility_captioning_preset"; - private static final Validator ACCESSIBILITY_CAPTIONING_PRESET_VALIDATOR = - new DiscreteValueValidator(new String[]{"-1", "0", "1", "2", - "3", "4"}); - /** * Integer property that specifes the background color for captions as a * packed 32-bit color. @@ -6809,9 +6320,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR = "accessibility_captioning_background_color"; - private static final Validator ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR_VALIDATOR = - ANY_INTEGER_VALIDATOR; - /** * Integer property that specifes the foreground color for captions as a * packed 32-bit color. @@ -6822,9 +6330,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR = "accessibility_captioning_foreground_color"; - private static final Validator ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR_VALIDATOR = - ANY_INTEGER_VALIDATOR; - /** * Integer property that specifes the edge type for captions, one of: * <ul> @@ -6839,9 +6344,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_EDGE_TYPE = "accessibility_captioning_edge_type"; - private static final Validator ACCESSIBILITY_CAPTIONING_EDGE_TYPE_VALIDATOR = - new DiscreteValueValidator(new String[]{"0", "1", "2"}); - /** * Integer property that specifes the edge color for captions as a * packed 32-bit color. @@ -6853,9 +6355,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_EDGE_COLOR = "accessibility_captioning_edge_color"; - private static final Validator ACCESSIBILITY_CAPTIONING_EDGE_COLOR_VALIDATOR = - ANY_INTEGER_VALIDATOR; - /** * Integer property that specifes the window color for captions as a * packed 32-bit color. @@ -6866,9 +6365,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_WINDOW_COLOR = "accessibility_captioning_window_color"; - private static final Validator ACCESSIBILITY_CAPTIONING_WINDOW_COLOR_VALIDATOR = - ANY_INTEGER_VALIDATOR; - /** * String property that specifies the typeface for captions, one of: * <ul> @@ -6885,10 +6381,6 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_TYPEFACE = "accessibility_captioning_typeface"; - private static final Validator ACCESSIBILITY_CAPTIONING_TYPEFACE_VALIDATOR = - new DiscreteValueValidator(new String[]{"DEFAULT", - "MONOSPACE", "SANS_SERIF", "SERIF"}); - /** * Floating point property that specifies font scaling for captions. * @@ -6897,18 +6389,12 @@ public final class Settings { public static final String ACCESSIBILITY_CAPTIONING_FONT_SCALE = "accessibility_captioning_font_scale"; - private static final Validator ACCESSIBILITY_CAPTIONING_FONT_SCALE_VALIDATOR = - new InclusiveFloatRangeValidator(0.5f, 2.0f); - /** * Setting that specifies whether display color inversion is enabled. */ public static final String ACCESSIBILITY_DISPLAY_INVERSION_ENABLED = "accessibility_display_inversion_enabled"; - private static final Validator ACCESSIBILITY_DISPLAY_INVERSION_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting that specifies whether display color space adjustment is * enabled. @@ -6919,9 +6405,6 @@ public final class Settings { public static final String ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED = "accessibility_display_daltonizer_enabled"; - private static final Validator ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Integer property that specifies the type of color space adjustment to * perform. Valid values are defined in AccessibilityManager and Settings arrays.xml: @@ -6938,10 +6421,6 @@ public final class Settings { public static final String ACCESSIBILITY_DISPLAY_DALTONIZER = "accessibility_display_daltonizer"; - private static final Validator ACCESSIBILITY_DISPLAY_DALTONIZER_VALIDATOR = - new DiscreteValueValidator( - new String[] {"-1", "0", "11", "12", "13"}); - /** * Setting that specifies whether automatic click when the mouse pointer stops moving is * enabled. @@ -6952,9 +6431,6 @@ public final class Settings { public static final String ACCESSIBILITY_AUTOCLICK_ENABLED = "accessibility_autoclick_enabled"; - private static final Validator ACCESSIBILITY_AUTOCLICK_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Integer setting specifying amount of time in ms the mouse pointer has to stay still * before performing click when {@link #ACCESSIBILITY_AUTOCLICK_ENABLED} is set. @@ -6965,9 +6441,6 @@ public final class Settings { public static final String ACCESSIBILITY_AUTOCLICK_DELAY = "accessibility_autoclick_delay"; - private static final Validator ACCESSIBILITY_AUTOCLICK_DELAY_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Whether or not larger size icons are used for the pointer of mouse/trackpad for * accessibility. @@ -6978,9 +6451,6 @@ public final class Settings { public static final String ACCESSIBILITY_LARGE_POINTER_ICON = "accessibility_large_pointer_icon"; - private static final Validator ACCESSIBILITY_LARGE_POINTER_ICON_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * The timeout for considering a press to be a long press in milliseconds. * @hide @@ -6988,9 +6458,6 @@ public final class Settings { @UnsupportedAppUsage public static final String LONG_PRESS_TIMEOUT = "long_press_timeout"; - private static final Validator LONG_PRESS_TIMEOUT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * 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. @@ -7046,8 +6513,6 @@ public final class Settings { */ public static final String DISPLAY_DENSITY_FORCED = "display_density_forced"; - static final Validator DISPLAY_DENSITY_FORCED_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Setting to always use the default text-to-speech settings regardless * of the application settings. @@ -7065,22 +6530,16 @@ public final class Settings { */ public static final String TTS_DEFAULT_RATE = "tts_default_rate"; - private static final Validator TTS_DEFAULT_RATE_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Default text-to-speech engine pitch. 100 = 1x */ public static final String TTS_DEFAULT_PITCH = "tts_default_pitch"; - private static final Validator TTS_DEFAULT_PITCH_VALIDATOR = NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Default text-to-speech engine. */ public static final String TTS_DEFAULT_SYNTH = "tts_default_synth"; - private static final Validator TTS_DEFAULT_SYNTH_VALIDATOR = PACKAGE_NAME_VALIDATOR; - /** * Default text-to-speech language. * @@ -7128,16 +6587,11 @@ public final class Settings { */ public static final String TTS_DEFAULT_LOCALE = "tts_default_locale"; - private static final Validator TTS_DEFAULT_LOCALE_VALIDATOR = TTS_LIST_VALIDATOR; - /** * Space delimited list of plugin packages that are enabled. */ public static final String TTS_ENABLED_PLUGINS = "tts_enabled_plugins"; - private static final Validator TTS_ENABLED_PLUGINS_VALIDATOR = - new PackageNameListValidator(" "); - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} * instead. @@ -7146,9 +6600,6 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON; - private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} * instead. @@ -7157,9 +6608,6 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY; - private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT} * instead. @@ -7168,9 +6616,6 @@ public final class Settings { public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Global.WIFI_NUM_OPEN_NETWORKS_KEPT; - private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_ON} * instead. @@ -7329,9 +6774,6 @@ public final class Settings { public static final String PREFERRED_TTY_MODE = "preferred_tty_mode"; - private static final Validator PREFERRED_TTY_MODE_VALIDATOR = - new DiscreteValueValidator(new String[]{"0", "1", "2", "3"}); - /** * Whether the enhanced voice privacy mode is enabled. * 0 = normal voice privacy @@ -7340,8 +6782,6 @@ public final class Settings { */ public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled"; - private static final Validator ENHANCED_VOICE_PRIVACY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the TTY mode mode is enabled. * 0 = disabled @@ -7350,8 +6790,6 @@ public final class Settings { */ public static final String TTY_MODE_ENABLED = "tty_mode_enabled"; - private static final Validator TTY_MODE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * User-selected RTT mode. When on, outgoing and incoming calls will be answered as RTT * calls when supported by the device and carrier. Boolean value. @@ -7360,8 +6798,6 @@ public final class Settings { */ public static final String RTT_CALLING_MODE = "rtt_calling_mode"; - private static final Validator RTT_CALLING_MODE_VALIDATOR = BOOLEAN_VALIDATOR; - /** /** * Controls whether settings backup is enabled. @@ -7539,32 +6975,24 @@ public final class Settings { */ public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd"; - private static final Validator MOUNT_PLAY_NOTIFICATION_SND_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true) * @hide */ public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart"; - private static final Validator MOUNT_UMS_AUTOSTART_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true) * @hide */ public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt"; - private static final Validator MOUNT_UMS_PROMPT_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true) * @hide */ public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled"; - private static final Validator MOUNT_UMS_NOTIFY_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * If nonzero, ANRs in invisible background processes bring up a dialog. * Otherwise, the process will be silently killed. @@ -7583,9 +7011,6 @@ public final class Settings { public static final String SHOW_FIRST_CRASH_DIALOG_DEV_OPTION = "show_first_crash_dialog_dev_option"; - private static final Validator SHOW_FIRST_CRASH_DIALOG_DEV_OPTION_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * The {@link ComponentName} string of the service to be used as the voice recognition * service. @@ -7644,9 +7069,6 @@ public final class Settings { @UnsupportedAppUsage public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior"; - private static final Validator INCALL_POWER_BUTTON_BEHAVIOR_VALIDATOR = - new DiscreteValueValidator(new String[]{"1", "2"}); - /** * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen". * @hide @@ -7702,8 +7124,6 @@ public final class Settings { */ public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled"; - private static final Validator WAKE_GESTURE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the device should doze if configured. * @hide @@ -7711,8 +7131,6 @@ public final class Settings { @UnsupportedAppUsage public static final String DOZE_ENABLED = "doze_enabled"; - private static final Validator DOZE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Indicates whether doze should be always on. * <p> @@ -7724,16 +7142,12 @@ public final class Settings { @TestApi public static final String DOZE_ALWAYS_ON = "doze_always_on"; - private static final Validator DOZE_ALWAYS_ON_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the device should pulse on pick up gesture. * @hide */ public static final String DOZE_PICK_UP_GESTURE = "doze_pulse_on_pick_up"; - private static final Validator DOZE_PICK_UP_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the device should pulse on long press gesture. * @hide @@ -7746,24 +7160,18 @@ public final class Settings { */ public static final String DOZE_DOUBLE_TAP_GESTURE = "doze_pulse_on_double_tap"; - private static final Validator DOZE_DOUBLE_TAP_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the device should respond to the SLPI tap gesture. * @hide */ public static final String DOZE_TAP_SCREEN_GESTURE = "doze_tap_gesture"; - private static final Validator DOZE_TAP_SCREEN_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Gesture that wakes up the display, showing some version of the lock screen. * @hide */ public static final String DOZE_WAKE_LOCK_SCREEN_GESTURE = "doze_wake_screen_gesture"; - private static final Validator DOZE_WAKE_LOCK_SCREEN_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Gesture that wakes up the display, toggling between {@link Display.STATE_OFF} and * {@link Display.STATE_DOZE}. @@ -7771,16 +7179,12 @@ public final class Settings { */ public static final String DOZE_WAKE_DISPLAY_GESTURE = "doze_wake_display_gesture"; - private static final Validator DOZE_WAKE_DISPLAY_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Gesture that skips media. * @hide */ public static final String SKIP_GESTURE = "skip_gesture"; - private static final Validator SKIP_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Count of successful gestures. * @hide @@ -7793,9 +7197,6 @@ public final class Settings { */ public static final String SKIP_TOUCH_COUNT = "skip_touch_count"; - private static final Validator SKIP_GESTURE_COUNT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Direction to advance media for skip gesture * @hide @@ -7803,21 +7204,11 @@ public final class Settings { public static final String SKIP_DIRECTION = "skip_gesture_direction"; /** - * Only used if FeatureFlag "settings_skip_direction_mutable" is enabled. - * If feature flag is disabled, should assume SKIP_DIRECTION = 0. - * 0 / false = right to left to advance to next - * 1 / true = left to right to advance to next - */ - private static final Validator SKIP_DIRECTION_VALIDATOR = BOOLEAN_VALIDATOR; - - /** * Gesture that silences sound (alarms, notification, calls). * @hide */ public static final String SILENCE_GESTURE = "silence_gesture"; - private static final Validator SILENCE_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Count of successful silence alarms gestures. * @hide @@ -7854,9 +7245,6 @@ public final class Settings { */ public static final String SILENCE_CALL_TOUCH_COUNT = "silence_call_touch_count"; - private static final Validator SILENCE_GESTURE_COUNT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * The current night mode that has been selected by the user. Owned * and controlled by UiModeManagerService. Constants are as per @@ -7865,17 +7253,12 @@ public final class Settings { */ public static final String UI_NIGHT_MODE = "ui_night_mode"; - private static final Validator UI_NIGHT_MODE_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 2); - /** * Whether screensavers are enabled. * @hide */ public static final String SCREENSAVER_ENABLED = "screensaver_enabled"; - private static final Validator SCREENSAVER_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The user's chosen screensaver components. * @@ -7885,9 +7268,6 @@ public final class Settings { */ public static final String SCREENSAVER_COMPONENTS = "screensaver_components"; - private static final Validator SCREENSAVER_COMPONENTS_VALIDATOR = - new ComponentNameListValidator(","); - /** * If screensavers are enabled, whether the screensaver should be automatically launched * when the device is inserted into a (desk) dock. @@ -7895,8 +7275,6 @@ public final class Settings { */ public static final String SCREENSAVER_ACTIVATE_ON_DOCK = "screensaver_activate_on_dock"; - private static final Validator SCREENSAVER_ACTIVATE_ON_DOCK_VALIDATOR = BOOLEAN_VALIDATOR; - /** * If screensavers are enabled, whether the screensaver should be automatically launched * when the screen times out when not on battery. @@ -7904,8 +7282,6 @@ public final class Settings { */ public static final String SCREENSAVER_ACTIVATE_ON_SLEEP = "screensaver_activate_on_sleep"; - private static final Validator SCREENSAVER_ACTIVATE_ON_SLEEP_VALIDATOR = BOOLEAN_VALIDATOR; - /** * If screensavers are enabled, the default screensaver component. * @hide @@ -7919,9 +7295,6 @@ public final class Settings { @UnsupportedAppUsage public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component"; - private static final Validator NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR = - COMPONENT_NAME_VALIDATOR; - /** * Whether NFC payment is handled by the foreground application or a default. * @hide @@ -8037,9 +7410,6 @@ public final class Settings { public static final String ENABLED_NOTIFICATION_ASSISTANT = "enabled_notification_assistant"; - private static final Validator ENABLED_NOTIFICATION_ASSISTANT_VALIDATOR = - new ComponentNameListValidator(":"); - /** * Read only list of the service components that the current user has explicitly allowed to * see all of the user's notifications, separated by ':'. @@ -8052,9 +7422,6 @@ public final class Settings { @UnsupportedAppUsage public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners"; - private static final Validator ENABLED_NOTIFICATION_LISTENERS_VALIDATOR = - new ComponentNameListValidator(":"); - /** * Read only list of the packages that the current user has explicitly allowed to * manage do not disturb, separated by ':'. @@ -8067,9 +7434,6 @@ public final class Settings { public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages"; - private static final Validator ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR = - new PackageNameListValidator(":"); - /** * Defines whether managed profile ringtones should be synced from it's parent profile * <p> @@ -8083,8 +7447,6 @@ public final class Settings { @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds"; - private static final Validator SYNC_PARENT_SOUNDS_VALIDATOR = BOOLEAN_VALIDATOR; - /** @hide */ @UnsupportedAppUsage public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations"; @@ -8218,8 +7580,6 @@ public final class Settings { */ public static final String DOUBLE_TAP_TO_WAKE = "double_tap_to_wake"; - private static final Validator DOUBLE_TAP_TO_WAKE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The current assistant component. It could be a voice interaction service, * or an activity that handles ACTION_ASSIST, or empty which means using the default @@ -8240,8 +7600,6 @@ public final class Settings { */ public static final String CAMERA_GESTURE_DISABLED = "camera_gesture_disabled"; - private static final Validator CAMERA_GESTURE_DISABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the camera launch gesture to double tap the power button when the screen is off * should be disabled. @@ -8251,9 +7609,6 @@ public final class Settings { public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED = "camera_double_tap_power_gesture_disabled"; - private static final Validator CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether the camera double twist gesture to flip between front and back mode should be * enabled. @@ -8263,9 +7618,6 @@ public final class Settings { public static final String CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED = "camera_double_twist_to_flip_enabled"; - private static final Validator CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether or not the smart camera lift trigger that launches the camera when the user moves * the phone into a position for taking photos should be enabled. @@ -8302,9 +7654,6 @@ public final class Settings { */ public static final String FACE_UNLOCK_KEYGUARD_ENABLED = "face_unlock_keyguard_enabled"; - private static final Validator FACE_UNLOCK_KEYGUARD_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether or not face unlock dismisses the keyguard. * @hide @@ -8312,9 +7661,6 @@ public final class Settings { public static final String FACE_UNLOCK_DISMISSES_KEYGUARD = "face_unlock_dismisses_keyguard"; - private static final Validator FACE_UNLOCK_DISMISSES_KEYGUARD_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether or not media is shown automatically when bypassing as a heads up. * @hide @@ -8322,9 +7668,6 @@ public final class Settings { public static final String SHOW_MEDIA_WHEN_BYPASSING = "show_media_when_bypassing"; - private static final Validator SHOW_MEDIA_WHEN_BYPASSING_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether or not face unlock requires attention. This is a cached value, the source of * truth is obtained through the HAL. @@ -8348,9 +7691,6 @@ public final class Settings { */ public static final String FACE_UNLOCK_APP_ENABLED = "face_unlock_app_enabled"; - private static final Validator FACE_UNLOCK_APP_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether or not face unlock always requires user confirmation, meaning {@link * android.hardware.biometrics.BiometricPrompt.Builder#setConfirmationRequired(boolean)} @@ -8361,9 +7701,6 @@ public final class Settings { public static final String FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION = "face_unlock_always_require_confirmation"; - private static final Validator FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether or not debugging is enabled. * @hide @@ -8378,9 +7715,6 @@ public final class Settings { */ public static final String ASSIST_GESTURE_ENABLED = "assist_gesture_enabled"; - private static final Validator ASSIST_GESTURE_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Sensitivity control for the assist gesture. * @@ -8396,9 +7730,6 @@ public final class Settings { public static final String ASSIST_GESTURE_SILENCE_ALERTS_ENABLED = "assist_gesture_silence_alerts_enabled"; - private static final Validator ASSIST_GESTURE_SILENCE_ALERTS_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Whether the assist gesture should wake the phone. * @@ -8407,9 +7738,6 @@ public final class Settings { public static final String ASSIST_GESTURE_WAKE_ENABLED = "assist_gesture_wake_enabled"; - private static final Validator ASSIST_GESTURE_WAKE_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Indicates whether the Assist Gesture Deferred Setup has been completed. * <p> @@ -8426,18 +7754,12 @@ public final class Settings { */ public static final String TRUST_AGENTS_EXTEND_UNLOCK = "trust_agents_extend_unlock"; - private static final Validator TRUST_AGENTS_EXTEND_UNLOCK_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Control whether the screen locks when trust is lost. * @hide */ public static final String LOCK_SCREEN_WHEN_TRUST_LOST = "lock_screen_when_trust_lost"; - private static final Validator LOCK_SCREEN_WHEN_TRUST_LOST_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Control whether Night display is currently activated. * @hide @@ -8450,9 +7772,6 @@ public final class Settings { */ public static final String NIGHT_DISPLAY_AUTO_MODE = "night_display_auto_mode"; - private static final Validator NIGHT_DISPLAY_AUTO_MODE_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 2); - /** * Control the color temperature of Night Display, represented in Kelvin. * @hide @@ -8460,9 +7779,6 @@ public final class Settings { public static final String NIGHT_DISPLAY_COLOR_TEMPERATURE = "night_display_color_temperature"; - private static final Validator NIGHT_DISPLAY_COLOR_TEMPERATURE_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Custom time when Night display is scheduled to activate. * Represented as milliseconds from midnight (e.g. 79200000 == 10pm). @@ -8471,9 +7787,6 @@ public final class Settings { public static final String NIGHT_DISPLAY_CUSTOM_START_TIME = "night_display_custom_start_time"; - private static final Validator NIGHT_DISPLAY_CUSTOM_START_TIME_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Custom time when Night display is scheduled to deactivate. * Represented as milliseconds from midnight (e.g. 21600000 == 6am). @@ -8481,9 +7794,6 @@ public final class Settings { */ public static final String NIGHT_DISPLAY_CUSTOM_END_TIME = "night_display_custom_end_time"; - private static final Validator NIGHT_DISPLAY_CUSTOM_END_TIME_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * A String representing the LocalDateTime when Night display was last activated. Use to * decide whether to apply the current activated state after a reboot or user change. In @@ -8499,9 +7809,6 @@ public final class Settings { */ public static final String DISPLAY_WHITE_BALANCE_ENABLED = "display_white_balance_enabled"; - private static final Validator DISPLAY_WHITE_BALANCE_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Names of the service components that the current user has explicitly allowed to * be a VR mode listener, separated by ':'. @@ -8511,9 +7818,6 @@ public final class Settings { @TestApi public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners"; - private static final Validator ENABLED_VR_LISTENERS_VALIDATOR = - new ComponentNameListValidator(":"); - /** * Behavior of the display while in VR mode. * @@ -8523,9 +7827,6 @@ public final class Settings { */ public static final String VR_DISPLAY_MODE = "vr_display_mode"; - private static final Validator VR_DISPLAY_MODE_VALIDATOR = - new DiscreteValueValidator(new String[]{"0", "1"}); - /** * Lower the display persistence while the system is in VR mode. * @@ -8590,9 +7891,6 @@ public final class Settings { public static final String AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN = "automatic_storage_manager_days_to_retain"; - private static final Validator AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Default number of days of information for the automatic storage manager to retain. * @@ -8608,7 +7906,6 @@ public final class Settings { public static final String AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED = "automatic_storage_manager_bytes_cleared"; - /** * Last run time for the automatic storage manager. * @@ -8616,7 +7913,6 @@ public final class Settings { */ public static final String AUTOMATIC_STORAGE_MANAGER_LAST_RUN = "automatic_storage_manager_last_run"; - /** * If the automatic storage manager has been disabled by policy. Note that this doesn't * mean that the automatic storage manager is prevented from being re-enabled -- this only @@ -8634,8 +7930,6 @@ public final class Settings { public static final String SYSTEM_NAVIGATION_KEYS_ENABLED = "system_navigation_keys_enabled"; - private static final Validator SYSTEM_NAVIGATION_KEYS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Holds comma separated list of ordering of QS tiles. * @@ -8643,8 +7937,6 @@ public final class Settings { */ public static final String QS_TILES = "sysui_qs_tiles"; - private static final Validator QS_TILES_VALIDATOR = TILE_LIST_VALIDATOR; - /** * Specifies whether the web action API is enabled. * @@ -8681,8 +7973,6 @@ public final class Settings { @TestApi public static final String NOTIFICATION_BADGING = "notification_badging"; - private static final Validator NOTIFICATION_BADGING_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether the notification bubbles are globally enabled * The value is boolean (1 or 0). @@ -8691,8 +7981,6 @@ public final class Settings { @TestApi public static final String NOTIFICATION_BUBBLES = "notification_bubbles"; - private static final Validator NOTIFICATION_BUBBLES_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether notifications are dismissed by a right-to-left swipe (instead of a left-to-right * swipe). @@ -8701,24 +7989,18 @@ public final class Settings { */ public static final String NOTIFICATION_DISMISS_RTL = "notification_dismiss_rtl"; - private static final Validator NOTIFICATION_DISMISS_RTL_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Comma separated list of QS tiles that have been auto-added already. * @hide */ public static final String QS_AUTO_ADDED_TILES = "qs_auto_tiles"; - private static final Validator QS_AUTO_ADDED_TILES_VALIDATOR = TILE_LIST_VALIDATOR; - /** * Whether the Lockdown button should be shown in the power menu. * @hide */ public static final String LOCKDOWN_IN_POWER_MENU = "lockdown_in_power_menu"; - private static final Validator LOCKDOWN_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Backup manager behavioral parameters. * This is encoded as a key=value list, separated by commas. Ex: @@ -8790,9 +8072,6 @@ public final class Settings { @SystemApi public static final int VOLUME_HUSH_MUTE = 2; - private static final Validator VOLUME_HUSH_GESTURE_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * The number of times (integer) the user has manually enabled battery saver. * @hide @@ -8869,9 +8148,6 @@ public final class Settings { public static final String THEME_CUSTOMIZATION_OVERLAY_PACKAGES = "theme_customization_overlay_packages"; - private static final Validator THEME_CUSTOMIZATION_OVERLAY_PACKAGES_VALIDATOR = - JSON_OBJECT_VALIDATOR; - /** * Navigation bar mode. * 0 = 3 button @@ -8881,8 +8157,6 @@ public final class Settings { */ public static final String NAVIGATION_MODE = "navigation_mode"; - private static final Validator NAVIGATION_MODE_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "1", "2"}); /** * Controls whether aware is enabled. @@ -8890,16 +8164,12 @@ public final class Settings { */ public static final String AWARE_ENABLED = "aware_enabled"; - private static final Validator AWARE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Controls whether aware_lock is enabled. * @hide */ public static final String AWARE_LOCK_ENABLED = "aware_lock_enabled"; - private static final Validator AWARE_LOCK_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * This are the settings to be backed up. * @@ -9061,201 +8331,6 @@ public final class Settings { }; /** - * All settings in {@link SETTINGS_TO_BACKUP} and {@link DEVICE_SPECIFIC_SETTINGS_TO_BACKUP} - * array *must* have a non-null validator, otherwise they won't be restored. - * - * @hide - */ - public static final Map<String, Validator> VALIDATORS = new ArrayMap<>(); - static { - VALIDATORS.put(BUGREPORT_IN_POWER_MENU, BUGREPORT_IN_POWER_MENU_VALIDATOR); - VALIDATORS.put(ALLOW_MOCK_LOCATION, ALLOW_MOCK_LOCATION_VALIDATOR); - VALIDATORS.put(USB_MASS_STORAGE_ENABLED, USB_MASS_STORAGE_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, - ACCESSIBILITY_DISPLAY_INVERSION_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_DISPLAY_DALTONIZER, - ACCESSIBILITY_DISPLAY_DALTONIZER_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, - ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, - ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, - ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED_VALIDATOR); - VALIDATORS.put(AUTOFILL_SERVICE, AUTOFILL_SERVICE_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, - ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE_VALIDATOR); - VALIDATORS.put(ENABLED_ACCESSIBILITY_SERVICES, - ENABLED_ACCESSIBILITY_SERVICES_VALIDATOR); - VALIDATORS.put(ENABLED_VR_LISTENERS, ENABLED_VR_LISTENERS_VALIDATOR); - VALIDATORS.put(TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, - TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES_VALIDATOR); - VALIDATORS.put(TOUCH_EXPLORATION_ENABLED, TOUCH_EXPLORATION_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_ENABLED, ACCESSIBILITY_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, - ACCESSIBILITY_SHORTCUT_TARGET_SERVICE_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_BUTTON_TARGET_COMPONENT, - ACCESSIBILITY_BUTTON_TARGET_COMPONENT_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, - ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_SHORTCUT_ENABLED, - ACCESSIBILITY_SHORTCUT_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, - ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, - ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_PRESET, - ACCESSIBILITY_CAPTIONING_PRESET_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_ENABLED, - ACCESSIBILITY_CAPTIONING_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_LOCALE, - ACCESSIBILITY_CAPTIONING_LOCALE_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR, - ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR, - ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_EDGE_TYPE, - ACCESSIBILITY_CAPTIONING_EDGE_TYPE_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_EDGE_COLOR, - ACCESSIBILITY_CAPTIONING_EDGE_COLOR_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_TYPEFACE, - ACCESSIBILITY_CAPTIONING_TYPEFACE_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_FONT_SCALE, - ACCESSIBILITY_CAPTIONING_FONT_SCALE_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_CAPTIONING_WINDOW_COLOR, - ACCESSIBILITY_CAPTIONING_WINDOW_COLOR_VALIDATOR); - VALIDATORS.put(TTS_DEFAULT_RATE, TTS_DEFAULT_RATE_VALIDATOR); - VALIDATORS.put(TTS_DEFAULT_PITCH, TTS_DEFAULT_PITCH_VALIDATOR); - VALIDATORS.put(TTS_DEFAULT_SYNTH, TTS_DEFAULT_SYNTH_VALIDATOR); - VALIDATORS.put(TTS_ENABLED_PLUGINS, TTS_ENABLED_PLUGINS_VALIDATOR); - VALIDATORS.put(TTS_DEFAULT_LOCALE, TTS_DEFAULT_LOCALE_VALIDATOR); - VALIDATORS.put(SHOW_IME_WITH_HARD_KEYBOARD, SHOW_IME_WITH_HARD_KEYBOARD_VALIDATOR); - VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, - WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR); - VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, - WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR); - VALIDATORS.put(WIFI_NUM_OPEN_NETWORKS_KEPT, WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR); - VALIDATORS.put(MOUNT_PLAY_NOTIFICATION_SND, MOUNT_PLAY_NOTIFICATION_SND_VALIDATOR); - VALIDATORS.put(MOUNT_UMS_AUTOSTART, MOUNT_UMS_AUTOSTART_VALIDATOR); - VALIDATORS.put(MOUNT_UMS_PROMPT, MOUNT_UMS_PROMPT_VALIDATOR); - VALIDATORS.put(MOUNT_UMS_NOTIFY_ENABLED, MOUNT_UMS_NOTIFY_ENABLED_VALIDATOR); - VALIDATORS.put(DOUBLE_TAP_TO_WAKE, DOUBLE_TAP_TO_WAKE_VALIDATOR); - VALIDATORS.put(WAKE_GESTURE_ENABLED, WAKE_GESTURE_ENABLED_VALIDATOR); - VALIDATORS.put(LONG_PRESS_TIMEOUT, LONG_PRESS_TIMEOUT_VALIDATOR); - VALIDATORS.put(CAMERA_GESTURE_DISABLED, CAMERA_GESTURE_DISABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_AUTOCLICK_ENABLED, - ACCESSIBILITY_AUTOCLICK_ENABLED_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_AUTOCLICK_DELAY, ACCESSIBILITY_AUTOCLICK_DELAY_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_LARGE_POINTER_ICON, - ACCESSIBILITY_LARGE_POINTER_ICON_VALIDATOR); - VALIDATORS.put(PREFERRED_TTY_MODE, PREFERRED_TTY_MODE_VALIDATOR); - VALIDATORS.put(ENHANCED_VOICE_PRIVACY_ENABLED, - ENHANCED_VOICE_PRIVACY_ENABLED_VALIDATOR); - VALIDATORS.put(TTY_MODE_ENABLED, TTY_MODE_ENABLED_VALIDATOR); - VALIDATORS.put(RTT_CALLING_MODE, RTT_CALLING_MODE_VALIDATOR); - VALIDATORS.put(INCALL_POWER_BUTTON_BEHAVIOR, INCALL_POWER_BUTTON_BEHAVIOR_VALIDATOR); - VALIDATORS.put(NIGHT_DISPLAY_CUSTOM_START_TIME, - NIGHT_DISPLAY_CUSTOM_START_TIME_VALIDATOR); - VALIDATORS.put(NIGHT_DISPLAY_CUSTOM_END_TIME, NIGHT_DISPLAY_CUSTOM_END_TIME_VALIDATOR); - VALIDATORS.put(NIGHT_DISPLAY_COLOR_TEMPERATURE, - NIGHT_DISPLAY_COLOR_TEMPERATURE_VALIDATOR); - VALIDATORS.put(NIGHT_DISPLAY_AUTO_MODE, NIGHT_DISPLAY_AUTO_MODE_VALIDATOR); - VALIDATORS.put(DISPLAY_WHITE_BALANCE_ENABLED, DISPLAY_WHITE_BALANCE_ENABLED_VALIDATOR); - VALIDATORS.put(SYNC_PARENT_SOUNDS, SYNC_PARENT_SOUNDS_VALIDATOR); - VALIDATORS.put(CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, - CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED_VALIDATOR); - VALIDATORS.put(CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, - CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED_VALIDATOR); - VALIDATORS.put(SYSTEM_NAVIGATION_KEYS_ENABLED, - SYSTEM_NAVIGATION_KEYS_ENABLED_VALIDATOR); - VALIDATORS.put(QS_TILES, QS_TILES_VALIDATOR); - VALIDATORS.put(DOZE_ENABLED, DOZE_ENABLED_VALIDATOR); - VALIDATORS.put(DOZE_ALWAYS_ON, DOZE_ALWAYS_ON_VALIDATOR); - VALIDATORS.put(DOZE_PICK_UP_GESTURE, DOZE_PICK_UP_GESTURE_VALIDATOR); - VALIDATORS.put(DOZE_DOUBLE_TAP_GESTURE, DOZE_DOUBLE_TAP_GESTURE_VALIDATOR); - VALIDATORS.put(DOZE_TAP_SCREEN_GESTURE, DOZE_TAP_SCREEN_GESTURE_VALIDATOR); - VALIDATORS.put(DOZE_WAKE_LOCK_SCREEN_GESTURE, DOZE_WAKE_LOCK_SCREEN_GESTURE_VALIDATOR); - VALIDATORS.put(DOZE_WAKE_DISPLAY_GESTURE, DOZE_WAKE_DISPLAY_GESTURE_VALIDATOR); - VALIDATORS.put(NFC_PAYMENT_DEFAULT_COMPONENT, NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR); - VALIDATORS.put(AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN, - AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_VALIDATOR); - VALIDATORS.put(FACE_UNLOCK_KEYGUARD_ENABLED, FACE_UNLOCK_KEYGUARD_ENABLED_VALIDATOR); - VALIDATORS.put(FACE_UNLOCK_DISMISSES_KEYGUARD, - FACE_UNLOCK_DISMISSES_KEYGUARD_VALIDATOR); - VALIDATORS.put(SHOW_MEDIA_WHEN_BYPASSING, SHOW_MEDIA_WHEN_BYPASSING_VALIDATOR); - VALIDATORS.put(FACE_UNLOCK_APP_ENABLED, FACE_UNLOCK_APP_ENABLED_VALIDATOR); - VALIDATORS.put(FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, - FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION_VALIDATOR); - VALIDATORS.put(ASSIST_GESTURE_ENABLED, ASSIST_GESTURE_ENABLED_VALIDATOR); - VALIDATORS.put(ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, - ASSIST_GESTURE_SILENCE_ALERTS_ENABLED_VALIDATOR); - VALIDATORS.put(ASSIST_GESTURE_WAKE_ENABLED, ASSIST_GESTURE_WAKE_ENABLED_VALIDATOR); - VALIDATORS.put(VR_DISPLAY_MODE, VR_DISPLAY_MODE_VALIDATOR); - VALIDATORS.put(NOTIFICATION_BADGING, NOTIFICATION_BADGING_VALIDATOR); - VALIDATORS.put(NOTIFICATION_BUBBLES, NOTIFICATION_BUBBLES_VALIDATOR); - VALIDATORS.put(NOTIFICATION_DISMISS_RTL, NOTIFICATION_DISMISS_RTL_VALIDATOR); - VALIDATORS.put(QS_AUTO_ADDED_TILES, QS_AUTO_ADDED_TILES_VALIDATOR); - VALIDATORS.put(SCREENSAVER_ENABLED, SCREENSAVER_ENABLED_VALIDATOR); - VALIDATORS.put(SCREENSAVER_COMPONENTS, SCREENSAVER_COMPONENTS_VALIDATOR); - VALIDATORS.put(SCREENSAVER_ACTIVATE_ON_DOCK, SCREENSAVER_ACTIVATE_ON_DOCK_VALIDATOR); - VALIDATORS.put(SCREENSAVER_ACTIVATE_ON_SLEEP, SCREENSAVER_ACTIVATE_ON_SLEEP_VALIDATOR); - VALIDATORS.put(LOCKDOWN_IN_POWER_MENU, LOCKDOWN_IN_POWER_MENU_VALIDATOR); - VALIDATORS.put(SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, - SHOW_FIRST_CRASH_DIALOG_DEV_OPTION_VALIDATOR); - VALIDATORS.put(VOLUME_HUSH_GESTURE, VOLUME_HUSH_GESTURE_VALIDATOR); - VALIDATORS.put(ENABLED_NOTIFICATION_LISTENERS, - ENABLED_NOTIFICATION_LISTENERS_VALIDATOR); //legacy restore setting - VALIDATORS.put(ENABLED_NOTIFICATION_ASSISTANT, - ENABLED_NOTIFICATION_ASSISTANT_VALIDATOR); //legacy restore setting - VALIDATORS.put(ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES, - ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES_VALIDATOR); //legacy restore setting - VALIDATORS.put(HUSH_GESTURE_USED, HUSH_GESTURE_USED_VALIDATOR); - VALIDATORS.put(MANUAL_RINGER_TOGGLE_COUNT, MANUAL_RINGER_TOGGLE_COUNT_VALIDATOR); - VALIDATORS.put(IN_CALL_NOTIFICATION_ENABLED, IN_CALL_NOTIFICATION_ENABLED_VALIDATOR); - VALIDATORS.put(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, BOOLEAN_VALIDATOR); - VALIDATORS.put(LOCK_SCREEN_SHOW_NOTIFICATIONS, BOOLEAN_VALIDATOR); - VALIDATORS.put(LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, BOOLEAN_VALIDATOR); - VALIDATORS.put(SHOW_NOTIFICATION_SNOOZE, BOOLEAN_VALIDATOR); - VALIDATORS.put(ZEN_DURATION, ZEN_DURATION_VALIDATOR); - VALIDATORS.put(SHOW_ZEN_UPGRADE_NOTIFICATION, BOOLEAN_VALIDATOR); - VALIDATORS.put(SHOW_ZEN_SETTINGS_SUGGESTION, BOOLEAN_VALIDATOR); - VALIDATORS.put(ZEN_SETTINGS_UPDATED, BOOLEAN_VALIDATOR); - VALIDATORS.put(ZEN_SETTINGS_SUGGESTION_VIEWED, BOOLEAN_VALIDATOR); - VALIDATORS.put(CHARGING_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); - VALIDATORS.put(CHARGING_VIBRATION_ENABLED, BOOLEAN_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, - NON_NEGATIVE_INTEGER_VALIDATOR); - VALIDATORS.put(ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, NON_NEGATIVE_INTEGER_VALIDATOR); - VALIDATORS.put(USER_SETUP_COMPLETE, BOOLEAN_VALIDATOR); - VALIDATORS.put(ASSIST_GESTURE_SETUP_COMPLETE, BOOLEAN_VALIDATOR); - VALIDATORS.put(NOTIFICATION_NEW_INTERRUPTION_MODEL, BOOLEAN_VALIDATOR); - VALIDATORS.put(TRUST_AGENTS_EXTEND_UNLOCK, TRUST_AGENTS_EXTEND_UNLOCK_VALIDATOR); - VALIDATORS.put(LOCK_SCREEN_CUSTOM_CLOCK_FACE, LOCK_SCREEN_CUSTOM_CLOCK_FACE_VALIDATOR); - VALIDATORS.put(LOCK_SCREEN_WHEN_TRUST_LOST, LOCK_SCREEN_WHEN_TRUST_LOST_VALIDATOR); - VALIDATORS.put(SKIP_GESTURE, SKIP_GESTURE_VALIDATOR); - VALIDATORS.put(SKIP_DIRECTION, SKIP_DIRECTION_VALIDATOR); - VALIDATORS.put(SKIP_DIRECTION, SKIP_DIRECTION_VALIDATOR); - VALIDATORS.put(SILENCE_GESTURE, SILENCE_GESTURE_VALIDATOR); - VALIDATORS.put(THEME_CUSTOMIZATION_OVERLAY_PACKAGES, - THEME_CUSTOMIZATION_OVERLAY_PACKAGES_VALIDATOR); - VALIDATORS.put(NAVIGATION_MODE, NAVIGATION_MODE_VALIDATOR); - VALIDATORS.put(AWARE_ENABLED, AWARE_ENABLED_VALIDATOR); - VALIDATORS.put(SKIP_GESTURE_COUNT, SKIP_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SKIP_TOUCH_COUNT, SKIP_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SILENCE_ALARMS_GESTURE_COUNT, SILENCE_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SILENCE_TIMER_GESTURE_COUNT, SILENCE_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SILENCE_CALL_GESTURE_COUNT, SILENCE_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SILENCE_ALARMS_TOUCH_COUNT, SILENCE_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SILENCE_TIMER_TOUCH_COUNT, SILENCE_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(SILENCE_CALL_TOUCH_COUNT, SILENCE_GESTURE_COUNT_VALIDATOR); - VALIDATORS.put(ODI_CAPTIONS_ENABLED, ODI_CAPTIONS_ENABLED_VALIDATOR); - VALIDATORS.put(DARK_MODE_DIALOG_SEEN, BOOLEAN_VALIDATOR); - VALIDATORS.put(UI_NIGHT_MODE, UI_NIGHT_MODE_VALIDATOR); - VALIDATORS.put(GLOBAL_ACTIONS_PANEL_ENABLED, GLOBAL_ACTIONS_PANEL_ENABLED_VALIDATOR); - VALIDATORS.put(AWARE_LOCK_ENABLED, AWARE_LOCK_ENABLED_VALIDATOR); - VALIDATORS.put(DISPLAY_DENSITY_FORCED, DISPLAY_DENSITY_FORCED_VALIDATOR); - } - - /** * Keys we no longer back up under the current schema, but want to continue to * process when restoring historical backup datasets. * @@ -9387,8 +8462,6 @@ public final class Settings { */ public static final String APPLY_RAMPING_RINGER = "apply_ramping_ringer"; - private static final Validator APPLY_RAMPING_RINGER_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Setting whether the global gesture for enabling accessibility is enabled. * If this gesture is enabled the user will be able to perfrom it to enable @@ -9516,16 +8589,12 @@ public final class Settings { */ public static final String AUTO_TIME = "auto_time"; - private static final Validator AUTO_TIME_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Value to specify if the user prefers the time zone * to be automatically fetched from the network (NITZ). 1=yes, 0=no */ public static final String AUTO_TIME_ZONE = "auto_time_zone"; - private static final Validator AUTO_TIME_ZONE_VALIDATOR = BOOLEAN_VALIDATOR; - /** * URI for the car dock "in" event sound. * @hide @@ -9556,8 +8625,6 @@ public final class Settings { */ public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled"; - private static final Validator DOCK_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether to play a sound for dock events, only when an accessibility service is on. * @hide @@ -9595,8 +8662,6 @@ public final class Settings { */ public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled"; - private static final Validator POWER_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * URI for the "wireless charging started" and "wired charging started" sound. * @hide @@ -9612,8 +8677,6 @@ public final class Settings { @Deprecated public static final String CHARGING_SOUNDS_ENABLED = "charging_sounds_enabled"; - private static final Validator CHARGING_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether to vibrate for wireless charging events. * @deprecated Use {@link android.provider.Settings.Secure#CHARGING_VIBRATION_ENABLED} @@ -9622,8 +8685,6 @@ public final class Settings { @Deprecated public static final String CHARGING_VIBRATION_ENABLED = "charging_vibration_enabled"; - private static final Validator CHARGING_VIBRATION_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether we keep the device on while the device is plugged in. * Supported values are: @@ -9637,30 +8698,6 @@ public final class Settings { */ public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in"; - private static final Validator STAY_ON_WHILE_PLUGGED_IN_VALIDATOR = new Validator() { - @Override - public boolean validate(@Nullable String value) { - try { - int val = Integer.parseInt(value); - return (val == 0) - || (val == BatteryManager.BATTERY_PLUGGED_AC) - || (val == BatteryManager.BATTERY_PLUGGED_USB) - || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS) - || (val == (BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_USB)) - || (val == (BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_WIRELESS)) - || (val == (BatteryManager.BATTERY_PLUGGED_USB - | BatteryManager.BATTERY_PLUGGED_WIRELESS)) - || (val == (BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_USB - | BatteryManager.BATTERY_PLUGGED_WIRELESS)); - } catch (NumberFormatException e) { - return false; - } - } - }; - /** * When the user has enable the option to have a "bug report" command * in the power menu. @@ -9668,8 +8705,6 @@ public final class Settings { */ public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu"; - private static final Validator BUGREPORT_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Whether ADB is enabled. */ @@ -9700,8 +8735,6 @@ public final class Settings { */ public static final String BLUETOOTH_ON = "bluetooth_on"; - private static final Validator BLUETOOTH_ON_VALIDATOR = BOOLEAN_VALIDATOR; - /** * CDMA Cell Broadcast SMS * 0 = CDMA Cell Broadcast SMS disabled @@ -10426,8 +9459,6 @@ public final class Settings { */ public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled"; - private static final Validator USB_MASS_STORAGE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * If this setting is set (to anything), then all references * to Gmail on the device must change to Google Mail. @@ -10580,9 +9611,6 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = "wifi_networks_available_notification_on"; - private static final Validator WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * {@hide} */ @@ -10596,9 +9624,6 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = "wifi_networks_available_repeat_delay"; - private static final Validator WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * 802.11 country code in ISO 3166 format * @hide @@ -10628,9 +9653,6 @@ public final class Settings { */ public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept"; - private static final Validator WIFI_NUM_OPEN_NETWORKS_KEPT_VALIDATOR = - NON_NEGATIVE_INTEGER_VALIDATOR; - /** * Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this. */ @@ -10669,8 +9691,6 @@ public final class Settings { */ public static final String SOFT_AP_TIMEOUT_ENABLED = "soft_ap_timeout_enabled"; - private static final Validator SOFT_AP_TIMEOUT_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Value to specify if Wi-Fi Wakeup feature is enabled. * @@ -10680,8 +9700,6 @@ public final class Settings { @SystemApi public static final String WIFI_WAKEUP_ENABLED = "wifi_wakeup_enabled"; - private static final Validator WIFI_WAKEUP_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Value to specify whether network quality scores and badging should be shown in the UI. * @@ -10717,8 +9735,6 @@ public final class Settings { public static final String NETWORK_RECOMMENDATIONS_ENABLED = "network_recommendations_enabled"; - private static final Validator NETWORK_RECOMMENDATIONS_ENABLED_VALIDATOR = - new DiscreteValueValidator(new String[] {"-1", "0", "1"}); /** * Which package name to use for network recommendations. If null, network recommendations @@ -10743,13 +9759,6 @@ public final class Settings { @TestApi public static final String USE_OPEN_WIFI_PACKAGE = "use_open_wifi_package"; - private static final Validator USE_OPEN_WIFI_PACKAGE_VALIDATOR = new Validator() { - @Override - public boolean validate(@Nullable String value) { - return (value == null) || PACKAGE_NAME_VALIDATOR.validate(value); - } - }; - /** * The number of milliseconds the {@link com.android.server.NetworkScoreService} * will give a recommendation request to complete before returning a default response. @@ -10781,8 +9790,6 @@ public final class Settings { */ public static final String WIFI_SCAN_THROTTLE_ENABLED = "wifi_scan_throttle_enabled"; - private static final Validator WIFI_SCAN_THROTTLE_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Settings to allow BLE scans to be enabled even when Bluetooth is turned off for * connectivity. @@ -10888,9 +9895,6 @@ public final class Settings { public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED = "wifi_watchdog_poor_network_test_enabled"; - private static final Validator WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED_VALIDATOR = - ANY_STRING_VALIDATOR; - /** * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and * needs to be set to 0 to disable it. @@ -10974,9 +9978,6 @@ public final class Settings { public static final String WIFI_PNO_FREQUENCY_CULLING_ENABLED = "wifi_pno_frequency_culling_enabled"; - private static final Validator WIFI_PNO_FREQUENCY_CULLING_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting to enable including recency information when determining pno network priorities. * Disabled by default, and setting it to 1 will enable it. @@ -10986,9 +9987,6 @@ public final class Settings { public static final String WIFI_PNO_RECENCY_SORTING_ENABLED = "wifi_pno_recency_sorting_enabled"; - private static final Validator WIFI_PNO_RECENCY_SORTING_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Setting to enable the Wi-Fi link probing. * Enabled by default, and setting it to 0 will disable it. @@ -10998,9 +9996,6 @@ public final class Settings { public static final String WIFI_LINK_PROBING_ENABLED = "wifi_link_probing_enabled"; - private static final Validator WIFI_LINK_PROBING_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * The maximum number of times we will retry a connection to an access * point for which we have failed in acquiring an IP address from DHCP. @@ -11540,15 +10535,11 @@ public final class Settings { */ public static final String PRIVATE_DNS_MODE = "private_dns_mode"; - private static final Validator PRIVATE_DNS_MODE_VALIDATOR = ANY_STRING_VALIDATOR; - /** * @hide */ public static final String PRIVATE_DNS_SPECIFIER = "private_dns_specifier"; - private static final Validator PRIVATE_DNS_SPECIFIER_VALIDATOR = ANY_STRING_VALIDATOR; - /** * Forced override of the default mode (hardcoded as "automatic", nee "opportunistic"). * This allows changing the default mode without effectively disabling other modes, @@ -12291,9 +11282,6 @@ public final class Settings { public static final String APP_AUTO_RESTRICTION_ENABLED = "app_auto_restriction_enabled"; - private static final Validator APP_AUTO_RESTRICTION_ENABLED_VALIDATOR = - BOOLEAN_VALIDATOR; - /** * Feature flag to enable or disable the Forced App Standby feature. * Type: int (0 for false, 1 for true) @@ -12568,9 +11556,6 @@ public final class Settings { */ public static final String EMERGENCY_TONE = "emergency_tone"; - private static final Validator EMERGENCY_TONE_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "1", "2"}); - /** * CDMA only settings * Whether the auto retry is enabled. The value is @@ -12579,8 +11564,6 @@ public final class Settings { */ public static final String CALL_AUTO_RETRY = "call_auto_retry"; - private static final Validator CALL_AUTO_RETRY_VALIDATOR = BOOLEAN_VALIDATOR; - /** * A setting that can be read whether the emergency affordance is currently needed. * The value is a boolean (1 or 0). @@ -12598,9 +11581,6 @@ public final class Settings { public static final String ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS = "enable_automatic_system_server_heap_dumps"; - private static final Validator ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "1"}); - /** * See RIL_PreferredNetworkType in ril.h * @hide @@ -12792,9 +11772,6 @@ public final class Settings { public static final String LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL = "low_power_sticky_auto_disable_level"; - private static final Validator LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 100); - /** * Whether sticky battery saver should be deactivated once the battery level has reached the * threshold specified by {@link #LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL}. @@ -12804,9 +11781,6 @@ public final class Settings { public static final String LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED = "low_power_sticky_auto_disable_enabled"; - private static final Validator LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "1"}); - /** * Battery level [1-100] at which low power mode automatically turns on. * If 0, it will not automatically turn on. For Q and newer, it will only automatically @@ -12819,9 +11793,6 @@ public final class Settings { */ public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level"; - private static final Validator LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 100); - /** * Whether battery saver is currently set to trigger based on percentage, dynamic power * savings trigger, or none. See {@link AutoPowerSaveModeTriggers} for @@ -12832,9 +11803,6 @@ public final class Settings { @TestApi public static final String AUTOMATIC_POWER_SAVE_MODE = "automatic_power_save_mode"; - private static final Validator AUTOMATIC_POWER_SAVE_MODE_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "1"}); - /** * The setting that backs the disable threshold for the setPowerSavingsWarning api in * PowerManager @@ -12845,8 +11813,6 @@ public final class Settings { @TestApi public static final String DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD = "dynamic_power_savings_disable_threshold"; - private static final Validator DYNAMIC_POWER_SAVINGS_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 100); /** * The setting which backs the setDynamicPowerSaveHint api in PowerManager. @@ -12934,8 +11900,6 @@ public final class Settings { */ public static final String DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled"; - private static final Validator DOCK_AUDIO_MEDIA_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * The surround sound formats AC3, DTS or IEC61937 are * available for use if they are detected. @@ -12995,9 +11959,6 @@ public final class Settings { */ public static final String ENCODED_SURROUND_OUTPUT = "encoded_surround_output"; - private static final Validator ENCODED_SURROUND_OUTPUT_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "1", "2", "3"}); - /** * Surround sounds formats that are enabled when ENCODED_SURROUND_OUTPUT is set to * ENCODED_SURROUND_OUTPUT_MANUAL. Encoded as comma separated list. Allowed values @@ -13010,32 +11971,6 @@ public final class Settings { public static final String ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS = "encoded_surround_output_enabled_formats"; - private static final Validator ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS_VALIDATOR = - new Validator() { - @Override - public boolean validate(@Nullable String value) { - try { - String[] surroundFormats = TextUtils.split(value, ","); - for (String format : surroundFormats) { - int audioFormat = Integer.valueOf(format); - boolean isSurroundFormat = false; - for (int sf : AudioFormat.SURROUND_SOUND_ENCODING) { - if (sf == audioFormat) { - isSurroundFormat = true; - break; - } - } - if (!isSurroundFormat) { - return false; - } - } - return true; - } catch (NumberFormatException e) { - return false; - } - } - }; - /** * Persisted safe headphone volume management state by AudioService * @hide @@ -13278,8 +12213,6 @@ public final class Settings { @Deprecated public static final String ZEN_DURATION = "zen_duration"; - private static final Validator ZEN_DURATION_VALIDATOR = ANY_INTEGER_VALIDATOR; - /** * @deprecated Use {@link android.provider.Settings.Secure#ZEN_DURATION_PROMPT} instead * @hide @@ -13736,8 +12669,6 @@ public final class Settings { */ public static final String AWARE_ALLOWED = "aware_allowed"; - private static final Validator AWARE_ALLOWED_VALIDATOR = BOOLEAN_VALIDATOR; - /** * Overrides internal R.integer.config_longPressOnPowerBehavior. * Allowable values detailed in frameworks/base/core/res/res/values/config.xml. @@ -13746,8 +12677,6 @@ public final class Settings { */ public static final String POWER_BUTTON_LONG_PRESS = "power_button_long_press"; - private static final Validator POWER_BUTTON_LONG_PRESS_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 5); /** * Overrides internal R.integer.config_veryLongPressOnPowerBehavior. @@ -13757,8 +12686,6 @@ public final class Settings { */ public static final String POWER_BUTTON_VERY_LONG_PRESS = "power_button_very_long_press"; - private static final Validator POWER_BUTTON_VERY_LONG_PRESS_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 1); /** * Settings to backup. This is here so that it's in the same place as the settings @@ -13814,71 +12741,6 @@ public final class Settings { }; /** - * All settings in {@link SETTINGS_TO_BACKUP} array *must* have a non-null validator, - * otherwise they won't be restored. - * - * @hide - */ - public static final Map<String, Validator> VALIDATORS = new ArrayMap<>(); - - static { - VALIDATORS.put(APPLY_RAMPING_RINGER, APPLY_RAMPING_RINGER_VALIDATOR); - VALIDATORS.put(BUGREPORT_IN_POWER_MENU, BUGREPORT_IN_POWER_MENU_VALIDATOR); - VALIDATORS.put(STAY_ON_WHILE_PLUGGED_IN, STAY_ON_WHILE_PLUGGED_IN_VALIDATOR); - VALIDATORS.put(AUTO_TIME, AUTO_TIME_VALIDATOR); - VALIDATORS.put(AUTO_TIME_ZONE, AUTO_TIME_ZONE_VALIDATOR); - VALIDATORS.put(POWER_SOUNDS_ENABLED, POWER_SOUNDS_ENABLED_VALIDATOR); - VALIDATORS.put(DOCK_SOUNDS_ENABLED, DOCK_SOUNDS_ENABLED_VALIDATOR); - VALIDATORS.put(CHARGING_SOUNDS_ENABLED, CHARGING_SOUNDS_ENABLED_VALIDATOR); - VALIDATORS.put(USB_MASS_STORAGE_ENABLED, USB_MASS_STORAGE_ENABLED_VALIDATOR); - VALIDATORS.put(NETWORK_RECOMMENDATIONS_ENABLED, - NETWORK_RECOMMENDATIONS_ENABLED_VALIDATOR); - VALIDATORS.put(WIFI_WAKEUP_ENABLED, WIFI_WAKEUP_ENABLED_VALIDATOR); - VALIDATORS.put(WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, - WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON_VALIDATOR); - VALIDATORS.put(USE_OPEN_WIFI_PACKAGE, USE_OPEN_WIFI_PACKAGE_VALIDATOR); - VALIDATORS.put(WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, - WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED_VALIDATOR); - VALIDATORS.put(EMERGENCY_TONE, EMERGENCY_TONE_VALIDATOR); - VALIDATORS.put(CALL_AUTO_RETRY, CALL_AUTO_RETRY_VALIDATOR); - VALIDATORS.put(DOCK_AUDIO_MEDIA_ENABLED, DOCK_AUDIO_MEDIA_ENABLED_VALIDATOR); - VALIDATORS.put(ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, - ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_VALIDATOR); - VALIDATORS.put(ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_VALIDATOR); - VALIDATORS.put(ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS, - ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS_VALIDATOR); - VALIDATORS.put(LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, - LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL_VALIDATOR); - VALIDATORS.put(LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, - LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED_VALIDATOR); - VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR); - VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL_MAX, - LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR); - VALIDATORS.put(AUTOMATIC_POWER_SAVE_MODE, AUTOMATIC_POWER_SAVE_MODE_VALIDATOR); - VALIDATORS.put(DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, - DYNAMIC_POWER_SAVINGS_VALIDATOR); - VALIDATORS.put(BLUETOOTH_ON, BLUETOOTH_ON_VALIDATOR); - VALIDATORS.put(PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_VALIDATOR); - VALIDATORS.put(PRIVATE_DNS_SPECIFIER, PRIVATE_DNS_SPECIFIER_VALIDATOR); - VALIDATORS.put(SOFT_AP_TIMEOUT_ENABLED, SOFT_AP_TIMEOUT_ENABLED_VALIDATOR); - VALIDATORS.put(WIFI_SCAN_THROTTLE_ENABLED, WIFI_SCAN_THROTTLE_ENABLED_VALIDATOR); - VALIDATORS.put(APP_AUTO_RESTRICTION_ENABLED, APP_AUTO_RESTRICTION_ENABLED_VALIDATOR); - VALIDATORS.put(ZEN_DURATION, ZEN_DURATION_VALIDATOR); - VALIDATORS.put(CHARGING_VIBRATION_ENABLED, CHARGING_VIBRATION_ENABLED_VALIDATOR); - VALIDATORS.put(DEVICE_PROVISIONING_MOBILE_DATA_ENABLED, BOOLEAN_VALIDATOR); - VALIDATORS.put(REQUIRE_PASSWORD_TO_DECRYPT, BOOLEAN_VALIDATOR); - VALIDATORS.put(DEVICE_DEMO_MODE, BOOLEAN_VALIDATOR); - VALIDATORS.put(WIFI_PNO_FREQUENCY_CULLING_ENABLED, - WIFI_PNO_FREQUENCY_CULLING_ENABLED_VALIDATOR); - VALIDATORS.put(WIFI_PNO_RECENCY_SORTING_ENABLED, - WIFI_PNO_RECENCY_SORTING_ENABLED_VALIDATOR); - VALIDATORS.put(WIFI_LINK_PROBING_ENABLED, WIFI_LINK_PROBING_ENABLED_VALIDATOR); - VALIDATORS.put(AWARE_ALLOWED, AWARE_ALLOWED_VALIDATOR); - VALIDATORS.put(POWER_BUTTON_LONG_PRESS, POWER_BUTTON_LONG_PRESS_VALIDATOR); - VALIDATORS.put(POWER_BUTTON_VERY_LONG_PRESS, POWER_BUTTON_VERY_LONG_PRESS_VALIDATOR); - } - - /** * Global settings that shouldn't be persisted. * * @hide diff --git a/packages/SettingsProvider/Android.bp b/packages/SettingsProvider/Android.bp index 0144dd47b99b..49908a334623 100644 --- a/packages/SettingsProvider/Android.bp +++ b/packages/SettingsProvider/Android.bp @@ -24,6 +24,7 @@ android_test { // because this test is not an instrumentation test. (because the target runs in the system process.) srcs: [ "test/**/*.java", + "src/android/provider/settings/validators/*", "src/com/android/providers/settings/SettingsBackupAgent.java", "src/com/android/providers/settings/SettingsState.java", "src/com/android/providers/settings/SettingsHelper.java", @@ -31,6 +32,8 @@ android_test { static_libs: [ "androidx.test.rules", "SettingsLibDisplayDensityUtils", + "platform-test-annotations", + "truth-prebuilt", ], libs: [ "android.test.base", diff --git a/core/java/android/provider/settings/validators/ComponentNameListValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/ComponentNameListValidator.java index b6b867a5d513..b6b867a5d513 100644 --- a/core/java/android/provider/settings/validators/ComponentNameListValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/ComponentNameListValidator.java diff --git a/core/java/android/provider/settings/validators/DiscreteValueValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/DiscreteValueValidator.java index 183651f77f5a..183651f77f5a 100644 --- a/core/java/android/provider/settings/validators/DiscreteValueValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/DiscreteValueValidator.java diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java new file mode 100644 index 000000000000..9be636d69daa --- /dev/null +++ b/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.provider.settings.validators; + +import static android.provider.settings.validators.SettingsValidators.ANY_INTEGER_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.ANY_STRING_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.BOOLEAN_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.PACKAGE_NAME_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.PERCENTAGE_INTEGER_VALIDATOR; + +import android.media.AudioFormat; +import android.os.BatteryManager; +import android.provider.Settings.Global; +import android.text.TextUtils; +import android.util.ArrayMap; + +import java.util.Map; + +/** + * Validators for Global settings + */ +public class GlobalSettingsValidators { + /** + * All settings in {@link Global.SETTINGS_TO_BACKUP} array *must* have a non-null validator, + * otherwise they won't be restored. + */ + public static final Map<String, Validator> VALIDATORS = new ArrayMap<>(); + + static { + VALIDATORS.put(Global.APPLY_RAMPING_RINGER, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.BUGREPORT_IN_POWER_MENU, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Global.STAY_ON_WHILE_PLUGGED_IN, + value -> { + try { + int val = Integer.parseInt(value); + return (val == 0) + || (val == BatteryManager.BATTERY_PLUGGED_AC) + || (val == BatteryManager.BATTERY_PLUGGED_USB) + || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS) + || (val + == (BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_USB)) + || (val + == (BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_WIRELESS)) + || (val + == (BatteryManager.BATTERY_PLUGGED_USB + | BatteryManager.BATTERY_PLUGGED_WIRELESS)) + || (val + == (BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_USB + | BatteryManager.BATTERY_PLUGGED_WIRELESS)); + } catch (NumberFormatException e) { + return false; + } + }); + VALIDATORS.put(Global.AUTO_TIME, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.AUTO_TIME_ZONE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.POWER_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.DOCK_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.CHARGING_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.USB_MASS_STORAGE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Global.NETWORK_RECOMMENDATIONS_ENABLED, + new DiscreteValueValidator(new String[] {"-1", "0", "1"})); + VALIDATORS.put(Global.WIFI_WAKEUP_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Global.USE_OPEN_WIFI_PACKAGE, + value -> (value == null) || PACKAGE_NAME_VALIDATOR.validate(value)); + 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.CALL_AUTO_RETRY, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.DOCK_AUDIO_MEDIA_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, + new DiscreteValueValidator(new String[] {"0", "1"})); + VALIDATORS.put( + Global.ENCODED_SURROUND_OUTPUT, + new DiscreteValueValidator(new String[] {"0", "1", "2", "3"})); + VALIDATORS.put( + Global.ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS, + value -> { + try { + String[] surroundFormats = TextUtils.split(value, ","); + for (String format : surroundFormats) { + int audioFormat = Integer.valueOf(format); + boolean isSurroundFormat = false; + for (int sf : AudioFormat.SURROUND_SOUND_ENCODING) { + if (sf == audioFormat) { + isSurroundFormat = true; + break; + } + } + if (!isSurroundFormat) { + return false; + } + } + return true; + } catch (NumberFormatException e) { + return false; + } + }); + VALIDATORS.put( + Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, + new InclusiveIntegerRangeValidator(0, 100)); + VALIDATORS.put( + Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, + new DiscreteValueValidator(new String[] {"0", "1"})); + VALIDATORS.put(Global.LOW_POWER_MODE_TRIGGER_LEVEL, PERCENTAGE_INTEGER_VALIDATOR); + VALIDATORS.put(Global.LOW_POWER_MODE_TRIGGER_LEVEL_MAX, PERCENTAGE_INTEGER_VALIDATOR); + VALIDATORS.put( + Global.AUTOMATIC_POWER_SAVE_MODE, + new DiscreteValueValidator(new String[] {"0", "1"})); + VALIDATORS.put( + Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, PERCENTAGE_INTEGER_VALIDATOR); + VALIDATORS.put(Global.BLUETOOTH_ON, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.PRIVATE_DNS_MODE, ANY_STRING_VALIDATOR); + VALIDATORS.put(Global.PRIVATE_DNS_SPECIFIER, ANY_STRING_VALIDATOR); + VALIDATORS.put(Global.SOFT_AP_TIMEOUT_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.WIFI_SCAN_THROTTLE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.APP_AUTO_RESTRICTION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.ZEN_DURATION, ANY_INTEGER_VALIDATOR); + VALIDATORS.put(Global.CHARGING_VIBRATION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.REQUIRE_PASSWORD_TO_DECRYPT, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.DEVICE_DEMO_MODE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.WIFI_PNO_FREQUENCY_CULLING_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.WIFI_PNO_RECENCY_SORTING_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.WIFI_LINK_PROBING_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.AWARE_ALLOWED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Global.POWER_BUTTON_LONG_PRESS, new InclusiveIntegerRangeValidator(0, 5)); + VALIDATORS.put( + Global.POWER_BUTTON_VERY_LONG_PRESS, new InclusiveIntegerRangeValidator(0, 1)); + } +} diff --git a/core/java/android/provider/settings/validators/InclusiveFloatRangeValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/InclusiveFloatRangeValidator.java index 38400ac676a8..1a0b88c1c150 100644 --- a/core/java/android/provider/settings/validators/InclusiveFloatRangeValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/InclusiveFloatRangeValidator.java @@ -23,11 +23,11 @@ import android.annotation.Nullable; * * @hide */ -public final class InclusiveFloatRangeValidator implements Validator { +final class InclusiveFloatRangeValidator implements Validator { private final float mMin; private final float mMax; - public InclusiveFloatRangeValidator(float min, float max) { + InclusiveFloatRangeValidator(float min, float max) { mMin = min; mMax = max; } diff --git a/core/java/android/provider/settings/validators/InclusiveIntegerRangeValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/InclusiveIntegerRangeValidator.java index e53c252c7d35..f9f8ce851719 100644 --- a/core/java/android/provider/settings/validators/InclusiveIntegerRangeValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/InclusiveIntegerRangeValidator.java @@ -23,11 +23,11 @@ import android.annotation.Nullable; * * @hide */ -public final class InclusiveIntegerRangeValidator implements Validator { +final class InclusiveIntegerRangeValidator implements Validator { private final int mMin; private final int mMax; - public InclusiveIntegerRangeValidator(int min, int max) { + InclusiveIntegerRangeValidator(int min, int max) { mMin = min; mMax = max; } diff --git a/core/java/android/provider/settings/validators/ListValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/ListValidator.java index a6001d2e10c1..a6001d2e10c1 100644 --- a/core/java/android/provider/settings/validators/ListValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/ListValidator.java diff --git a/core/java/android/provider/settings/validators/PackageNameListValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/PackageNameListValidator.java index bc7fc13bdc6d..a883223f6f1b 100644 --- a/core/java/android/provider/settings/validators/PackageNameListValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/PackageNameListValidator.java @@ -23,8 +23,8 @@ import static android.provider.settings.validators.SettingsValidators.PACKAGE_NA * * @hide */ -public final class PackageNameListValidator extends ListValidator { - public PackageNameListValidator(String separator) { +final class PackageNameListValidator extends ListValidator { + PackageNameListValidator(String separator) { super(separator); } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java new file mode 100644 index 000000000000..f160edc6e446 --- /dev/null +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.provider.settings.validators; + +import static android.provider.settings.validators.SettingsValidators.ANY_INTEGER_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.BOOLEAN_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.COLON_SEPARATED_COMPONENT_LIST_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.COLON_SEPARATED_PACKAGE_LIST_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.COMMA_SEPARATED_COMPONENT_LIST_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.COMPONENT_NAME_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.JSON_OBJECT_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.LOCALE_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.NULLABLE_COMPONENT_NAME_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.PACKAGE_NAME_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.TILE_LIST_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.TTS_LIST_VALIDATOR; + +import android.provider.Settings.Secure; +import android.util.ArrayMap; + +import java.util.Map; + +/** + * Validators for the Secure Settings. + */ +public class SecureSettingsValidators { + /** + * All settings in {@link Secure.SETTINGS_TO_BACKUP} and {@link + * Secure.DEVICE_SPECIFIC_SETTINGS_TO_BACKUP} array *must* have a non-null validator, otherwise + * they won't be restored. + */ + public static final Map<String, Validator> VALIDATORS = new ArrayMap<>(); + + static { + VALIDATORS.put(Secure.BUGREPORT_IN_POWER_MENU, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ALLOW_MOCK_LOCATION, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.USB_MASS_STORAGE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, + new DiscreteValueValidator(new String[] {"-1", "0", "11", "12", "13"})); + VALIDATORS.put(Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.AUTOFILL_SERVICE, NULLABLE_COMPONENT_NAME_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, + new InclusiveFloatRangeValidator(1.0f, Float.MAX_VALUE)); + VALIDATORS.put( + Secure.ENABLED_ACCESSIBILITY_SERVICES, COLON_SEPARATED_COMPONENT_LIST_VALIDATOR); + VALIDATORS.put(Secure.ENABLED_VR_LISTENERS, COLON_SEPARATED_COMPONENT_LIST_VALIDATOR); + VALIDATORS.put( + Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, + COLON_SEPARATED_COMPONENT_LIST_VALIDATOR); + VALIDATORS.put(Secure.TOUCH_EXPLORATION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, NULLABLE_COMPONENT_NAME_VALIDATOR); + // technically either ComponentName or class name, but there's proper value + // validation at callsites, so allow any non-null string + VALIDATORS.put(Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT, value -> value != null); + VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_CAPTIONING_PRESET, + new DiscreteValueValidator(new String[] {"-1", "0", "1", "2", "3", "4"})); + VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_LOCALE, LOCALE_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR, ANY_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR, ANY_INTEGER_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE, + new DiscreteValueValidator(new String[] {"0", "1", "2"})); + VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR, ANY_INTEGER_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE, + new DiscreteValueValidator( + new String[] {"DEFAULT", "MONOSPACE", "SANS_SERIF", "SERIF"})); + VALIDATORS.put( + Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, + new InclusiveFloatRangeValidator(0.5f, 2.0f)); + VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR, ANY_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.TTS_DEFAULT_RATE, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.TTS_DEFAULT_PITCH, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.TTS_DEFAULT_SYNTH, PACKAGE_NAME_VALIDATOR); + VALIDATORS.put(Secure.TTS_ENABLED_PLUGINS, new PackageNameListValidator(" ")); + VALIDATORS.put(Secure.TTS_DEFAULT_LOCALE, TTS_LIST_VALIDATOR); + VALIDATORS.put(Secure.SHOW_IME_WITH_HARD_KEYBOARD, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.MOUNT_PLAY_NOTIFICATION_SND, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.MOUNT_UMS_AUTOSTART, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.MOUNT_UMS_PROMPT, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.MOUNT_UMS_NOTIFY_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOUBLE_TAP_TO_WAKE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.WAKE_GESTURE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.LONG_PRESS_TIMEOUT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.CAMERA_GESTURE_DISABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_AUTOCLICK_DELAY, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.ACCESSIBILITY_LARGE_POINTER_ICON, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.PREFERRED_TTY_MODE, + new DiscreteValueValidator(new String[] {"0", "1", "2", "3"})); + VALIDATORS.put(Secure.ENHANCED_VOICE_PRIVACY_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.TTY_MODE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.RTT_CALLING_MODE, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.INCALL_POWER_BUTTON_BEHAVIOR, + new DiscreteValueValidator(new String[] {"1", "2"})); + VALIDATORS.put(Secure.NIGHT_DISPLAY_CUSTOM_START_TIME, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.NIGHT_DISPLAY_CUSTOM_END_TIME, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.NIGHT_DISPLAY_AUTO_MODE, new InclusiveIntegerRangeValidator(0, 2)); + VALIDATORS.put(Secure.DISPLAY_WHITE_BALANCE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SYNC_PARENT_SOUNDS, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.QS_TILES, TILE_LIST_VALIDATOR); + VALIDATORS.put(Secure.DOZE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_ALWAYS_ON, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_PICK_UP_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_DOUBLE_TAP_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_TAP_SCREEN_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DOZE_WAKE_DISPLAY_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.NFC_PAYMENT_DEFAULT_COMPONENT, COMPONENT_NAME_VALIDATOR); + VALIDATORS.put( + Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.FACE_UNLOCK_KEYGUARD_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.FACE_UNLOCK_DISMISSES_KEYGUARD, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SHOW_MEDIA_WHEN_BYPASSING, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.FACE_UNLOCK_APP_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ASSIST_GESTURE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ASSIST_GESTURE_WAKE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.VR_DISPLAY_MODE, new DiscreteValueValidator(new String[] {"0", "1"})); + VALIDATORS.put(Secure.NOTIFICATION_BADGING, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.NOTIFICATION_BUBBLES, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.NOTIFICATION_DISMISS_RTL, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.QS_AUTO_ADDED_TILES, TILE_LIST_VALIDATOR); + VALIDATORS.put(Secure.SCREENSAVER_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SCREENSAVER_COMPONENTS, COMMA_SEPARATED_COMPONENT_LIST_VALIDATOR); + VALIDATORS.put(Secure.SCREENSAVER_ACTIVATE_ON_DOCK, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.LOCKDOWN_IN_POWER_MENU, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.VOLUME_HUSH_GESTURE, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put( + Secure.ENABLED_NOTIFICATION_LISTENERS, + COLON_SEPARATED_COMPONENT_LIST_VALIDATOR); // legacy restore setting + VALIDATORS.put( + Secure.ENABLED_NOTIFICATION_ASSISTANT, + COLON_SEPARATED_COMPONENT_LIST_VALIDATOR); // legacy restore setting + VALIDATORS.put( + Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES, + COLON_SEPARATED_PACKAGE_LIST_VALIDATOR); // legacy restore setting + VALIDATORS.put(Secure.HUSH_GESTURE_USED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.MANUAL_RINGER_TOGGLE_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.IN_CALL_NOTIFICATION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SHOW_NOTIFICATION_SNOOZE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ZEN_DURATION, ANY_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SHOW_ZEN_SETTINGS_SUGGESTION, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ZEN_SETTINGS_UPDATED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ZEN_SETTINGS_SUGGESTION_VIEWED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.CHARGING_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.CHARGING_VIBRATION_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put( + Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.USER_SETUP_COMPLETE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.ASSIST_GESTURE_SETUP_COMPLETE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.TRUST_AGENTS_EXTEND_UNLOCK, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, JSON_OBJECT_VALIDATOR); + VALIDATORS.put(Secure.LOCK_SCREEN_WHEN_TRUST_LOST, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SKIP_GESTURE, BOOLEAN_VALIDATOR); + /* + * Only used if FeatureFlag "settings_skip_direction_mutable" is enabled. + * If feature flag is disabled, should assume SKIP_DIRECTION = 0. + * 0 / false = right to left to advance to next + * 1 / true = left to right to advance to next + */ + VALIDATORS.put(Secure.SKIP_DIRECTION, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_GESTURE, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, JSON_OBJECT_VALIDATOR); + VALIDATORS.put( + Secure.NAVIGATION_MODE, new DiscreteValueValidator(new String[] {"0", "1", "2"})); + VALIDATORS.put(Secure.AWARE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.SKIP_GESTURE_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SKIP_TOUCH_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_ALARMS_GESTURE_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_TIMER_GESTURE_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_CALL_GESTURE_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_ALARMS_TOUCH_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_TIMER_TOUCH_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.SILENCE_CALL_TOUCH_COUNT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(Secure.ODI_CAPTIONS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DARK_MODE_DIALOG_SEEN, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.UI_NIGHT_MODE, new InclusiveIntegerRangeValidator(0, 2)); + VALIDATORS.put(Secure.GLOBAL_ACTIONS_PANEL_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.AWARE_LOCK_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.DISPLAY_DENSITY_FORCED, NON_NEGATIVE_INTEGER_VALIDATOR); + } +} diff --git a/core/java/android/provider/settings/validators/SettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SettingsValidators.java index 562c638d0b5a..224042ca755d 100644 --- a/core/java/android/provider/settings/validators/SettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SettingsValidators.java @@ -24,6 +24,7 @@ import android.text.TextUtils; import org.json.JSONException; import org.json.JSONObject; +import java.text.SimpleDateFormat; import java.util.Locale; /** @@ -180,4 +181,27 @@ public class SettingsValidators { public static final Validator TTS_LIST_VALIDATOR = new TTSListValidator(); public static final Validator TILE_LIST_VALIDATOR = new TileListValidator(); + + static final Validator DATE_FORMAT_VALIDATOR = value -> { + try { + new SimpleDateFormat(value); + return true; + } catch (IllegalArgumentException | NullPointerException e) { + return false; + } + }; + + static final Validator COLON_SEPARATED_COMPONENT_LIST_VALIDATOR = + new ComponentNameListValidator(":"); + + static final Validator COLON_SEPARATED_PACKAGE_LIST_VALIDATOR = + new PackageNameListValidator(":"); + + static final Validator COMMA_SEPARATED_COMPONENT_LIST_VALIDATOR = + new ComponentNameListValidator(","); + + static final Validator PERCENTAGE_INTEGER_VALIDATOR = + new InclusiveIntegerRangeValidator(0, 100); + + static final Validator VIBRATION_INTENSITY_VALIDATOR = new InclusiveIntegerRangeValidator(0, 3); } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java new file mode 100644 index 000000000000..94ab0f11927d --- /dev/null +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.provider.settings.validators; + +import static android.provider.settings.validators.SettingsValidators.BOOLEAN_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.COMPONENT_NAME_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.DATE_FORMAT_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.LENIENT_IP_ADDRESS_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.URI_VALIDATOR; +import static android.provider.settings.validators.SettingsValidators.VIBRATION_INTENSITY_VALIDATOR; + +import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; +import android.content.ComponentName; +import android.hardware.display.ColorDisplayManager; +import android.os.BatteryManager; +import android.provider.Settings.System; +import android.util.ArrayMap; + +import java.util.Map; + +/** + * Validators for System settings + */ +public class SystemSettingsValidators { + /** + * These are all public system settings + * + * <p>All settings in {@link System.SETTINGS_TO_BACKUP} array *must* have a non-null validator, + * otherwise they won't be restored. + */ + @UnsupportedAppUsage + public static final Map<String, Validator> VALIDATORS = new ArrayMap<>(); + + static { + VALIDATORS.put( + System.STAY_ON_WHILE_PLUGGED_IN, + value -> { + try { + int val = Integer.parseInt(value); + return (val == 0) + || (val == BatteryManager.BATTERY_PLUGGED_AC) + || (val == BatteryManager.BATTERY_PLUGGED_USB) + || (val == BatteryManager.BATTERY_PLUGGED_WIRELESS) + || (val + == (BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_USB)) + || (val + == (BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_WIRELESS)) + || (val + == (BatteryManager.BATTERY_PLUGGED_USB + | BatteryManager.BATTERY_PLUGGED_WIRELESS)) + || (val + == (BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_USB + | BatteryManager.BATTERY_PLUGGED_WIRELESS)); + } catch (NumberFormatException e) { + return false; + } + }); + VALIDATORS.put(System.END_BUTTON_BEHAVIOR, new InclusiveIntegerRangeValidator(0, 3)); + VALIDATORS.put(System.WIFI_USE_STATIC_IP, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.BLUETOOTH_DISCOVERABILITY, new InclusiveIntegerRangeValidator(0, 2)); + VALIDATORS.put(System.BLUETOOTH_DISCOVERABILITY_TIMEOUT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put( + System.NEXT_ALARM_FORMATTED, + new Validator() { + private static final int MAX_LENGTH = 1000; + + @Override + public boolean validate(String value) { + // TODO: No idea what the correct format is. + return value == null || value.length() < MAX_LENGTH; + } + }); + VALIDATORS.put( + System.FONT_SCALE, + value -> { + try { + return Float.parseFloat(value) >= 0; + } catch (NumberFormatException | NullPointerException e) { + return false; + } + }); + VALIDATORS.put(System.DIM_SCREEN, BOOLEAN_VALIDATOR); + VALIDATORS.put( + System.DISPLAY_COLOR_MODE, + new Validator() { + @Override + public boolean validate(@Nullable String value) { + // Assume the actual validation that this device can properly handle this + // kind of + // color mode further down in ColorDisplayManager / ColorDisplayService. + try { + final int setting = Integer.parseInt(value); + final boolean isInFrameworkRange = + setting >= ColorDisplayManager.COLOR_MODE_NATURAL + && setting <= ColorDisplayManager.COLOR_MODE_AUTOMATIC; + final boolean isInVendorRange = + setting >= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MIN + && setting + <= ColorDisplayManager + .VENDOR_COLOR_MODE_RANGE_MAX; + return isInFrameworkRange || isInVendorRange; + } catch (NumberFormatException | NullPointerException e) { + return false; + } + } + }); + VALIDATORS.put(System.SCREEN_OFF_TIMEOUT, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(System.SCREEN_BRIGHTNESS_FOR_VR, new InclusiveIntegerRangeValidator(0, 255)); + VALIDATORS.put(System.SCREEN_BRIGHTNESS_MODE, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.ADAPTIVE_SLEEP, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.MODE_RINGER_STREAMS_AFFECTED, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(System.MUTE_STREAMS_AFFECTED, NON_NEGATIVE_INTEGER_VALIDATOR); + VALIDATORS.put(System.VIBRATE_ON, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.NOTIFICATION_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR); + VALIDATORS.put(System.RING_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR); + VALIDATORS.put(System.HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR); + VALIDATORS.put(System.RINGTONE, URI_VALIDATOR); + VALIDATORS.put(System.NOTIFICATION_SOUND, URI_VALIDATOR); + VALIDATORS.put(System.ALARM_ALERT, URI_VALIDATOR); + VALIDATORS.put(System.TEXT_AUTO_REPLACE, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.TEXT_AUTO_CAPS, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.TEXT_AUTO_PUNCTUATE, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.TEXT_SHOW_PASSWORD, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.AUTO_TIME, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.AUTO_TIME_ZONE, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SHOW_GTALK_SERVICE_STATUS, BOOLEAN_VALIDATOR); + VALIDATORS.put( + System.WALLPAPER_ACTIVITY, + new Validator() { + private static final int MAX_LENGTH = 1000; + + @Override + public boolean validate(String value) { + if (value != null && value.length() > MAX_LENGTH) { + return false; + } + return ComponentName.unflattenFromString(value) != null; + } + }); + VALIDATORS.put( + System.TIME_12_24, new DiscreteValueValidator(new String[] {"12", "24", null})); + VALIDATORS.put(System.DATE_FORMAT, DATE_FORMAT_VALIDATOR); + VALIDATORS.put(System.SETUP_WIZARD_HAS_RUN, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.ACCELEROMETER_ROTATION, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.USER_ROTATION, new InclusiveIntegerRangeValidator(0, 3)); + VALIDATORS.put(System.DTMF_TONE_WHEN_DIALING, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SOUND_EFFECTS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.HAPTIC_FEEDBACK_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.POWER_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.DOCK_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SHOW_WEB_SUGGESTIONS, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.WIFI_USE_STATIC_IP, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.ADVANCED_SETTINGS, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SCREEN_AUTO_BRIGHTNESS_ADJ, new InclusiveFloatRangeValidator(-1, 1)); + VALIDATORS.put(System.VIBRATE_INPUT_DEVICES, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.MASTER_MONO, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.MASTER_BALANCE, new InclusiveFloatRangeValidator(-1.f, 1.f)); + VALIDATORS.put(System.NOTIFICATIONS_USE_RING_VOLUME, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.VIBRATE_IN_SILENT, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.MEDIA_BUTTON_RECEIVER, COMPONENT_NAME_VALIDATOR); + VALIDATORS.put(System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.VIBRATE_WHEN_RINGING, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.DTMF_TONE_TYPE_WHEN_DIALING, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.HEARING_AID, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.TTY_MODE, new InclusiveIntegerRangeValidator(0, 3)); + VALIDATORS.put(System.NOTIFICATION_LIGHT_PULSE, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.POINTER_LOCATION, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SHOW_TOUCHES, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.WINDOW_ORIENTATION_LISTENER_LOG, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.LOCKSCREEN_SOUNDS_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.LOCKSCREEN_DISABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SIP_RECEIVE_CALLS, BOOLEAN_VALIDATOR); + VALIDATORS.put( + System.SIP_CALL_OPTIONS, + new DiscreteValueValidator(new String[] {"SIP_ALWAYS", "SIP_ADDRESS_ONLY"})); + VALIDATORS.put(System.SIP_ALWAYS, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SIP_ADDRESS_ONLY, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SIP_ASK_ME_EACH_TIME, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.POINTER_SPEED, new InclusiveFloatRangeValidator(-7, 7)); + VALIDATORS.put(System.LOCK_TO_APP_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put( + System.EGG_MODE, + new Validator() { + @Override + public boolean validate(@Nullable String value) { + try { + return Long.parseLong(value) >= 0; + } catch (NumberFormatException e) { + return false; + } + } + }); + VALIDATORS.put(System.WIFI_STATIC_IP, LENIENT_IP_ADDRESS_VALIDATOR); + VALIDATORS.put(System.WIFI_STATIC_GATEWAY, LENIENT_IP_ADDRESS_VALIDATOR); + VALIDATORS.put(System.WIFI_STATIC_NETMASK, LENIENT_IP_ADDRESS_VALIDATOR); + VALIDATORS.put(System.WIFI_STATIC_DNS1, LENIENT_IP_ADDRESS_VALIDATOR); + VALIDATORS.put(System.WIFI_STATIC_DNS2, LENIENT_IP_ADDRESS_VALIDATOR); + VALIDATORS.put(System.SHOW_BATTERY_PERCENT, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.NOTIFICATION_LIGHT_PULSE, BOOLEAN_VALIDATOR); + } +} diff --git a/core/java/android/provider/settings/validators/TTSListValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/TTSListValidator.java index 6c73471a8e8e..6c73471a8e8e 100644 --- a/core/java/android/provider/settings/validators/TTSListValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/TTSListValidator.java diff --git a/core/java/android/provider/settings/validators/TileListValidator.java b/packages/SettingsProvider/src/android/provider/settings/validators/TileListValidator.java index c69644252bcd..c69644252bcd 100644 --- a/core/java/android/provider/settings/validators/TileListValidator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/TileListValidator.java diff --git a/core/java/android/provider/settings/validators/Validator.java b/packages/SettingsProvider/src/android/provider/settings/validators/Validator.java index 393a03ddf916..393a03ddf916 100644 --- a/core/java/android/provider/settings/validators/Validator.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/Validator.java diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 50528a1f96e3..8446ad16e49a 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -34,6 +34,9 @@ import android.os.Build; import android.os.ParcelFileDescriptor; import android.os.UserHandle; import android.provider.Settings; +import android.provider.settings.validators.GlobalSettingsValidators; +import android.provider.settings.validators.SecureSettingsValidators; +import android.provider.settings.validators.SystemSettingsValidators; import android.provider.settings.validators.Validator; import android.util.ArrayMap; import android.util.ArraySet; @@ -636,15 +639,15 @@ public class SettingsBackupAgent extends BackupAgentHelper { whitelist = ArrayUtils.concatElements(String.class, Settings.Secure.SETTINGS_TO_BACKUP, Settings.Secure.LEGACY_RESTORE_SETTINGS, Settings.Secure.DEVICE_SPECIFIC_SETTINGS_TO_BACKUP); - validators = Settings.Secure.VALIDATORS; + validators = SecureSettingsValidators.VALIDATORS; } else if (contentUri.equals(Settings.System.CONTENT_URI)) { whitelist = ArrayUtils.concatElements(String.class, Settings.System.SETTINGS_TO_BACKUP, Settings.System.LEGACY_RESTORE_SETTINGS); - validators = Settings.System.VALIDATORS; + validators = SystemSettingsValidators.VALIDATORS; } else if (contentUri.equals(Settings.Global.CONTENT_URI)) { whitelist = ArrayUtils.concatElements(String.class, Settings.Global.SETTINGS_TO_BACKUP, Settings.Global.LEGACY_RESTORE_SETTINGS); - validators = Settings.Global.VALIDATORS; + validators = GlobalSettingsValidators.VALIDATORS; } else { throw new IllegalArgumentException("Unknown URI: " + contentUri); } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index e492e28f6172..4d71e72b59d6 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -70,6 +70,7 @@ import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.Settings.Global; import android.provider.Settings.Secure; +import android.provider.settings.validators.SystemSettingsValidators; import android.provider.settings.validators.Validator; import android.text.TextUtils; import android.util.ArrayMap; @@ -1717,7 +1718,7 @@ public class SettingsProvider extends ContentProvider { } private void validateSystemSettingValue(String name, String value) { - Validator validator = Settings.System.VALIDATORS.get(name); + Validator validator = SystemSettingsValidators.VALIDATORS.get(name); if (validator != null && !validator.validate(value)) { throw new IllegalArgumentException("Invalid value: " + value + " for setting: " + name); diff --git a/core/tests/coretests/src/android/provider/settings/validators/SettingsValidatorsTest.java b/packages/SettingsProvider/test/src/android/provider/settings/validators/SettingsValidatorsTest.java index 5f042d3dce0f..6b18d48bf92d 100644 --- a/core/tests/coretests/src/android/provider/settings/validators/SettingsValidatorsTest.java +++ b/packages/SettingsProvider/test/src/android/provider/settings/validators/SettingsValidatorsTest.java @@ -218,7 +218,7 @@ public class SettingsValidatorsTest { @Test public void dateFormatValidator_onNullValue_returnsFalse() { - assertFalse(Settings.System.DATE_FORMAT_VALIDATOR.validate(null)); + assertFalse(SettingsValidators.DATE_FORMAT_VALIDATOR.validate(null)); } @Test @@ -238,18 +238,18 @@ public class SettingsValidatorsTest { @Test public void testJSONObjectValidator_onNullValue_returnsFalse() { - assertThat(SettingsValidators.JSON_OBJECT_VALIDATOR.validate(null)).isFalse(); + assertFalse(SettingsValidators.JSON_OBJECT_VALIDATOR.validate(null)); } @Test public void testJSONObjectValidator_onEmptyString_returnsFalse() { - assertThat(SettingsValidators.JSON_OBJECT_VALIDATOR.validate("")).isFalse(); + assertFalse(SettingsValidators.JSON_OBJECT_VALIDATOR.validate("")); } @Test public void ensureAllBackedUpSystemSettingsHaveValidators() { String offenders = getOffenders(concat(Settings.System.SETTINGS_TO_BACKUP, - Settings.System.LEGACY_RESTORE_SETTINGS), Settings.System.VALIDATORS); + Settings.System.LEGACY_RESTORE_SETTINGS), SystemSettingsValidators.VALIDATORS); failIfOffendersPresent(offenders, "Settings.System"); } @@ -296,7 +296,7 @@ public class SettingsValidatorsTest { @Test public void ensureAllBackedUpGlobalSettingsHaveValidators() { String offenders = getOffenders(concat(Settings.Global.SETTINGS_TO_BACKUP, - Settings.Global.LEGACY_RESTORE_SETTINGS), Settings.Global.VALIDATORS); + Settings.Global.LEGACY_RESTORE_SETTINGS), GlobalSettingsValidators.VALIDATORS); failIfOffendersPresent(offenders, "Settings.Global"); } @@ -304,7 +304,7 @@ public class SettingsValidatorsTest { @Test public void ensureAllBackedUpSecureSettingsHaveValidators() { String offenders = getOffenders(concat(Settings.Secure.SETTINGS_TO_BACKUP, - Settings.Secure.LEGACY_RESTORE_SETTINGS), Settings.Secure.VALIDATORS); + Settings.Secure.LEGACY_RESTORE_SETTINGS), SecureSettingsValidators.VALIDATORS); failIfOffendersPresent(offenders, "Settings.Secure"); } |