Merge "Add Settings.Secure.NAVIGATION_MODE_RESTORE" into udc-qpr-dev

This commit is contained in:
XingHai Lu
2023-08-16 23:00:32 +00:00
committed by Android (Google) Code Review
4 changed files with 39 additions and 2 deletions

View File

@@ -11113,6 +11113,19 @@ public final class Settings {
public static final String NAVIGATION_MODE =
"navigation_mode";
/**
* The value is from another(source) device's {@link #NAVIGATION_MODE} during restore.
* It's supposed to be written only by
* {@link com.android.providers.settings.SettingsHelper}.
* This setting should not be added into backup array.
* <p>Value: -1 = Can't get value from restore(default),
* 0 = 3 button,
* 1 = 2 button,
* 2 = fully gestural.
* @hide
*/
public static final String NAVIGATION_MODE_RESTORE = "navigation_mode_restore";
/**
* Scale factor for the back gesture inset size on the left side of the screen.
* @hide

View File

@@ -259,6 +259,8 @@ public class SecureSettingsValidators {
VALIDATORS.put(Secure.NAV_BAR_KIDS_MODE, BOOLEAN_VALIDATOR);
VALIDATORS.put(
Secure.NAVIGATION_MODE, new DiscreteValueValidator(new String[] {"0", "1", "2"}));
VALIDATORS.put(Secure.NAVIGATION_MODE_RESTORE,
new DiscreteValueValidator(new String[] {"-1", "0", "1", "2"}));
VALIDATORS.put(Secure.BACK_GESTURE_INSET_SCALE_LEFT,
new InclusiveFloatRangeValidator(0.0f, Float.MAX_VALUE));
VALIDATORS.put(Secure.BACK_GESTURE_INSET_SCALE_RIGHT,

View File

@@ -813,7 +813,11 @@ public class SettingsBackupAgent extends BackupAgentHelper {
continue;
}
if (settingsToPreserve.contains(getQualifiedKeyForSetting(key, contentUri))) {
// Filter out Settings.Secure.NAVIGATION_MODE from modified preserve settings.
// Let it take part in restore process. See also b/244532342.
boolean isSettingPreserved = settingsToPreserve.contains(
getQualifiedKeyForSetting(key, contentUri));
if (isSettingPreserved && !Settings.Secure.NAVIGATION_MODE.equals(key)) {
Log.i(TAG, "Skipping restore for setting " + key + " as it is marked as "
+ "preserved");
continue;
@@ -874,6 +878,23 @@ public class SettingsBackupAgent extends BackupAgentHelper {
} else {
destination = contentUri;
}
// Value is written to NAVIGATION_MODE_RESTORE to mark navigation mode
// has been set before on source device.
// See also: b/244532342.
if (Settings.Secure.NAVIGATION_MODE.equals(key)) {
contentValues.clear();
contentValues.put(Settings.NameValueTable.NAME,
Settings.Secure.NAVIGATION_MODE_RESTORE);
contentValues.put(Settings.NameValueTable.VALUE, value);
cr.insert(destination, contentValues);
// Avoid restore original setting if it has been preserved.
if (isSettingPreserved) {
Log.i(TAG, "Skipping restore for setting navigation_mode "
+ "as it is marked as preserved");
continue;
}
}
settingsHelper.restoreValue(this, cr, contentValues, destination, key, value,
mRestoredFromSdkInt);

View File

@@ -848,7 +848,8 @@ public class SettingsBackupTest {
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT,
Settings.Secure.UI_TRANSLATION_ENABLED,
Settings.Secure.CREDENTIAL_SERVICE,
Settings.Secure.CREDENTIAL_SERVICE_PRIMARY);
Settings.Secure.CREDENTIAL_SERVICE_PRIMARY,
Settings.Secure.NAVIGATION_MODE_RESTORE);
@Test
public void systemSettingsBackedUpOrDenied() {