Tear down agent after preflight rejection

We were failing to tear down a full-backup target process in several
error situations (preflight, quota exceeded, unforeseen), leaving the
app in an incoherent execution state for general operation.  Now we
properly tear down the target in all full-backup early exits.

Fix #63540605
Test: run cts -m CtsBackupTestCases -t android.backup.cts.BackupQuotaTest

Change-Id: Id8f6fe0381e85a8d8e4015fc6fd34bb840859e7a
This commit is contained in:
Christopher Tate
2017-07-10 16:19:41 -07:00
parent 150fec445a
commit e989348ca3

View File

@@ -4871,6 +4871,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
final int N = mPackages.size();
final byte[] buffer = new byte[8192];
for (int i = 0; i < N; i++) {
mBackupRunner = null;
PackageInfo currentPackage = mPackages.get(i);
String packageName = currentPackage.packageName;
if (DEBUG) {
@@ -5054,7 +5055,13 @@ public class BackupManagerService implements BackupManagerServiceInterface {
}
EventLog.writeEvent(EventLogTags.FULL_BACKUP_AGENT_FAILURE, packageName,
"transport rejected");
// Do nothing, clean up, and continue looping.
// This failure state can come either a-priori from the transport, or
// from the preflight pass. If we got as far as preflight, we now need
// to tear down the target process.
if (mBackupRunner != null) {
tearDownAgentAndKill(currentPackage.applicationInfo);
}
// ... and continue looping.
} else if (backupPackageStatus == BackupTransport.TRANSPORT_QUOTA_EXCEEDED) {
sendBackupOnPackageResult(mBackupObserver, packageName,
BackupManager.ERROR_TRANSPORT_QUOTA_EXCEEDED);
@@ -5063,6 +5070,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
EventLog.writeEvent(EventLogTags.FULL_BACKUP_QUOTA_EXCEEDED,
packageName);
}
tearDownAgentAndKill(currentPackage.applicationInfo);
// Do nothing, clean up, and continue looping.
} else if (backupPackageStatus == BackupTransport.AGENT_ERROR) {
sendBackupOnPackageResult(mBackupObserver, packageName,
@@ -5086,6 +5094,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
EventLog.writeEvent(EventLogTags.FULL_BACKUP_TRANSPORT_FAILURE);
// Abort entire backup pass.
backupRunStatus = BackupManager.ERROR_TRANSPORT_ABORTED;
tearDownAgentAndKill(currentPackage.applicationInfo);
return;
} else {
// Success!