Merge "Update D2D logic in line with new opt-out rules" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b56fc740bb
@@ -564,10 +564,6 @@ public abstract class BackupAgent extends ContextWrapper {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public IncludeExcludeRules getIncludeExcludeRules(FullBackup.BackupScheme backupScheme)
|
public IncludeExcludeRules getIncludeExcludeRules(FullBackup.BackupScheme backupScheme)
|
||||||
throws IOException, XmlPullParserException {
|
throws IOException, XmlPullParserException {
|
||||||
if (isDeviceToDeviceMigration()) {
|
|
||||||
return IncludeExcludeRules.emptyRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap;
|
Map<String, Set<PathWithRequiredFlags>> manifestIncludeMap;
|
||||||
ArraySet<PathWithRequiredFlags> manifestExcludeSet;
|
ArraySet<PathWithRequiredFlags> manifestExcludeSet;
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,15 @@ import static android.app.backup.BackupManager.OperationType;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.StringDef;
|
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.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.XmlResourceParser;
|
import android.content.res.XmlResourceParser;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
@@ -96,6 +100,14 @@ public class FullBackup {
|
|||||||
public static final String FLAG_REQUIRED_FAKE_CLIENT_SIDE_ENCRYPTION =
|
public static final String FLAG_REQUIRED_FAKE_CLIENT_SIDE_ENCRYPTION =
|
||||||
"fakeClientSideEncryption";
|
"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({
|
@StringDef({
|
||||||
ConfigSection.CLOUD_BACKUP,
|
ConfigSection.CLOUD_BACKUP,
|
||||||
ConfigSection.DEVICE_TRANSFER
|
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) {
|
if (mFullBackupContent != 0) {
|
||||||
// Fall back to the old config.
|
// Fall back to the old config.
|
||||||
|
|||||||
@@ -56,14 +56,6 @@ public class BackupAgentTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
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
|
@Test
|
||||||
public void testGetIncludeExcludeRules_isNotMigration_returnsRules() throws Exception {
|
public void testGetIncludeExcludeRules_isNotMigration_returnsRules() throws Exception {
|
||||||
PathWithRequiredFlags path = new PathWithRequiredFlags("path", /* requiredFlags */ 0);
|
PathWithRequiredFlags path = new PathWithRequiredFlags("path", /* requiredFlags */ 0);
|
||||||
|
|||||||
@@ -162,6 +162,9 @@ public class LocalTransport extends BackupTransport {
|
|||||||
if (mParameters.isFakeEncryptionFlag()) {
|
if (mParameters.isFakeEncryptionFlag()) {
|
||||||
flags |= BackupAgent.FLAG_FAKE_CLIENT_SIDE_ENCRYPTION_ENABLED;
|
flags |= BackupAgent.FLAG_FAKE_CLIENT_SIDE_ENCRYPTION_ENABLED;
|
||||||
}
|
}
|
||||||
|
if (mParameters.isDeviceTransfer()) {
|
||||||
|
flags |= BackupAgent.FLAG_DEVICE_TO_DEVICE_TRANSFER;
|
||||||
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user