Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaf216e8 authored by XingHaiLu's avatar XingHaiLu Committed by XingHai Lu
Browse files

Add Settings.Secure.NAVIGATION_MODE_RESTORE

During restore get NAVIGATION_MODE value and write it to NAVIGATION_MODE_RESTORE.
This value is used for improving setup experience.
Bug: 244532342
Test: manual
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:918a57109c926328a717e90418ae5ac5dbb5f683)
Merged-In: I12b182184e1d381e14c7b290fd5f357026990c78
Change-Id: I12b182184e1d381e14c7b290fd5f357026990c78
parent 657e69c9
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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,
+22 −1
Original line number Diff line number Diff line
@@ -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);

+2 −1
Original line number Diff line number Diff line
@@ -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() {