summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Tate <ctate@android.com>2009-09-22 11:14:17 -0700
committerChristopher Tate <ctate@android.com>2009-09-22 14:14:10 -0700
commitb03b3bbd6833f7c6fbd8100fa3958220554f66a3 (patch)
treeda0245d74935b77acba5c2b914a7c2cd4f1679b8
parent36dac6ae8e005f0247e44345727d1580b1623127 (diff)
downloadframeworks_base-b03b3bbd6833f7c6fbd8100fa3958220554f66a3.zip
frameworks_base-b03b3bbd6833f7c6fbd8100fa3958220554f66a3.tar.gz
frameworks_base-b03b3bbd6833f7c6fbd8100fa3958220554f66a3.tar.bz2
If backup fails, reenqueue all of the affected packages for next time.
-rw-r--r--services/java/com/android/server/BackupManagerService.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 0f1c00f..2fa18bf 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -912,6 +912,7 @@ class BackupManagerService extends IBackupManager.Stub {
@Override
public void run() {
+ int status = BackupConstants.TRANSPORT_OK;
long startRealtime = SystemClock.elapsedRealtime();
if (DEBUG) Log.v(TAG, "Beginning backup of " + mQueue.size() + " targets");
@@ -920,7 +921,6 @@ class BackupManagerService extends IBackupManager.Stub {
try {
EventLog.writeEvent(BACKUP_START_EVENT, mTransport.transportDirName());
- int status = BackupConstants.TRANSPORT_OK;
// If we haven't stored anything yet, we need to do an init operation.
if (status == BackupConstants.TRANSPORT_OK && mEverStoredApps.size() == 0) {
@@ -958,11 +958,6 @@ class BackupManagerService extends IBackupManager.Stub {
}
}
- // When we succeed at everything, we can remove the journal
- if (status == BackupConstants.TRANSPORT_OK && !mJournal.delete()) {
- Log.e(TAG, "Unable to remove backup journal file " + mJournal);
- }
-
if (status == BackupConstants.TRANSPORT_NOT_INITIALIZED) {
// The backend reports that our dataset has been wiped. We need to
// reset all of our bookkeeping and instead run a new backup pass for
@@ -973,7 +968,31 @@ class BackupManagerService extends IBackupManager.Stub {
}
} catch (Exception e) {
Log.e(TAG, "Error in backup thread", e);
+ status = BackupConstants.TRANSPORT_ERROR;
} finally {
+ // If things went wrong, we need to re-stage the apps we had expected
+ // to be backing up in this pass. This journals the package names in
+ // the current active pending-backup file, not in the we are holding
+ // here in mJournal.
+ if (status != BackupConstants.TRANSPORT_OK) {
+ Log.w(TAG, "Backup pass unsuccessful, restaging");
+ for (BackupRequest req : mQueue) {
+ try {
+ dataChanged(req.appInfo.packageName);
+ } catch (RemoteException e) {
+ // can't happen; it's a local call
+ }
+ }
+ }
+
+ // Either backup was successful, in which case we of course do not need
+ // this pass's journal any more; or it failed, in which case we just
+ // re-enqueued all of these packages in the current active journal.
+ // Either way, we no longer need this pass's journal.
+ if (!mJournal.delete()) {
+ Log.e(TAG, "Unable to remove backup journal file " + mJournal);
+ }
+
// Only once we're entirely finished do we release the wakelock
mWakelock.release();
}