Skip to content

Commit bf1a4a8

Browse files
Christopher TateChristopher Tate
authored andcommitted
Start using cancelFullBackup() when appropriate
The API was in place but the framework wasn't yet calling it. Bug 16524520 Change-Id: Ie368758c830a7d0ad11e7dd3142a0ed896069944
1 parent 7f708ec commit bf1a4a8

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

core/java/android/app/backup/BackupTransport.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,11 @@ public int sendBackupData(int numBytes) throws RemoteException {
589589
return BackupTransport.this.sendBackupData(numBytes);
590590
}
591591

592+
@Override
593+
public void cancelFullBackup() throws RemoteException {
594+
BackupTransport.this.cancelFullBackup();
595+
}
596+
592597
@Override
593598
public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) {
594599
return BackupTransport.this.getNextFullRestoreDataChunk(socket);

core/java/com/android/internal/backup/IBackupTransport.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ interface IBackupTransport {
239239
long requestFullBackupTime();
240240
int performFullBackup(in PackageInfo targetPackage, in ParcelFileDescriptor socket);
241241
int sendBackupData(int numBytes);
242+
void cancelFullBackup();
242243

243244
// full restore stuff
244245

services/backup/java/com/android/server/backup/BackupManagerService.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3745,28 +3745,25 @@ public void run() {
37453745
}
37463746
} while (nRead > 0 && result == BackupTransport.TRANSPORT_OK);
37473747

3748-
int finishResult;
3749-
3748+
// If we've lost our running criteria, tell the transport to cancel
3749+
// and roll back this (partial) backup payload; otherwise tell it
3750+
// that we've reached the clean finish state.
37503751
if (!mKeepRunning.get()) {
37513752
result = BackupTransport.TRANSPORT_ERROR;
3752-
// TODO: tell the transport to abort the backup
3753-
Slog.w(TAG, "TODO: tell transport to halt & roll back");
3753+
transport.cancelFullBackup();
3754+
} else {
3755+
// If we were otherwise in a good state, now interpret the final
3756+
// result based on what finishBackup() returns. If we're in a
3757+
// failure case already, preserve that result and ignore whatever
3758+
// finishBackup() reports.
3759+
final int finishResult = transport.finishBackup();
3760+
if (result == BackupTransport.TRANSPORT_OK) {
3761+
result = finishResult;
3762+
}
37543763
}
37553764

3756-
// In all cases we need to give the transport its finish callback
3757-
finishResult = transport.finishBackup();
3758-
37593765
if (MORE_DEBUG) {
3760-
Slog.i(TAG, "Done trying to send backup data: result="
3761-
+ result + " finishResult=" + finishResult);
3762-
}
3763-
3764-
// If we were otherwise in a good state, now interpret the final
3765-
// result based on what finishBackup() returned. If we're in a
3766-
// failure case already, preserve that result and ignore whatever
3767-
// finishBackup() reported.
3768-
if (result == BackupTransport.TRANSPORT_OK) {
3769-
result = finishResult;
3766+
Slog.i(TAG, "Done trying to send backup data: result=" + result);
37703767
}
37713768

37723769
if (result != BackupTransport.TRANSPORT_OK) {

0 commit comments

Comments
 (0)