summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java170
-rw-r--r--packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java120
-rw-r--r--services/core/java/com/android/server/display/mode/DisplayModeDirector.java18
3 files changed, 171 insertions, 137 deletions
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
index 59c3cd38a97d..e7d7bb01e180 100644
--- a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java
@@ -19,93 +19,105 @@ package android.provider.settings.backup;
import android.compat.annotation.UnsupportedAppUsage;
import android.provider.Settings;
+import com.android.server.display.feature.flags.Flags;
+
+import java.util.ArrayList;
+import java.util.List;
+
/** Information about the system settings to back up */
public class SystemSettings {
/**
- * Settings to backup.
+ * Settings to back 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.
*/
@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.ADAPTIVE_SLEEP, // moved to secure
- Settings.System.APPLY_RAMPING_RINGER,
- 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.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.FOLD_LOCK_BEHAVIOR,
- 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_ON,
- 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.ALARM_VIBRATION_INTENSITY,
- Settings.System.MEDIA_VIBRATION_INTENSITY,
- Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
- Settings.System.RING_VIBRATION_INTENSITY,
- Settings.System.HAPTIC_FEEDBACK_INTENSITY,
- Settings.System.HARDWARE_HAPTIC_FEEDBACK_INTENSITY,
- Settings.System.KEYBOARD_VIBRATION_ENABLED,
- Settings.System.HAPTIC_FEEDBACK_ENABLED,
- Settings.System.DISPLAY_COLOR_MODE_VENDOR_HINT, // must precede DISPLAY_COLOR_MODE
- Settings.System.DISPLAY_COLOR_MODE,
- Settings.System.ALARM_ALERT,
- Settings.System.NOTIFICATION_LIGHT_PULSE,
- Settings.System.WEAR_ACCESSIBILITY_GESTURE_ENABLED,
- Settings.System.CLOCKWORK_BLUETOOTH_SETTINGS_PREF,
- Settings.System.UNREAD_NOTIFICATION_DOT_INDICATOR,
- Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS,
- Settings.System.LOCALE_PREFERENCES,
- Settings.System.TOUCHPAD_POINTER_SPEED,
- Settings.System.TOUCHPAD_NATURAL_SCROLLING,
- Settings.System.TOUCHPAD_TAP_TO_CLICK,
- Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE,
- Settings.System.CAMERA_FLASH_NOTIFICATION,
- Settings.System.SCREEN_FLASH_NOTIFICATION,
- Settings.System.SCREEN_FLASH_NOTIFICATION_COLOR,
- Settings.System.PEAK_REFRESH_RATE,
- Settings.System.MIN_REFRESH_RATE,
- Settings.System.NOTIFICATION_COOLDOWN_ENABLED,
- Settings.System.NOTIFICATION_COOLDOWN_ALL,
- Settings.System.NOTIFICATION_COOLDOWN_VIBRATE_UNLOCKED,
- };
+ public static final String[] SETTINGS_TO_BACKUP = getSettingsToBackUp();
+
+ private static String[] getSettingsToBackUp() {
+ List<String> settings = new ArrayList<>(List.of(
+ 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.ADAPTIVE_SLEEP, // moved to secure
+ Settings.System.APPLY_RAMPING_RINGER,
+ 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.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.FOLD_LOCK_BEHAVIOR,
+ 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_ON,
+ 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.ALARM_VIBRATION_INTENSITY,
+ Settings.System.MEDIA_VIBRATION_INTENSITY,
+ Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+ Settings.System.RING_VIBRATION_INTENSITY,
+ Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+ Settings.System.HARDWARE_HAPTIC_FEEDBACK_INTENSITY,
+ Settings.System.KEYBOARD_VIBRATION_ENABLED,
+ Settings.System.HAPTIC_FEEDBACK_ENABLED,
+ Settings.System.DISPLAY_COLOR_MODE_VENDOR_HINT, // must precede DISPLAY_COLOR_MODE
+ Settings.System.DISPLAY_COLOR_MODE,
+ Settings.System.ALARM_ALERT,
+ Settings.System.NOTIFICATION_LIGHT_PULSE,
+ Settings.System.WEAR_ACCESSIBILITY_GESTURE_ENABLED,
+ Settings.System.CLOCKWORK_BLUETOOTH_SETTINGS_PREF,
+ Settings.System.UNREAD_NOTIFICATION_DOT_INDICATOR,
+ Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS,
+ Settings.System.LOCALE_PREFERENCES,
+ Settings.System.TOUCHPAD_POINTER_SPEED,
+ Settings.System.TOUCHPAD_NATURAL_SCROLLING,
+ Settings.System.TOUCHPAD_TAP_TO_CLICK,
+ Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE,
+ Settings.System.CAMERA_FLASH_NOTIFICATION,
+ Settings.System.SCREEN_FLASH_NOTIFICATION,
+ Settings.System.SCREEN_FLASH_NOTIFICATION_COLOR,
+ Settings.System.NOTIFICATION_COOLDOWN_ENABLED,
+ Settings.System.NOTIFICATION_COOLDOWN_ALL,
+ Settings.System.NOTIFICATION_COOLDOWN_VIBRATE_UNLOCKED
+ ));
+ if (Flags.backUpSmoothDisplayAndForcePeakRefreshRate()) {
+ settings.add(Settings.System.PEAK_REFRESH_RATE);
+ settings.add(Settings.System.MIN_REFRESH_RATE);
+ }
+ return settings.toArray(new String[0]);
+ }
}
diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
index 6ad10cc8cc5b..5826daf0191a 100644
--- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
@@ -33,6 +33,8 @@ import android.provider.settings.backup.SystemSettings;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import com.android.server.display.feature.flags.Flags;
+
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -53,59 +55,6 @@ public class SettingsBackupTest {
public static final String HYBRID_SYSUI_BATTERY_WARNING_FLAGS =
"hybrid_sysui_battery_warning_flags";
- /**
- * The following denylists contain settings that should *not* be backed up and restored to
- * another device. As a general rule, anything that is not user configurable should be
- * denied (and conversely, things that *are* user configurable *should* be backed up)
- */
- private static final Set<String> BACKUP_DENY_LIST_SYSTEM_SETTINGS =
- newHashSet(
- Settings.System.ADVANCED_SETTINGS, // candidate for backup?
- Settings.System.ALARM_ALERT_CACHE, // internal cache
- Settings.System.APPEND_FOR_LAST_AUDIBLE, // suffix deprecated since API 2
- Settings.System.EGG_MODE, // I am the lolrus
- Settings.System.END_BUTTON_BEHAVIOR, // bug?
- Settings.System
- .HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, // candidate for backup?
- Settings.System.LOCKSCREEN_DISABLED, // ?
- Settings.System.MEDIA_BUTTON_RECEIVER, // candidate for backup?
- Settings.System.MUTE_STREAMS_AFFECTED, // candidate for backup?
- Settings.System.NOTIFICATION_SOUND_CACHE, // internal cache
- Settings.System.POINTER_LOCATION, // backup candidate?
- Settings.System.DEBUG_ENABLE_ENHANCED_CALL_BLOCKING, // used for testing only
- Settings.System.RINGTONE_CACHE, // internal cache
- Settings.System.SCREEN_BRIGHTNESS, // removed in P
- Settings.System.SETUP_WIZARD_HAS_RUN, // Only used by SuW
- Settings.System.SHOW_GTALK_SERVICE_STATUS, // candidate for backup?
- Settings.System.SHOW_TOUCHES,
- Settings.System.SHOW_KEY_PRESSES,
- Settings.System.SHOW_ROTARY_INPUT,
- Settings.System.SIP_ADDRESS_ONLY, // value, not a setting
- Settings.System.SIP_ALWAYS, // value, not a setting
- Settings.System.SYSTEM_LOCALES, // bug?
- Settings.System.USER_ROTATION, // backup candidate?
- Settings.System.VIBRATE_IN_SILENT, // deprecated?
- Settings.System.VOLUME_ACCESSIBILITY, // used internally, changing value will
- // not change volume
- Settings.System.VOLUME_ALARM, // deprecated since API 2?
- Settings.System.VOLUME_ASSISTANT, // candidate for backup?
- Settings.System.VOLUME_BLUETOOTH_SCO, // deprecated since API 2?
- Settings.System.VOLUME_MASTER, // candidate for backup?
- Settings.System.VOLUME_MUSIC, // deprecated since API 2?
- Settings.System.VOLUME_NOTIFICATION, // deprecated since API 2?
- Settings.System.VOLUME_RING, // deprecated since API 2?
- Settings.System.VOLUME_SYSTEM, // deprecated since API 2?
- Settings.System.VOLUME_VOICE, // deprecated since API 2?
- Settings.System.WHEN_TO_MAKE_WIFI_CALLS, // bug?
- Settings.System.WINDOW_ORIENTATION_LISTENER_LOG, // used for debugging only
- Settings.System.SCREEN_BRIGHTNESS_FLOAT,
- Settings.System.SCREEN_BRIGHTNESS_FOR_ALS,
- Settings.System.WEAR_ACCESSIBILITY_GESTURE_ENABLED_DURING_OOBE,
- Settings.System.WEAR_TTS_PREWARM_ENABLED,
- Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ,
- Settings.System.MULTI_AUDIO_FOCUS_ENABLED // form-factor/OEM specific
- );
-
private static final Set<String> BACKUP_DENY_LIST_GLOBAL_SETTINGS =
newHashSet(
Settings.Global.ACTIVITY_MANAGER_CONSTANTS,
@@ -862,7 +811,7 @@ public class SettingsBackupTest {
checkSettingsBackedUpOrDenied(
getCandidateSettings(Settings.System.class),
newHashSet(SystemSettings.SETTINGS_TO_BACKUP),
- BACKUP_DENY_LIST_SYSTEM_SETTINGS);
+ getBackUpDenyListSystemSettings());
}
@Test
@@ -937,6 +886,69 @@ public class SettingsBackupTest {
checkSettingsBackedUpOrDenied(allSettings, keys, BACKUP_DENY_LIST_SECURE_SETTINGS);
}
+ /**
+ * The following denylists contain settings that should *not* be backed up and restored to
+ * another device. As a general rule, anything that is not user configurable should be
+ * denied (and conversely, things that *are* user configurable *should* be backed up)
+ */
+ private static Set<String> getBackUpDenyListSystemSettings() {
+ Set<String> settings =
+ newHashSet(
+ Settings.System.ADVANCED_SETTINGS, // candidate for backup?
+ Settings.System.ALARM_ALERT_CACHE, // internal cache
+ Settings.System.APPEND_FOR_LAST_AUDIBLE, // suffix deprecated since API 2
+ Settings.System.EGG_MODE, // I am the lolrus
+ Settings.System.END_BUTTON_BEHAVIOR, // bug?
+ Settings.System
+ .HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY,
+ // candidate for backup?
+ Settings.System.LOCKSCREEN_DISABLED, // ?
+ Settings.System.MEDIA_BUTTON_RECEIVER, // candidate for backup?
+ Settings.System.MUTE_STREAMS_AFFECTED, // candidate for backup?
+ Settings.System.NOTIFICATION_SOUND_CACHE, // internal cache
+ Settings.System.POINTER_LOCATION, // backup candidate?
+ Settings.System.DEBUG_ENABLE_ENHANCED_CALL_BLOCKING,
+ // used for testing only
+ Settings.System.RINGTONE_CACHE, // internal cache
+ Settings.System.SCREEN_BRIGHTNESS, // removed in P
+ Settings.System.SETUP_WIZARD_HAS_RUN, // Only used by SuW
+ Settings.System.SHOW_GTALK_SERVICE_STATUS, // candidate for backup?
+ Settings.System.SHOW_TOUCHES,
+ Settings.System.SHOW_KEY_PRESSES,
+ Settings.System.SHOW_ROTARY_INPUT,
+ Settings.System.SIP_ADDRESS_ONLY, // value, not a setting
+ Settings.System.SIP_ALWAYS, // value, not a setting
+ Settings.System.SYSTEM_LOCALES, // bug?
+ Settings.System.USER_ROTATION, // backup candidate?
+ Settings.System.VIBRATE_IN_SILENT, // deprecated?
+ Settings.System.VOLUME_ACCESSIBILITY,
+ // used internally, changing value will
+ // not change volume
+ Settings.System.VOLUME_ALARM, // deprecated since API 2?
+ Settings.System.VOLUME_ASSISTANT, // candidate for backup?
+ Settings.System.VOLUME_BLUETOOTH_SCO, // deprecated since API 2?
+ Settings.System.VOLUME_MASTER, // candidate for backup?
+ Settings.System.VOLUME_MUSIC, // deprecated since API 2?
+ Settings.System.VOLUME_NOTIFICATION, // deprecated since API 2?
+ Settings.System.VOLUME_RING, // deprecated since API 2?
+ Settings.System.VOLUME_SYSTEM, // deprecated since API 2?
+ Settings.System.VOLUME_VOICE, // deprecated since API 2?
+ Settings.System.WHEN_TO_MAKE_WIFI_CALLS, // bug?
+ Settings.System.WINDOW_ORIENTATION_LISTENER_LOG, // used for debugging only
+ Settings.System.SCREEN_BRIGHTNESS_FLOAT,
+ Settings.System.SCREEN_BRIGHTNESS_FOR_ALS,
+ Settings.System.WEAR_ACCESSIBILITY_GESTURE_ENABLED_DURING_OOBE,
+ Settings.System.WEAR_TTS_PREWARM_ENABLED,
+ Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ,
+ Settings.System.MULTI_AUDIO_FOCUS_ENABLED // form-factor/OEM specific
+ );
+ if (!Flags.backUpSmoothDisplayAndForcePeakRefreshRate()) {
+ settings.add(Settings.System.MIN_REFRESH_RATE);
+ settings.add(Settings.System.PEAK_REFRESH_RATE);
+ }
+ return settings;
+ }
+
private static void checkSettingsBackedUpOrDenied(
Set<String> settings, Set<String> settingsToBackup, Set<String> denylist) {
Set<String> settingsNotBackedUp = difference(settings, settingsToBackup);
diff --git a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
index 6e503cbd68f3..030585f35983 100644
--- a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
+++ b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
@@ -970,9 +970,14 @@ public class DisplayModeDirector {
if (!mIsBackUpSmoothDisplayAndForcePeakRefreshRateEnabled) {
// The flag had been turned off, we need to restore the original value
- Settings.System.putFloatForUser(cr,
- Settings.System.MIN_REFRESH_RATE, minRefreshRate, cr.getUserId());
+ Settings.System.putFloatForUser(cr, Settings.System.MIN_REFRESH_RATE,
+ highestRefreshRate, cr.getUserId());
}
+ } else if (mIsBackUpSmoothDisplayAndForcePeakRefreshRateEnabled
+ && Math.round(minRefreshRate) == Math.round(highestRefreshRate)) {
+ // The flag has been turned on, we need to upgrade the setting
+ Settings.System.putFloatForUser(cr, Settings.System.MIN_REFRESH_RATE,
+ Float.POSITIVE_INFINITY, cr.getUserId());
}
float peakRefreshRate = Settings.System.getFloatForUser(cr,
@@ -983,9 +988,14 @@ public class DisplayModeDirector {
if (!mIsBackUpSmoothDisplayAndForcePeakRefreshRateEnabled) {
// The flag had been turned off, we need to restore the original value
- Settings.System.putFloatForUser(cr,
- Settings.System.PEAK_REFRESH_RATE, peakRefreshRate, cr.getUserId());
+ Settings.System.putFloatForUser(cr, Settings.System.PEAK_REFRESH_RATE,
+ highestRefreshRate, cr.getUserId());
}
+ } else if (mIsBackUpSmoothDisplayAndForcePeakRefreshRateEnabled
+ && Math.round(peakRefreshRate) == Math.round(highestRefreshRate)) {
+ // The flag has been turned on, we need to upgrade the setting
+ Settings.System.putFloatForUser(cr, Settings.System.PEAK_REFRESH_RATE,
+ Float.POSITIVE_INFINITY, cr.getUserId());
}
updateRefreshRateSettingLocked(minRefreshRate, peakRefreshRate, mDefaultRefreshRate);