Move the list of settings to backup out of the Settings class
Bug: 139449903
Test: atest SettingsProviderTest
Change-Id: Ia1636732e4b6458fd874a6748dddfcaf7d967545
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index fecb7f1..dd3942e 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4193,73 +4193,6 @@
*/
/**
- * Settings to backup. This is here so that it's in the same place as the settings
- * keys and easy to update.
- *
- * NOTE: Settings are backed up and restored in the order they appear
- * in this array. If you have one setting depending on another,
- * make sure that they are ordered appropriately.
- *
- * @hide
- */
- @UnsupportedAppUsage
- public static final String[] SETTINGS_TO_BACKUP = {
- STAY_ON_WHILE_PLUGGED_IN, // moved to global
- WIFI_USE_STATIC_IP,
- WIFI_STATIC_IP,
- WIFI_STATIC_GATEWAY,
- WIFI_STATIC_NETMASK,
- WIFI_STATIC_DNS1,
- WIFI_STATIC_DNS2,
- BLUETOOTH_DISCOVERABILITY,
- BLUETOOTH_DISCOVERABILITY_TIMEOUT,
- FONT_SCALE,
- DIM_SCREEN,
- SCREEN_OFF_TIMEOUT,
- SCREEN_BRIGHTNESS_MODE,
- SCREEN_AUTO_BRIGHTNESS_ADJ,
- SCREEN_BRIGHTNESS_FOR_VR,
- ADAPTIVE_SLEEP,
- VIBRATE_INPUT_DEVICES,
- MODE_RINGER_STREAMS_AFFECTED,
- TEXT_AUTO_REPLACE,
- TEXT_AUTO_CAPS,
- TEXT_AUTO_PUNCTUATE,
- TEXT_SHOW_PASSWORD,
- AUTO_TIME, // moved to global
- AUTO_TIME_ZONE, // moved to global
- TIME_12_24,
- DATE_FORMAT,
- DTMF_TONE_WHEN_DIALING,
- DTMF_TONE_TYPE_WHEN_DIALING,
- HEARING_AID,
- TTY_MODE,
- MASTER_MONO,
- MASTER_BALANCE,
- SOUND_EFFECTS_ENABLED,
- HAPTIC_FEEDBACK_ENABLED,
- POWER_SOUNDS_ENABLED, // moved to global
- DOCK_SOUNDS_ENABLED, // moved to global
- LOCKSCREEN_SOUNDS_ENABLED,
- SHOW_WEB_SUGGESTIONS,
- SIP_CALL_OPTIONS,
- SIP_RECEIVE_CALLS,
- POINTER_SPEED,
- VIBRATE_WHEN_RINGING,
- RINGTONE,
- LOCK_TO_APP_ENABLED,
- NOTIFICATION_SOUND,
- ACCELEROMETER_ROTATION,
- SHOW_BATTERY_PERCENT,
- NOTIFICATION_VIBRATION_INTENSITY,
- RING_VIBRATION_INTENSITY,
- HAPTIC_FEEDBACK_INTENSITY,
- DISPLAY_COLOR_MODE,
- ALARM_ALERT,
- NOTIFICATION_LIGHT_PULSE,
- };
-
- /**
* Keys we no longer back up under the current schema, but want to continue to
* process when restoring historical backup datasets.
*
@@ -8171,152 +8104,6 @@
public static final String AWARE_LOCK_ENABLED = "aware_lock_enabled";
/**
- * This are the settings to be backed up.
- *
- * NOTE: Settings are backed up and restored in the order they appear
- * in this array. If you have one setting depending on another,
- * make sure that they are ordered appropriately.
- *
- * @hide
- */
- @UnsupportedAppUsage
- public static final String[] SETTINGS_TO_BACKUP = {
- BUGREPORT_IN_POWER_MENU, // moved to global
- ALLOW_MOCK_LOCATION,
- USB_MASS_STORAGE_ENABLED, // moved to global
- ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
- ACCESSIBILITY_DISPLAY_DALTONIZER,
- ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
- ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
- ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
- AUTOFILL_SERVICE,
- ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
- ENABLED_ACCESSIBILITY_SERVICES,
- ENABLED_VR_LISTENERS,
- TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
- TOUCH_EXPLORATION_ENABLED,
- ACCESSIBILITY_ENABLED,
- ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
- ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
- ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
- ACCESSIBILITY_SHORTCUT_ENABLED,
- ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
- ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
- ACCESSIBILITY_CAPTIONING_PRESET,
- ACCESSIBILITY_CAPTIONING_ENABLED,
- ACCESSIBILITY_CAPTIONING_LOCALE,
- ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
- ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
- ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
- ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
- ACCESSIBILITY_CAPTIONING_TYPEFACE,
- ACCESSIBILITY_CAPTIONING_FONT_SCALE,
- ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
- TTS_DEFAULT_RATE,
- TTS_DEFAULT_PITCH,
- TTS_DEFAULT_SYNTH,
- TTS_ENABLED_PLUGINS,
- TTS_DEFAULT_LOCALE,
- SHOW_IME_WITH_HARD_KEYBOARD,
- WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, // moved to global
- WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, // moved to global
- WIFI_NUM_OPEN_NETWORKS_KEPT, // moved to global
- MOUNT_PLAY_NOTIFICATION_SND,
- MOUNT_UMS_AUTOSTART,
- MOUNT_UMS_PROMPT,
- MOUNT_UMS_NOTIFY_ENABLED,
- DOUBLE_TAP_TO_WAKE,
- WAKE_GESTURE_ENABLED,
- LONG_PRESS_TIMEOUT,
- CAMERA_GESTURE_DISABLED,
- ACCESSIBILITY_AUTOCLICK_ENABLED,
- ACCESSIBILITY_AUTOCLICK_DELAY,
- ACCESSIBILITY_LARGE_POINTER_ICON,
- PREFERRED_TTY_MODE,
- ENHANCED_VOICE_PRIVACY_ENABLED,
- TTY_MODE_ENABLED,
- RTT_CALLING_MODE,
- INCALL_POWER_BUTTON_BEHAVIOR,
- NIGHT_DISPLAY_CUSTOM_START_TIME,
- NIGHT_DISPLAY_CUSTOM_END_TIME,
- NIGHT_DISPLAY_COLOR_TEMPERATURE,
- NIGHT_DISPLAY_AUTO_MODE,
- DISPLAY_WHITE_BALANCE_ENABLED,
- SYNC_PARENT_SOUNDS,
- CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
- CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
- SYSTEM_NAVIGATION_KEYS_ENABLED,
- QS_TILES,
- DOZE_ENABLED,
- DOZE_ALWAYS_ON,
- DOZE_PICK_UP_GESTURE,
- DOZE_DOUBLE_TAP_GESTURE,
- DOZE_TAP_SCREEN_GESTURE,
- DOZE_WAKE_LOCK_SCREEN_GESTURE,
- DOZE_WAKE_DISPLAY_GESTURE,
- NFC_PAYMENT_DEFAULT_COMPONENT,
- AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
- FACE_UNLOCK_KEYGUARD_ENABLED,
- SHOW_MEDIA_WHEN_BYPASSING,
- FACE_UNLOCK_DISMISSES_KEYGUARD,
- FACE_UNLOCK_APP_ENABLED,
- FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION,
- ASSIST_GESTURE_ENABLED,
- ASSIST_GESTURE_SILENCE_ALERTS_ENABLED,
- ASSIST_GESTURE_WAKE_ENABLED,
- VR_DISPLAY_MODE,
- NOTIFICATION_BADGING,
- NOTIFICATION_BUBBLES,
- NOTIFICATION_DISMISS_RTL,
- QS_AUTO_ADDED_TILES,
- SCREENSAVER_ENABLED,
- SCREENSAVER_COMPONENTS,
- SCREENSAVER_ACTIVATE_ON_DOCK,
- SCREENSAVER_ACTIVATE_ON_SLEEP,
- LOCKDOWN_IN_POWER_MENU,
- SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
- VOLUME_HUSH_GESTURE,
- MANUAL_RINGER_TOGGLE_COUNT,
- HUSH_GESTURE_USED,
- IN_CALL_NOTIFICATION_ENABLED,
- LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- LOCK_SCREEN_CUSTOM_CLOCK_FACE,
- LOCK_SCREEN_SHOW_NOTIFICATIONS,
- LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
- SHOW_NOTIFICATION_SNOOZE,
- ZEN_DURATION,
- SHOW_ZEN_UPGRADE_NOTIFICATION,
- SHOW_ZEN_SETTINGS_SUGGESTION,
- ZEN_SETTINGS_UPDATED,
- ZEN_SETTINGS_SUGGESTION_VIEWED,
- CHARGING_SOUNDS_ENABLED,
- CHARGING_VIBRATION_ENABLED,
- ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS,
- ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS,
- NOTIFICATION_NEW_INTERRUPTION_MODEL,
- TRUST_AGENTS_EXTEND_UNLOCK,
- UI_NIGHT_MODE,
- LOCK_SCREEN_WHEN_TRUST_LOST,
- SKIP_GESTURE,
- SKIP_DIRECTION,
- SILENCE_GESTURE,
- THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
- NAVIGATION_MODE,
- AWARE_ENABLED,
- SKIP_GESTURE_COUNT,
- SKIP_TOUCH_COUNT,
- SILENCE_ALARMS_GESTURE_COUNT,
- SILENCE_CALL_GESTURE_COUNT,
- SILENCE_TIMER_GESTURE_COUNT,
- SILENCE_ALARMS_TOUCH_COUNT,
- SILENCE_CALL_TOUCH_COUNT,
- SILENCE_TIMER_TOUCH_COUNT,
- DARK_MODE_DIALOG_SEEN,
- GLOBAL_ACTIONS_PANEL_ENABLED,
- AWARE_LOCK_ENABLED
- };
-
- /**
* The settings values which should only be restored if the target device is the
* same as the source device
*
@@ -12688,59 +12475,6 @@
"power_button_very_long_press";
/**
- * Settings to backup. This is here so that it's in the same place as the settings
- * keys and easy to update.
- *
- * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in System
- * and Secure as well. This is because those tables drive both backup and
- * restore, and restore needs to properly whitelist keys that used to live
- * in those namespaces. The keys will only actually be backed up / restored
- * if they are also mentioned in this table (Global.SETTINGS_TO_BACKUP).
- *
- * NOTE: Settings are backed up and restored in the order they appear
- * in this array. If you have one setting depending on another,
- * make sure that they are ordered appropriately.
- *
- * NOTE: This table should only be used for settings which should be restored
- * between different types of devices {@see #DEVICE_SPECIFIC_SETTINGS_TO_BACKUP}
- *
- * @hide
- */
- public static final String[] SETTINGS_TO_BACKUP = {
- APPLY_RAMPING_RINGER,
- BUGREPORT_IN_POWER_MENU,
- STAY_ON_WHILE_PLUGGED_IN,
- APP_AUTO_RESTRICTION_ENABLED,
- AUTO_TIME,
- AUTO_TIME_ZONE,
- POWER_SOUNDS_ENABLED,
- DOCK_SOUNDS_ENABLED,
- CHARGING_SOUNDS_ENABLED,
- USB_MASS_STORAGE_ENABLED,
- NETWORK_RECOMMENDATIONS_ENABLED,
- WIFI_WAKEUP_ENABLED,
- WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
- USE_OPEN_WIFI_PACKAGE,
- WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
- EMERGENCY_TONE,
- CALL_AUTO_RETRY,
- DOCK_AUDIO_MEDIA_ENABLED,
- ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS,
- ENCODED_SURROUND_OUTPUT,
- ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS,
- LOW_POWER_MODE_TRIGGER_LEVEL,
- LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
- LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL,
- BLUETOOTH_ON,
- PRIVATE_DNS_MODE,
- PRIVATE_DNS_SPECIFIER,
- SOFT_AP_TIMEOUT_ENABLED,
- ZEN_DURATION,
- CHARGING_VIBRATION_ENABLED,
- AWARE_ALLOWED,
- };
-
- /**
* Global settings that shouldn't be persisted.
*
* @hide
diff --git a/packages/SettingsProvider/Android.bp b/packages/SettingsProvider/Android.bp
index 49908a3..681b494 100644
--- a/packages/SettingsProvider/Android.bp
+++ b/packages/SettingsProvider/Android.bp
@@ -24,6 +24,7 @@
// because this test is not an instrumentation test. (because the target runs in the system process.)
srcs: [
"test/**/*.java",
+ "src/android/provider/settings/backup/*",
"src/android/provider/settings/validators/*",
"src/com/android/providers/settings/SettingsBackupAgent.java",
"src/com/android/providers/settings/SettingsState.java",
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java
new file mode 100644
index 0000000..0c49f63
--- /dev/null
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java
@@ -0,0 +1,73 @@
+/*
+ * 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.backup;
+
+import android.provider.Settings;
+
+/** Information related to the backup of Global settings */
+public class GlobalSettings {
+
+ /**
+ * These keys may be mentioned in the SETTINGS_TO_BACKUP arrays in SystemSettings
+ * and SecureSettings as well. This is because those tables drive both backup and
+ * restore, and restore needs to properly whitelist keys that used to live
+ * in those namespaces.
+ *
+ * NOTE: Settings are backed up and restored in the order they appear
+ * in this array. If you have one setting depending on another,
+ * make sure that they are ordered appropriately.
+ *
+ * NOTE: This table should only be used for settings which should be restored
+ * between different types of devices
+ * {@see #Settings.Secure.DEVICE_SPECIFIC_SETTINGS_TO_BACKUP}
+ *
+ * NOTE: All settings which are backed up should have a corresponding validator.
+ */
+ public static final String[] SETTINGS_TO_BACKUP = {
+ Settings.Global.APPLY_RAMPING_RINGER,
+ Settings.Global.BUGREPORT_IN_POWER_MENU,
+ Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
+ Settings.Global.APP_AUTO_RESTRICTION_ENABLED,
+ Settings.Global.AUTO_TIME,
+ Settings.Global.AUTO_TIME_ZONE,
+ Settings.Global.POWER_SOUNDS_ENABLED,
+ Settings.Global.DOCK_SOUNDS_ENABLED,
+ Settings.Global.CHARGING_SOUNDS_ENABLED,
+ Settings.Global.USB_MASS_STORAGE_ENABLED,
+ Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED,
+ Settings.Global.WIFI_WAKEUP_ENABLED,
+ Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
+ Settings.Global.USE_OPEN_WIFI_PACKAGE,
+ Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
+ Settings.Global.EMERGENCY_TONE,
+ Settings.Global.CALL_AUTO_RETRY,
+ Settings.Global.DOCK_AUDIO_MEDIA_ENABLED,
+ Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS,
+ Settings.Global.ENCODED_SURROUND_OUTPUT,
+ Settings.Global.ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS,
+ Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL,
+ Settings.Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
+ Settings.Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL,
+ Settings.Global.BLUETOOTH_ON,
+ Settings.Global.PRIVATE_DNS_MODE,
+ Settings.Global.PRIVATE_DNS_SPECIFIER,
+ Settings.Global.SOFT_AP_TIMEOUT_ENABLED,
+ Settings.Global.ZEN_DURATION,
+ Settings.Global.CHARGING_VIBRATION_ENABLED,
+ Settings.Global.AWARE_ALLOWED,
+ };
+}
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
new file mode 100644
index 0000000..8c2e431
--- /dev/null
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
@@ -0,0 +1,166 @@
+/*
+ * 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.backup;
+
+import android.annotation.UnsupportedAppUsage;
+import android.provider.Settings;
+
+/** Information relating to the Secure settings which should be backed up */
+public class SecureSettings {
+
+ /**
+ * NOTE: Settings are backed up and restored in the order they appear
+ * in this array. If you have one setting depending on another,
+ * make sure that they are ordered appropriately.
+ */
+ @UnsupportedAppUsage
+ public static final String[] SETTINGS_TO_BACKUP = {
+ Settings.Secure.BUGREPORT_IN_POWER_MENU, // moved to global
+ Settings.Secure.ALLOW_MOCK_LOCATION,
+ Settings.Secure.USB_MASS_STORAGE_ENABLED, // moved to global
+ Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
+ Settings.Secure.AUTOFILL_SERVICE,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE,
+ Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
+ Settings.Secure.ENABLED_VR_LISTENERS,
+ Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
+ Settings.Secure.TOUCH_EXPLORATION_ENABLED,
+ Settings.Secure.ACCESSIBILITY_ENABLED,
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
+ Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED,
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
+ Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_BACKGROUND_COLOR,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FOREGROUND_COLOR,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
+ Settings.Secure.TTS_DEFAULT_RATE,
+ Settings.Secure.TTS_DEFAULT_PITCH,
+ Settings.Secure.TTS_DEFAULT_SYNTH,
+ Settings.Secure.TTS_ENABLED_PLUGINS,
+ Settings.Secure.TTS_DEFAULT_LOCALE,
+ Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD,
+ Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, // moved to global
+ Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, // moved to global
+ Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, // moved to global
+ Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND,
+ Settings.Secure.MOUNT_UMS_AUTOSTART,
+ Settings.Secure.MOUNT_UMS_PROMPT,
+ Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED,
+ Settings.Secure.DOUBLE_TAP_TO_WAKE,
+ Settings.Secure.WAKE_GESTURE_ENABLED,
+ Settings.Secure.LONG_PRESS_TIMEOUT,
+ Settings.Secure.CAMERA_GESTURE_DISABLED,
+ Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED,
+ Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY,
+ Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
+ Settings.Secure.PREFERRED_TTY_MODE,
+ Settings.Secure.ENHANCED_VOICE_PRIVACY_ENABLED,
+ Settings.Secure.TTY_MODE_ENABLED,
+ Settings.Secure.RTT_CALLING_MODE,
+ Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
+ Settings.Secure.NIGHT_DISPLAY_CUSTOM_START_TIME,
+ Settings.Secure.NIGHT_DISPLAY_CUSTOM_END_TIME,
+ Settings.Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE,
+ Settings.Secure.NIGHT_DISPLAY_AUTO_MODE,
+ Settings.Secure.DISPLAY_WHITE_BALANCE_ENABLED,
+ Settings.Secure.SYNC_PARENT_SOUNDS,
+ Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED,
+ Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
+ Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED,
+ Settings.Secure.QS_TILES,
+ Settings.Secure.DOZE_ENABLED,
+ Settings.Secure.DOZE_ALWAYS_ON,
+ Settings.Secure.DOZE_PICK_UP_GESTURE,
+ Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
+ Settings.Secure.DOZE_TAP_SCREEN_GESTURE,
+ Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE,
+ Settings.Secure.DOZE_WAKE_DISPLAY_GESTURE,
+ Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
+ Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
+ Settings.Secure.FACE_UNLOCK_KEYGUARD_ENABLED,
+ Settings.Secure.SHOW_MEDIA_WHEN_BYPASSING,
+ Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD,
+ Settings.Secure.FACE_UNLOCK_APP_ENABLED,
+ Settings.Secure.FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION,
+ Settings.Secure.ASSIST_GESTURE_ENABLED,
+ Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED,
+ Settings.Secure.ASSIST_GESTURE_WAKE_ENABLED,
+ Settings.Secure.VR_DISPLAY_MODE,
+ Settings.Secure.NOTIFICATION_BADGING,
+ Settings.Secure.NOTIFICATION_BUBBLES,
+ Settings.Secure.NOTIFICATION_DISMISS_RTL,
+ Settings.Secure.QS_AUTO_ADDED_TILES,
+ Settings.Secure.SCREENSAVER_ENABLED,
+ Settings.Secure.SCREENSAVER_COMPONENTS,
+ Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK,
+ Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP,
+ Settings.Secure.LOCKDOWN_IN_POWER_MENU,
+ Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
+ Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.MANUAL_RINGER_TOGGLE_COUNT,
+ Settings.Secure.HUSH_GESTURE_USED,
+ Settings.Secure.IN_CALL_NOTIFICATION_ENABLED,
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
+ Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE,
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
+ Settings.Secure.SHOW_NOTIFICATION_SNOOZE,
+ Settings.Secure.ZEN_DURATION,
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION,
+ Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION,
+ Settings.Secure.ZEN_SETTINGS_UPDATED,
+ Settings.Secure.ZEN_SETTINGS_SUGGESTION_VIEWED,
+ Settings.Secure.CHARGING_SOUNDS_ENABLED,
+ Settings.Secure.CHARGING_VIBRATION_ENABLED,
+ Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS,
+ Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS,
+ Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL,
+ Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK,
+ Settings.Secure.UI_NIGHT_MODE,
+ Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST,
+ Settings.Secure.SKIP_GESTURE,
+ Settings.Secure.SKIP_DIRECTION,
+ Settings.Secure.SILENCE_GESTURE,
+ Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
+ Settings.Secure.NAVIGATION_MODE,
+ Settings.Secure.AWARE_ENABLED,
+ Settings.Secure.SKIP_GESTURE_COUNT,
+ Settings.Secure.SKIP_TOUCH_COUNT,
+ Settings.Secure.SILENCE_ALARMS_GESTURE_COUNT,
+ Settings.Secure.SILENCE_CALL_GESTURE_COUNT,
+ Settings.Secure.SILENCE_TIMER_GESTURE_COUNT,
+ Settings.Secure.SILENCE_ALARMS_TOUCH_COUNT,
+ Settings.Secure.SILENCE_CALL_TOUCH_COUNT,
+ Settings.Secure.SILENCE_TIMER_TOUCH_COUNT,
+ Settings.Secure.DARK_MODE_DIALOG_SEEN,
+ Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED,
+ Settings.Secure.AWARE_LOCK_ENABLED
+ };
+}
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
new file mode 100644
index 0000000..89b19de
--- /dev/null
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
@@ -0,0 +1,88 @@
+/*
+ * 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.backup;
+
+import android.annotation.UnsupportedAppUsage;
+import android.provider.Settings;
+
+/** Information about the system settings to back up */
+public class SystemSettings {
+
+ /**
+ * Settings to backup.
+ *
+ * NOTE: Settings are backed up and restored in the order they appear
+ * in this array. If you have one setting depending on another,
+ * make sure that they are ordered appropriately.
+ */
+ @UnsupportedAppUsage
+ public static final String[] SETTINGS_TO_BACKUP = {
+ Settings.System.STAY_ON_WHILE_PLUGGED_IN, // moved to global
+ Settings.System.WIFI_USE_STATIC_IP,
+ Settings.System.WIFI_STATIC_IP,
+ Settings.System.WIFI_STATIC_GATEWAY,
+ Settings.System.WIFI_STATIC_NETMASK,
+ Settings.System.WIFI_STATIC_DNS1,
+ Settings.System.WIFI_STATIC_DNS2,
+ Settings.System.BLUETOOTH_DISCOVERABILITY,
+ Settings.System.BLUETOOTH_DISCOVERABILITY_TIMEOUT,
+ Settings.System.FONT_SCALE,
+ Settings.System.DIM_SCREEN,
+ Settings.System.SCREEN_OFF_TIMEOUT,
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ,
+ Settings.System.SCREEN_BRIGHTNESS_FOR_VR,
+ Settings.System.ADAPTIVE_SLEEP,
+ Settings.System.VIBRATE_INPUT_DEVICES,
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED,
+ Settings.System.TEXT_AUTO_REPLACE,
+ Settings.System.TEXT_AUTO_CAPS,
+ Settings.System.TEXT_AUTO_PUNCTUATE,
+ Settings.System.TEXT_SHOW_PASSWORD,
+ Settings.System.AUTO_TIME, // moved to global
+ Settings.System.AUTO_TIME_ZONE, // moved to global
+ Settings.System.TIME_12_24,
+ Settings.System.DATE_FORMAT,
+ Settings.System.DTMF_TONE_WHEN_DIALING,
+ Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,
+ Settings.System.HEARING_AID,
+ Settings.System.TTY_MODE,
+ Settings.System.MASTER_MONO,
+ Settings.System.MASTER_BALANCE,
+ Settings.System.SOUND_EFFECTS_ENABLED,
+ Settings.System.HAPTIC_FEEDBACK_ENABLED,
+ Settings.System.POWER_SOUNDS_ENABLED, // moved to global
+ Settings.System.DOCK_SOUNDS_ENABLED, // moved to global
+ Settings.System.LOCKSCREEN_SOUNDS_ENABLED,
+ Settings.System.SHOW_WEB_SUGGESTIONS,
+ Settings.System.SIP_CALL_OPTIONS,
+ Settings.System.SIP_RECEIVE_CALLS,
+ Settings.System.POINTER_SPEED,
+ Settings.System.VIBRATE_WHEN_RINGING,
+ Settings.System.RINGTONE,
+ Settings.System.LOCK_TO_APP_ENABLED,
+ Settings.System.NOTIFICATION_SOUND,
+ Settings.System.ACCELEROMETER_ROTATION,
+ Settings.System.SHOW_BATTERY_PERCENT,
+ Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+ Settings.System.RING_VIBRATION_INTENSITY,
+ Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+ Settings.System.DISPLAY_COLOR_MODE,
+ Settings.System.ALARM_ALERT,
+ Settings.System.NOTIFICATION_LIGHT_PULSE,
+ };
+}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 8446ad1..f545fa6 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.ParcelFileDescriptor;
import android.os.UserHandle;
import android.provider.Settings;
+import android.provider.settings.backup.GlobalSettings;
+import android.provider.settings.backup.SecureSettings;
+import android.provider.settings.backup.SystemSettings;
import android.provider.settings.validators.GlobalSettingsValidators;
import android.provider.settings.validators.SecureSettingsValidators;
import android.provider.settings.validators.SystemSettingsValidators;
@@ -545,7 +548,7 @@
Cursor cursor = getContentResolver().query(Settings.System.CONTENT_URI, PROJECTION, null,
null, null);
try {
- return extractRelevantValues(cursor, Settings.System.SETTINGS_TO_BACKUP);
+ return extractRelevantValues(cursor, SystemSettings.SETTINGS_TO_BACKUP);
} finally {
cursor.close();
}
@@ -555,7 +558,7 @@
Cursor cursor = getContentResolver().query(Settings.Secure.CONTENT_URI, PROJECTION, null,
null, null);
try {
- return extractRelevantValues(cursor, Settings.Secure.SETTINGS_TO_BACKUP);
+ return extractRelevantValues(cursor, SecureSettings.SETTINGS_TO_BACKUP);
} finally {
cursor.close();
}
@@ -565,7 +568,7 @@
Cursor cursor = getContentResolver().query(Settings.Global.CONTENT_URI, PROJECTION, null,
null, null);
try {
- return extractRelevantValues(cursor, Settings.Global.SETTINGS_TO_BACKUP);
+ return extractRelevantValues(cursor, GlobalSettings.SETTINGS_TO_BACKUP);
} finally {
cursor.close();
}
@@ -636,16 +639,16 @@
final String[] whitelist;
Map<String, Validator> validators = null;
if (contentUri.equals(Settings.Secure.CONTENT_URI)) {
- whitelist = ArrayUtils.concatElements(String.class, Settings.Secure.SETTINGS_TO_BACKUP,
+ whitelist = ArrayUtils.concatElements(String.class, SecureSettings.SETTINGS_TO_BACKUP,
Settings.Secure.LEGACY_RESTORE_SETTINGS,
Settings.Secure.DEVICE_SPECIFIC_SETTINGS_TO_BACKUP);
validators = SecureSettingsValidators.VALIDATORS;
} else if (contentUri.equals(Settings.System.CONTENT_URI)) {
- whitelist = ArrayUtils.concatElements(String.class, Settings.System.SETTINGS_TO_BACKUP,
+ whitelist = ArrayUtils.concatElements(String.class, SystemSettings.SETTINGS_TO_BACKUP,
Settings.System.LEGACY_RESTORE_SETTINGS);
validators = SystemSettingsValidators.VALIDATORS;
} else if (contentUri.equals(Settings.Global.CONTENT_URI)) {
- whitelist = ArrayUtils.concatElements(String.class, Settings.Global.SETTINGS_TO_BACKUP,
+ whitelist = ArrayUtils.concatElements(String.class, GlobalSettings.SETTINGS_TO_BACKUP,
Settings.Global.LEGACY_RESTORE_SETTINGS);
validators = GlobalSettingsValidators.VALIDATORS;
} else {
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
similarity index 97%
rename from core/tests/coretests/src/android/provider/SettingsBackupTest.java
rename to packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
index eef780a..d7eb7e95 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
@@ -18,15 +18,16 @@
import static com.google.android.collect.Sets.newHashSet;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.is;
+import static junit.framework.Assert.assertTrue;
import static java.lang.reflect.Modifier.isFinal;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
import android.platform.test.annotations.Presubmit;
+import android.provider.settings.backup.GlobalSettings;
+import android.provider.settings.backup.SecureSettings;
+import android.provider.settings.backup.SystemSettings;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -727,45 +728,43 @@
public void systemSettingsBackedUpOrBlacklisted() {
checkSettingsBackedUpOrBlacklisted(
getCandidateSettings(Settings.System.class),
- newHashSet(Settings.System.SETTINGS_TO_BACKUP),
+ newHashSet(SystemSettings.SETTINGS_TO_BACKUP),
BACKUP_BLACKLISTED_SYSTEM_SETTINGS);
}
@Test
public void globalSettingsBackedUpOrBlacklisted() {
checkSettingsBackedUpOrBlacklisted(
- getCandidateSettings(Settings.Global.class),
- newHashSet(Settings.Global.SETTINGS_TO_BACKUP),
- BACKUP_BLACKLISTED_GLOBAL_SETTINGS);
+ getCandidateSettings(Settings.Global.class),
+ newHashSet(GlobalSettings.SETTINGS_TO_BACKUP),
+ BACKUP_BLACKLISTED_GLOBAL_SETTINGS);
}
@Test
public void secureSettingsBackedUpOrBlacklisted() {
HashSet<String> keys = new HashSet<String>();
- Collections.addAll(keys, Settings.Secure.SETTINGS_TO_BACKUP);
+ Collections.addAll(keys, SecureSettings.SETTINGS_TO_BACKUP);
Collections.addAll(keys, Settings.Secure.DEVICE_SPECIFIC_SETTINGS_TO_BACKUP);
checkSettingsBackedUpOrBlacklisted(
getCandidateSettings(Settings.Secure.class),
keys,
- BACKUP_BLACKLISTED_SECURE_SETTINGS);
+ BACKUP_BLACKLISTED_SECURE_SETTINGS);
}
private static void checkSettingsBackedUpOrBlacklisted(
Set<String> settings, Set<String> settingsToBackup, Set<String> blacklist) {
Set<String> settingsNotBackedUp = difference(settings, settingsToBackup);
Set<String> settingsNotBackedUpOrBlacklisted = difference(settingsNotBackedUp, blacklist);
- assertThat(
+ assertTrue(
"Settings not backed up or blacklisted",
- settingsNotBackedUpOrBlacklisted,
- is(empty()));
+ settingsNotBackedUpOrBlacklisted.isEmpty());
- assertThat(
- "blacklisted settings backed up",
- intersect(settingsToBackup, blacklist),
- is(empty()));
+ assertTrue(
+ "blacklisted settings backed up", intersect(settingsToBackup, blacklist).isEmpty());
}
- private static Set<String> getCandidateSettings(Class<? extends Settings.NameValueTable> clazz) {
+ private static Set<String> getCandidateSettings(
+ Class<? extends Settings.NameValueTable> clazz) {
HashSet<String> result = new HashSet<String>();
for (Field field : clazz.getDeclaredFields()) {
if (looksLikeValidSetting(field)) {
diff --git a/packages/SettingsProvider/test/src/android/provider/settings/validators/SettingsValidatorsTest.java b/packages/SettingsProvider/test/src/android/provider/settings/validators/SettingsValidatorsTest.java
index 6b18d48..a3b0835 100644
--- a/packages/SettingsProvider/test/src/android/provider/settings/validators/SettingsValidatorsTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/settings/validators/SettingsValidatorsTest.java
@@ -24,6 +24,9 @@
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
+import android.provider.settings.backup.GlobalSettings;
+import android.provider.settings.backup.SecureSettings;
+import android.provider.settings.backup.SystemSettings;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -248,7 +251,7 @@
@Test
public void ensureAllBackedUpSystemSettingsHaveValidators() {
- String offenders = getOffenders(concat(Settings.System.SETTINGS_TO_BACKUP,
+ String offenders = getOffenders(concat(SystemSettings.SETTINGS_TO_BACKUP,
Settings.System.LEGACY_RESTORE_SETTINGS), SystemSettingsValidators.VALIDATORS);
failIfOffendersPresent(offenders, "Settings.System");
@@ -295,7 +298,7 @@
@Test
public void ensureAllBackedUpGlobalSettingsHaveValidators() {
- String offenders = getOffenders(concat(Settings.Global.SETTINGS_TO_BACKUP,
+ String offenders = getOffenders(concat(GlobalSettings.SETTINGS_TO_BACKUP,
Settings.Global.LEGACY_RESTORE_SETTINGS), GlobalSettingsValidators.VALIDATORS);
failIfOffendersPresent(offenders, "Settings.Global");
@@ -303,7 +306,7 @@
@Test
public void ensureAllBackedUpSecureSettingsHaveValidators() {
- String offenders = getOffenders(concat(Settings.Secure.SETTINGS_TO_BACKUP,
+ String offenders = getOffenders(concat(SecureSettings.SETTINGS_TO_BACKUP,
Settings.Secure.LEGACY_RESTORE_SETTINGS), SecureSettingsValidators.VALIDATORS);
failIfOffendersPresent(offenders, "Settings.Secure");