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

Commit 6fb2bb1b authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov
Browse files

Guard the preserve settings logic in SettingsBackupAgent with a flag

The flag will guard the feature in R and can be removed in the next
release.

Bug: 144838882
Test: atest SettingsBackupAgentTest
Change-Id: I259a3f41304c40d8aac5ab5e4d24ae1027914b56
parent ada833f4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ public class FeatureFlagUtils {
    /** @hide */
    public static final String BACKUP_NO_KV_DATA_CHANGE_CALLS =
            "backup_enable_no_data_notification_calls";
    /** @hide */
    public static final String SETTINGS_DO_NOT_RESTORE_PRESERVED =
            "settings_do_not_restore_preserved";

    private static final Map<String, String> DEFAULT_FLAGS;

@@ -68,6 +71,9 @@ public class FeatureFlagUtils {

        // Disabled until backup transports support it.
        DEFAULT_FLAGS.put(BACKUP_NO_KV_DATA_CHANGE_CALLS, "false");
        // Disabled by default until b/148278926 is resolved. This flags guards a feature
        // introduced in R and will be removed in the next release (b/148367230).
        DEFAULT_FLAGS.put(SETTINGS_DO_NOT_RESTORE_PRESERVED, "false");
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.provider.settings.validators.Validator;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.BackupUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Slog;
import android.view.Display;
@@ -625,6 +626,11 @@ public class SettingsBackupAgent extends BackupAgentHelper {
     * Get names of the settings for which the current value should be preserved during restore.
     */
    private Set<String> getSettingsToPreserveInRestore(Uri settingsUri) {
        if (!FeatureFlagUtils.isEnabled(getApplicationContext(),
                FeatureFlagUtils.SETTINGS_DO_NOT_RESTORE_PRESERVED)) {
            return Collections.emptySet();
        }

        Cursor cursor = getContentResolver().query(settingsUri, new String[] {
                Settings.NameValueTable.NAME, Settings.NameValueTable.IS_PRESERVED_IN_RESTORE },
                /* selection */ null, /* selectionArgs */ null, /* sortOrder */ null);