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

Commit b56fc740 authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov Committed by Android (Google) Code Review
Browse files

Merge "Update D2D logic in line with new opt-out rules" into sc-dev

parents 7df4e1c5 75ee2bf7
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -564,10 +564,6 @@ public abstract class BackupAgent extends ContextWrapper {
    @VisibleForTesting
    public IncludeExcludeRules getIncludeExcludeRules(FullBackup.BackupScheme backupScheme)
            throws IOException, XmlPullParserException {
        if (isDeviceToDeviceMigration()) {
            return IncludeExcludeRules.emptyRules();
        }

        Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap;
        ArraySet<PathWithRequiredFlags> manifestExcludeSet;

+16 −1
Original line number Diff line number Diff line
@@ -20,11 +20,15 @@ import static android.app.backup.BackupManager.OperationType;

import android.annotation.Nullable;
import android.annotation.StringDef;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.XmlResourceParser;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.storage.StorageManager;
@@ -96,6 +100,14 @@ public class FullBackup {
    public static final String FLAG_REQUIRED_FAKE_CLIENT_SIDE_ENCRYPTION =
            "fakeClientSideEncryption";

    /**
     * When  this change is enabled, include / exclude rules specified via
     * {@code android:fullBackupContent} are ignored during D2D transfers.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
    private static final long IGNORE_FULL_BACKUP_CONTENT_IN_D2D = 180523564L;

    @StringDef({
        ConfigSection.CLOUD_BACKUP,
        ConfigSection.DEVICE_TRANSFER
@@ -527,7 +539,10 @@ public class FullBackup {
                }
            }

            // TODO(b/180523564): Ignore the old config for apps targeting Android S+ during D2D.
            if (operationType == OperationType.MIGRATION
                    && CompatChanges.isChangeEnabled(IGNORE_FULL_BACKUP_CONTENT_IN_D2D)) {
                return;
            }

            if (mFullBackupContent != 0) {
                // Fall back to the old config.
+0 −8
Original line number Diff line number Diff line
@@ -56,14 +56,6 @@ public class BackupAgentTest {
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void testGetIncludeExcludeRules_isMigration_returnsEmptyRules()  throws Exception {
        mBackupAgent = getAgentForOperationType(OperationType.MIGRATION);

        IncludeExcludeRules rules = mBackupAgent.getIncludeExcludeRules(mBackupScheme);
        assertThat(rules).isEqualTo(IncludeExcludeRules.emptyRules());
    }

    @Test
    public void testGetIncludeExcludeRules_isNotMigration_returnsRules() throws Exception {
        PathWithRequiredFlags path = new PathWithRequiredFlags("path", /* requiredFlags */ 0);
+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ public class LocalTransport extends BackupTransport {
        if (mParameters.isFakeEncryptionFlag()) {
            flags |= BackupAgent.FLAG_FAKE_CLIENT_SIDE_ENCRYPTION_ENABLED;
        }
        if (mParameters.isDeviceTransfer()) {
            flags |= BackupAgent.FLAG_DEVICE_TO_DEVICE_TRANSFER;
        }
        return flags;
    }