From a28e854683a732696b5d6b414e1a16c4c90d0294 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Mon, 12 Sep 2011 13:45:21 -0700 Subject: [PATCH] Move full backup/restore onto dedicated threads Running full backup/restore on the Backup Manager looper thread causes problems. It not only interfered with the delayed-Message timeout processing; in the case of installing apks during restore it also interfered fatally with the interaction between the Package Manager and install-time restore of data from the cloud. The long-term right thing to do here will be a refactoring of full backup and restore to be structured as the sort of state-machine process that incremental backup and restore now use. This is particularly thorny in the case of full restore (due to the Package Manager interactions), and full backup/restore are considered experimental at this point, so that refactoring is deferred to a future release. The current process is essentially standalone, so the bug is fixed here pro tem by letting it run to completion on its own thread, freeing the looper for normal work. Fixes bug 5173450 Change-Id: I659a61afa18ffe7fde1a07f7fa0e860d5e8d5a89 --- .../com/android/server/BackupManagerService.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index be2ef822fc617..2938c45e2c535 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -497,10 +497,14 @@ class BackupManagerService extends IBackupManager.Stub { case MSG_RUN_FULL_BACKUP: { + // TODO: refactor full backup to be a looper-based state machine + // similar to normal backup/restore. FullBackupParams params = (FullBackupParams)msg.obj; - (new PerformFullBackupTask(params.fd, params.observer, params.includeApks, + PerformFullBackupTask task = new PerformFullBackupTask(params.fd, + params.observer, params.includeApks, params.includeShared, params.curPassword, params.encryptPassword, - params.allApps, params.packages, params.latch)).run(); + params.allApps, params.packages, params.latch); + (new Thread(task)).start(); break; } @@ -519,9 +523,13 @@ class BackupManagerService extends IBackupManager.Stub { case MSG_RUN_FULL_RESTORE: { + // TODO: refactor full restore to be a looper-based state machine + // similar to normal backup/restore. FullRestoreParams params = (FullRestoreParams)msg.obj; - (new PerformFullRestoreTask(params.fd, params.curPassword, params.encryptPassword, - params.observer, params.latch)).run(); + PerformFullRestoreTask task = new PerformFullRestoreTask(params.fd, + params.curPassword, params.encryptPassword, + params.observer, params.latch); + (new Thread(task)).start(); break; }