From aa74ed121ff2ba0535aa32f2c8159526fbc6a4d7 Mon Sep 17 00:00:00 2001 From: Joël Stemmer Date: Wed, 24 Jan 2024 11:37:04 +0000 Subject: Set `mStatus` when `dispatchNextRestore` encounters a transport error `PerformUnifiedRestoreTask` is a state-machine that is responsible for restoring the backups a given set of packages. At every point in this process it's possible for a transport error to occur. This is treated as a fatal error, immediately moving the state machine into the `FINAL` state. The `mStatus` variable is used to indicate the result in the `RestoreObserver.restoreFinished` callback. A non-zero value for `mStatus` indicates something failed during restore. `dispatchNextRestore` is the only place in this state machine where a transport error does not set `mStatus` to `TRANSPORT_ERROR`, even though the state is set to `FINAL`. As a result, the `RestoreObserver` listener is likely to wrongly assume that the restore succeeded in this particular case. Bug: 283932000 Test: atest services/tests/mockingservicestests/src/com/android/server/backup Test: Manual testing with custom build that returns an error in `dispatchNextRestore`. Change-Id: I769e8200ad4ac12b58dbb8c8181b21ff9933453a --- .../com/android/server/backup/restore/PerformUnifiedRestoreTask.java | 1 + 1 file changed, 1 insertion(+) (limited to 'services/backup/java') diff --git a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java index 055970819e28..d85dd879e21d 100644 --- a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java +++ b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java @@ -732,6 +732,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY, monitoringExtras); EventLog.writeEvent(EventLogTags.RESTORE_TRANSPORT_FAILURE); + mStatus = BackupTransport.TRANSPORT_ERROR; nextState = UnifiedRestoreState.FINAL; } finally { executeNextState(nextState); -- cgit v1.2.3-59-g8ed1b