Retrieve BackupAgent logs after onRestoreFinished completes execution

This fixes a race condition that was introduced in ag/20312251. The logs
were requested right after doRestoreFinished was called. But because
that method is async, this resulted in a timeout while waiting to
retrieve logs if the BackupAgent took longer than 500ms to execute
onRestoreFinished-- which WallpaperBackupAgent will almost always do (it
sets the restored wallpapers in that method).

Bug: 282013010
Test: this class is not unit testable. Tested manually by adding debug
logs and doing a restore. Observed that the wallpaper restore took
longer than 500ms and there was no timeout. The logs were successfully
retrieved after the restore was finished.

Change-Id: I697e1279b9e366da15a6e31a9730e91a8b3d0d0b
This commit is contained in:
Sarp Misoglu
2023-05-11 19:27:23 +01:00
parent ff9c6d9638
commit 2865eb7b21

View File

@@ -900,9 +900,6 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
mAgent.doRestoreFinished(mEphemeralOpToken,
backupManagerService.getBackupManagerBinder());
// Ask the agent for logs after doRestoreFinished() to allow it to finalize its logs.
BackupManagerMonitorUtils.monitorAgentLoggingResults(mMonitor, mCurrentPackage, mAgent);
// If we get this far, the callback or timeout will schedule the
// next restore state, so we're done
} catch (Exception e) {
@@ -1323,6 +1320,11 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
EventLog.writeEvent(EventLogTags.RESTORE_PACKAGE,
mCurrentPackage.packageName, size);
// Ask the agent for logs after doRestoreFinished() has completed executing to allow
// it to finalize its logs.
BackupManagerMonitorUtils.monitorAgentLoggingResults(mMonitor, mCurrentPackage,
mAgent);
// Just go back to running the restore queue
keyValueAgentCleanup();