summaryrefslogtreecommitdiffstats
path: root/services/backup
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2015-02-24 17:27:09 -0800
committerChristopher Tate <ctate@google.com>2015-02-24 17:37:54 -0800
commit12f783d6c6155a65a87511e200206a81798aa2ed (patch)
tree779829159d8924ecceb5632444860dcc35f14c8a /services/backup
parenta1879609890640bd26639fc3ce1fa482efd17e8d (diff)
downloadframeworks_base-12f783d6c6155a65a87511e200206a81798aa2ed.zip
frameworks_base-12f783d6c6155a65a87511e200206a81798aa2ed.tar.gz
frameworks_base-12f783d6c6155a65a87511e200206a81798aa2ed.tar.bz2
Don't crash when backup timeout races with agent completion
There's a narrow window of time in which an agent reporting that its operation has completed races with timeouts such that we wind up handling the completion callback just after certain fundamental state has been reset. Detect this race and proceed gracefully instead of crashing. Bug 19498669 Change-Id: I5a475527db1a55a8e567366ddfb10112e427682e
Diffstat (limited to 'services/backup')
-rw-r--r--services/backup/java/com/android/server/backup/BackupManagerService.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index 4d7ebed..acf4d39 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -2778,7 +2778,22 @@ public class BackupManagerService {
@Override
public void operationComplete() {
- // Okay, the agent successfully reported back to us!
+ // The agent reported back to us!
+
+ if (mBackupData == null) {
+ // This callback was racing with our timeout, so we've cleaned up the
+ // agent state already and are on to the next thing. We have nothing
+ // further to do here: agent state having been cleared means that we've
+ // initiated the appropriate next operation.
+ final String pkg = (mCurrentPackage != null)
+ ? mCurrentPackage.packageName : "[none]";
+ if (DEBUG) {
+ Slog.i(TAG, "Callback after agent teardown: " + pkg);
+ }
+ addBackupTrace("late opComplete; curPkg = " + pkg);
+ return;
+ }
+
final String pkgName = mCurrentPackage.packageName;
final long filepos = mBackupDataName.length();
FileDescriptor fd = mBackupData.getFileDescriptor();