Skip to content

Commit e659fb9

Browse files
author
Christopher Tate
committed
Gracefully handle "needs init" transport errors at finish
Although it's typical for a backup transport to report that it needs an explicit initialization opportunity when the backup is initiated, it can sometimes come to pass that the "needs init" error condition is reported at backup *finish*. In this case the framework side was failing to properly reset all of the relevant state. The end result was to spin hard forever, holding wakelocks and continually failing to actually perform the necessary init operation, possibly continuing even after a reboot. Fixed. Bug 5434579 Change-Id: If1d72c338526e4019ea524c48a11e71e44e77f71
1 parent e47b89c commit e659fb9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,9 @@ void finalizeBackup() {
19661966
synchronized (mQueueLock) {
19671967
mBackupRunning = false;
19681968
if (mStatus == BackupConstants.TRANSPORT_NOT_INITIALIZED) {
1969+
// Make sure we back up everything and perform the one-time init
1970+
clearMetadata();
1971+
if (DEBUG) Slog.d(TAG, "Server requires init; rerunning");
19691972
backupNow();
19701973
}
19711974
}
@@ -1975,6 +1978,12 @@ void finalizeBackup() {
19751978
mWakelock.release();
19761979
}
19771980

1981+
// Remove the PM metadata state. This will generate an init on the next pass.
1982+
void clearMetadata() {
1983+
final File pmState = new File(mStateDir, PACKAGE_MANAGER_SENTINEL);
1984+
if (pmState.exists()) pmState.delete();
1985+
}
1986+
19781987
// Invoke an agent's doBackup() and start a timeout message spinning on the main
19791988
// handler in case it doesn't get back to us.
19801989
int invokeAgentForBackup(String packageName, IBackupAgent agent,

0 commit comments

Comments
 (0)