Eliminate a race condition that could lead to calling PBT#finalizeBackup() twice

Calling finalizeBackup() the second time will most probably lead to underholding
the wakelock and system crash.

Bug: 63156509
Test: manual
Change-Id: Ic995ba4a65d749b80bf1f1d226d35a279a0d1b25
This commit is contained in:
Michal Karpinski
2017-07-07 15:30:50 +01:00
parent cf694adee3
commit 015df962d5

View File

@@ -2822,11 +2822,11 @@ public class BackupManagerService implements BackupManagerServiceInterface {
break;
case FINAL:
if (!mFinished) finalizeBackup();
else {
Slog.e(TAG, "Duplicate finish");
if (!mFinished) {
finalizeBackup();
} else {
Slog.e(TAG, "Duplicate finish of K/V pass");
}
mFinished = true;
break;
}
}
@@ -3180,6 +3180,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
break;
}
}
mFinished = true;
Slog.i(BackupManagerService.TAG, "K/V backup pass finished.");
// Only once we're entirely finished do we release the wakelock for k/v backup.
mWakelock.release();