Loading services/backup/java/com/android/server/backup/RefactoredBackupManagerService.java +16 −21 Original line number Diff line number Diff line Loading @@ -18,6 +18,22 @@ package com.android.server.backup; import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_BACKUP_IN_FOREGROUND; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_FULL_CONFIRMATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_OP_COMPLETE; import static com.android.server.backup.internal.BackupHandler.MSG_REQUEST_BACKUP; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_SESSION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_RETRY_CLEAR; import static com.android.server.backup.internal.BackupHandler.MSG_RETRY_INIT; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_ADB_BACKUP; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_ADB_RESTORE; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_BACKUP; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_CLEAR; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_INITIALIZE; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_RESTORE; import static com.android.server.backup.internal.BackupHandler.MSG_SCHEDULE_BACKUP_PACKAGE; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.AppGlobals; Loading Loading @@ -189,27 +205,6 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter public static final String RUN_BACKUP_ACTION = "android.app.backup.intent.RUN"; public static final String RUN_INITIALIZE_ACTION = "android.app.backup.intent.INIT"; public static final int MSG_RUN_BACKUP = 1; public static final int MSG_RUN_ADB_BACKUP = 2; public static final int MSG_RUN_RESTORE = 3; public static final int MSG_RUN_CLEAR = 4; public static final int MSG_RUN_INITIALIZE = 5; public static final int MSG_RUN_GET_RESTORE_SETS = 6; public static final int MSG_RESTORE_SESSION_TIMEOUT = 8; public static final int MSG_FULL_CONFIRMATION_TIMEOUT = 9; public static final int MSG_RUN_ADB_RESTORE = 10; public static final int MSG_RETRY_INIT = 11; public static final int MSG_RETRY_CLEAR = 12; public static final int MSG_WIDGET_BROADCAST = 13; public static final int MSG_RUN_FULL_TRANSPORT_BACKUP = 14; public static final int MSG_REQUEST_BACKUP = 15; public static final int MSG_SCHEDULE_BACKUP_PACKAGE = 16; public static final int MSG_BACKUP_OPERATION_TIMEOUT = 17; public static final int MSG_RESTORE_OPERATION_TIMEOUT = 18; // backup task state machine tick public static final int MSG_BACKUP_RESTORE_STEP = 20; public static final int MSG_OP_COMPLETE = 21; // Timeout interval for deciding that a bind or clear-data has taken too long private static final long TIMEOUT_INTERVAL = 10 * 1000; Loading services/backup/java/com/android/server/backup/internal/BackupHandler.java +45 −27 Original line number Diff line number Diff line Loading @@ -55,6 +55,27 @@ import java.util.HashSet; */ public class BackupHandler extends Handler { public static final int MSG_RUN_BACKUP = 1; public static final int MSG_RUN_ADB_BACKUP = 2; public static final int MSG_RUN_RESTORE = 3; public static final int MSG_RUN_CLEAR = 4; public static final int MSG_RUN_INITIALIZE = 5; public static final int MSG_RUN_GET_RESTORE_SETS = 6; public static final int MSG_RESTORE_SESSION_TIMEOUT = 8; public static final int MSG_FULL_CONFIRMATION_TIMEOUT = 9; public static final int MSG_RUN_ADB_RESTORE = 10; public static final int MSG_RETRY_INIT = 11; public static final int MSG_RETRY_CLEAR = 12; public static final int MSG_WIDGET_BROADCAST = 13; public static final int MSG_RUN_FULL_TRANSPORT_BACKUP = 14; public static final int MSG_REQUEST_BACKUP = 15; public static final int MSG_SCHEDULE_BACKUP_PACKAGE = 16; public static final int MSG_BACKUP_OPERATION_TIMEOUT = 17; public static final int MSG_RESTORE_OPERATION_TIMEOUT = 18; // backup task state machine tick public static final int MSG_BACKUP_RESTORE_STEP = 20; public static final int MSG_OP_COMPLETE = 21; private RefactoredBackupManagerService backupManagerService; public BackupHandler( Loading @@ -66,7 +87,7 @@ public class BackupHandler extends Handler { public void handleMessage(Message msg) { switch (msg.what) { case RefactoredBackupManagerService.MSG_RUN_BACKUP: { case MSG_RUN_BACKUP: { backupManagerService.setLastBackupPass(System.currentTimeMillis()); IBackupTransport transport = Loading Loading @@ -117,8 +138,7 @@ public class BackupHandler extends Handler { backupManagerService, transport, dirName, queue, oldJournal, null, null, Collections.<String>emptyList(), false, false /* nonIncremental */); Message pbtMessage = obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, pbt); Message pbtMessage = obtainMessage(MSG_BACKUP_RESTORE_STEP, pbt); sendMessage(pbtMessage); } catch (Exception e) { // unable to ask the transport its dir name -- transient failure, since Loading @@ -144,7 +164,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP: { case MSG_BACKUP_RESTORE_STEP: { try { BackupRestoreTask task = (BackupRestoreTask) msg.obj; if (RefactoredBackupManagerService.MORE_DEBUG) { Loading @@ -159,7 +179,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_OP_COMPLETE: { case MSG_OP_COMPLETE: { try { Pair<BackupRestoreTask, Long> taskWithResult = (Pair<BackupRestoreTask, Long>) msg.obj; Loading @@ -171,7 +191,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_ADB_BACKUP: { case MSG_RUN_ADB_BACKUP: { // TODO: refactor full backup to be a looper-based state machine // similar to normal backup/restore. AdbBackupParams params = (AdbBackupParams) msg.obj; Loading @@ -185,13 +205,13 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_FULL_TRANSPORT_BACKUP: { case MSG_RUN_FULL_TRANSPORT_BACKUP: { PerformFullTransportBackupTask task = (PerformFullTransportBackupTask) msg.obj; (new Thread(task, "transport-backup")).start(); break; } case RefactoredBackupManagerService.MSG_RUN_RESTORE: { case MSG_RUN_RESTORE: { RestoreParams params = (RestoreParams) msg.obj; Slog.d(RefactoredBackupManagerService.TAG, "MSG_RUN_RESTORE observer=" + params.observer); Loading @@ -215,15 +235,14 @@ public class BackupHandler extends Handler { Slog.d(RefactoredBackupManagerService.TAG, "Starting restore."); } backupManagerService.setRestoreInProgress(true); Message restoreMsg = obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, task); Message restoreMsg = obtainMessage(MSG_BACKUP_RESTORE_STEP, task); sendMessage(restoreMsg); } } break; } case RefactoredBackupManagerService.MSG_RUN_ADB_RESTORE: { case MSG_RUN_ADB_RESTORE: { // TODO: refactor full restore to be a looper-based state machine // similar to normal backup/restore. AdbRestoreParams params = (AdbRestoreParams) msg.obj; Loading @@ -235,21 +254,21 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_CLEAR: { case MSG_RUN_CLEAR: { ClearParams params = (ClearParams) msg.obj; (new PerformClearTask(backupManagerService, params.transport, params.packageInfo)).run(); break; } case RefactoredBackupManagerService.MSG_RETRY_CLEAR: { case MSG_RETRY_CLEAR: { // reenqueues if the transport remains unavailable ClearRetryParams params = (ClearRetryParams) msg.obj; backupManagerService.clearBackupData(params.transportName, params.packageName); break; } case RefactoredBackupManagerService.MSG_RUN_INITIALIZE: { case MSG_RUN_INITIALIZE: { HashSet<String> queue; // Snapshot the pending-init queue and work on that Loading @@ -262,7 +281,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RETRY_INIT: { case MSG_RETRY_INIT: { synchronized (backupManagerService.getQueueLock()) { backupManagerService.recordInitPendingLocked(msg.arg1 != 0, (String) msg.obj); backupManagerService.getAlarmManager().set(AlarmManager.RTC_WAKEUP, Loading @@ -272,7 +291,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_GET_RESTORE_SETS: { case MSG_RUN_GET_RESTORE_SETS: { // Like other async operations, this is entered with the wakelock held RestoreSet[] sets = null; RestoreGetSetsParams params = (RestoreGetSetsParams) msg.obj; Loading Loading @@ -302,9 +321,9 @@ public class BackupHandler extends Handler { } // Done: reset the session timeout clock removeMessages(RefactoredBackupManagerService.MSG_RESTORE_SESSION_TIMEOUT); removeMessages(MSG_RESTORE_SESSION_TIMEOUT); sendEmptyMessageDelayed( RefactoredBackupManagerService.MSG_RESTORE_SESSION_TIMEOUT, MSG_RESTORE_SESSION_TIMEOUT, RefactoredBackupManagerService.TIMEOUT_RESTORE_INTERVAL); backupManagerService.getWakelock().release(); Loading @@ -312,15 +331,15 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_BACKUP_OPERATION_TIMEOUT: case RefactoredBackupManagerService.MSG_RESTORE_OPERATION_TIMEOUT: { case MSG_BACKUP_OPERATION_TIMEOUT: case MSG_RESTORE_OPERATION_TIMEOUT: { Slog.d(RefactoredBackupManagerService.TAG, "Timeout message received for token=" + Integer.toHexString(msg.arg1)); backupManagerService.handleCancel(msg.arg1, false); break; } case RefactoredBackupManagerService.MSG_RESTORE_SESSION_TIMEOUT: { case MSG_RESTORE_SESSION_TIMEOUT: { synchronized (backupManagerService) { if (backupManagerService.getActiveRestoreSession() != null) { // Client app left the restore session dangling. We know that it Loading @@ -338,7 +357,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_FULL_CONFIRMATION_TIMEOUT: { case MSG_FULL_CONFIRMATION_TIMEOUT: { synchronized (backupManagerService.getAdbBackupRestoreConfirmations()) { AdbParams params = backupManagerService.getAdbBackupRestoreConfirmations().get( msg.arg1); Loading Loading @@ -368,13 +387,13 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_WIDGET_BROADCAST: { case MSG_WIDGET_BROADCAST: { final Intent intent = (Intent) msg.obj; backupManagerService.getContext().sendBroadcastAsUser(intent, UserHandle.SYSTEM); break; } case RefactoredBackupManagerService.MSG_REQUEST_BACKUP: { case MSG_REQUEST_BACKUP: { BackupParams params = (BackupParams) msg.obj; if (RefactoredBackupManagerService.MORE_DEBUG) { Slog.d(RefactoredBackupManagerService.TAG, Loading @@ -392,13 +411,12 @@ public class BackupHandler extends Handler { params.transport, params.dirName, kvQueue, null, params.observer, params.monitor, params.fullPackages, true, params.nonIncrementalBackup); Message pbtMessage = obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, pbt); Message pbtMessage = obtainMessage(MSG_BACKUP_RESTORE_STEP, pbt); sendMessage(pbtMessage); break; } case RefactoredBackupManagerService.MSG_SCHEDULE_BACKUP_PACKAGE: { case MSG_SCHEDULE_BACKUP_PACKAGE: { String pkgName = (String) msg.obj; if (RefactoredBackupManagerService.MORE_DEBUG) { Slog.d(RefactoredBackupManagerService.TAG, Loading services/backup/java/com/android/server/backup/internal/PerformBackupTask.java +7 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.backup.internal; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_RESTORE_STEP; import android.app.ApplicationThreadConstants; import android.app.IBackupAgent; import android.app.backup.BackupDataInput; Loading Loading @@ -322,7 +325,7 @@ public class PerformBackupTask implements BackupRestoreTask { // backup callback and returned. Blow away the lingering (spurious) // pending timeout message for it. backupManagerService.getBackupHandler().removeMessages( RefactoredBackupManagerService.MSG_BACKUP_OPERATION_TIMEOUT); MSG_BACKUP_OPERATION_TIMEOUT); } } Loading Loading @@ -846,8 +849,7 @@ public class PerformBackupTask implements BackupRestoreTask { BackupManagerMonitor.EXTRA_LOG_ILLEGAL_KEY, key)); backupManagerService.getBackupHandler().removeMessages( RefactoredBackupManagerService .MSG_BACKUP_OPERATION_TIMEOUT); MSG_BACKUP_OPERATION_TIMEOUT); BackupObserverUtils .sendBackupOnPackageResult(mObserver, pkgName, BackupManager.ERROR_AGENT_FAILURE); Loading Loading @@ -885,8 +887,7 @@ public class PerformBackupTask implements BackupRestoreTask { "operationComplete(): sending data to transport for " + pkgName); } backupManagerService.getBackupHandler().removeMessages( RefactoredBackupManagerService.MSG_BACKUP_OPERATION_TIMEOUT); backupManagerService.getBackupHandler().removeMessages(MSG_BACKUP_OPERATION_TIMEOUT); clearAgentState(); backupManagerService.addBackupTrace("operation complete"); Loading Loading @@ -1115,7 +1116,7 @@ public class PerformBackupTask implements BackupRestoreTask { backupManagerService.addBackupTrace("executeNextState => " + nextState); mCurrentState = nextState; Message msg = backupManagerService.getBackupHandler().obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, this); MSG_BACKUP_RESTORE_STEP, this); backupManagerService.getBackupHandler().sendMessage(msg); } } services/backup/java/com/android/server/backup/internal/RunBackupReceiver.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.backup.internal; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_BACKUP; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -66,7 +68,7 @@ public class RunBackupReceiver extends BroadcastReceiver { backupManagerService.getWakelock().acquire(); Message msg = backupManagerService.getBackupHandler().obtainMessage( RefactoredBackupManagerService.MSG_RUN_BACKUP); MSG_RUN_BACKUP); backupManagerService.getBackupHandler().sendMessage(msg); } else { Slog.i(RefactoredBackupManagerService.TAG, Loading services/backup/java/com/android/server/backup/internal/RunInitializeReceiver.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.backup.internal; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_INITIALIZE; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -44,7 +46,7 @@ public class RunInitializeReceiver extends BroadcastReceiver { backupManagerService.getWakelock().acquire(); Message msg = backupManagerService.getBackupHandler().obtainMessage( RefactoredBackupManagerService.MSG_RUN_INITIALIZE); MSG_RUN_INITIALIZE); backupManagerService.getBackupHandler().sendMessage(msg); } } Loading Loading
services/backup/java/com/android/server/backup/RefactoredBackupManagerService.java +16 −21 Original line number Diff line number Diff line Loading @@ -18,6 +18,22 @@ package com.android.server.backup; import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_BACKUP_IN_FOREGROUND; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_FULL_CONFIRMATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_OP_COMPLETE; import static com.android.server.backup.internal.BackupHandler.MSG_REQUEST_BACKUP; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_SESSION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_RETRY_CLEAR; import static com.android.server.backup.internal.BackupHandler.MSG_RETRY_INIT; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_ADB_BACKUP; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_ADB_RESTORE; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_BACKUP; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_CLEAR; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_INITIALIZE; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_RESTORE; import static com.android.server.backup.internal.BackupHandler.MSG_SCHEDULE_BACKUP_PACKAGE; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.AppGlobals; Loading Loading @@ -189,27 +205,6 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter public static final String RUN_BACKUP_ACTION = "android.app.backup.intent.RUN"; public static final String RUN_INITIALIZE_ACTION = "android.app.backup.intent.INIT"; public static final int MSG_RUN_BACKUP = 1; public static final int MSG_RUN_ADB_BACKUP = 2; public static final int MSG_RUN_RESTORE = 3; public static final int MSG_RUN_CLEAR = 4; public static final int MSG_RUN_INITIALIZE = 5; public static final int MSG_RUN_GET_RESTORE_SETS = 6; public static final int MSG_RESTORE_SESSION_TIMEOUT = 8; public static final int MSG_FULL_CONFIRMATION_TIMEOUT = 9; public static final int MSG_RUN_ADB_RESTORE = 10; public static final int MSG_RETRY_INIT = 11; public static final int MSG_RETRY_CLEAR = 12; public static final int MSG_WIDGET_BROADCAST = 13; public static final int MSG_RUN_FULL_TRANSPORT_BACKUP = 14; public static final int MSG_REQUEST_BACKUP = 15; public static final int MSG_SCHEDULE_BACKUP_PACKAGE = 16; public static final int MSG_BACKUP_OPERATION_TIMEOUT = 17; public static final int MSG_RESTORE_OPERATION_TIMEOUT = 18; // backup task state machine tick public static final int MSG_BACKUP_RESTORE_STEP = 20; public static final int MSG_OP_COMPLETE = 21; // Timeout interval for deciding that a bind or clear-data has taken too long private static final long TIMEOUT_INTERVAL = 10 * 1000; Loading
services/backup/java/com/android/server/backup/internal/BackupHandler.java +45 −27 Original line number Diff line number Diff line Loading @@ -55,6 +55,27 @@ import java.util.HashSet; */ public class BackupHandler extends Handler { public static final int MSG_RUN_BACKUP = 1; public static final int MSG_RUN_ADB_BACKUP = 2; public static final int MSG_RUN_RESTORE = 3; public static final int MSG_RUN_CLEAR = 4; public static final int MSG_RUN_INITIALIZE = 5; public static final int MSG_RUN_GET_RESTORE_SETS = 6; public static final int MSG_RESTORE_SESSION_TIMEOUT = 8; public static final int MSG_FULL_CONFIRMATION_TIMEOUT = 9; public static final int MSG_RUN_ADB_RESTORE = 10; public static final int MSG_RETRY_INIT = 11; public static final int MSG_RETRY_CLEAR = 12; public static final int MSG_WIDGET_BROADCAST = 13; public static final int MSG_RUN_FULL_TRANSPORT_BACKUP = 14; public static final int MSG_REQUEST_BACKUP = 15; public static final int MSG_SCHEDULE_BACKUP_PACKAGE = 16; public static final int MSG_BACKUP_OPERATION_TIMEOUT = 17; public static final int MSG_RESTORE_OPERATION_TIMEOUT = 18; // backup task state machine tick public static final int MSG_BACKUP_RESTORE_STEP = 20; public static final int MSG_OP_COMPLETE = 21; private RefactoredBackupManagerService backupManagerService; public BackupHandler( Loading @@ -66,7 +87,7 @@ public class BackupHandler extends Handler { public void handleMessage(Message msg) { switch (msg.what) { case RefactoredBackupManagerService.MSG_RUN_BACKUP: { case MSG_RUN_BACKUP: { backupManagerService.setLastBackupPass(System.currentTimeMillis()); IBackupTransport transport = Loading Loading @@ -117,8 +138,7 @@ public class BackupHandler extends Handler { backupManagerService, transport, dirName, queue, oldJournal, null, null, Collections.<String>emptyList(), false, false /* nonIncremental */); Message pbtMessage = obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, pbt); Message pbtMessage = obtainMessage(MSG_BACKUP_RESTORE_STEP, pbt); sendMessage(pbtMessage); } catch (Exception e) { // unable to ask the transport its dir name -- transient failure, since Loading @@ -144,7 +164,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP: { case MSG_BACKUP_RESTORE_STEP: { try { BackupRestoreTask task = (BackupRestoreTask) msg.obj; if (RefactoredBackupManagerService.MORE_DEBUG) { Loading @@ -159,7 +179,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_OP_COMPLETE: { case MSG_OP_COMPLETE: { try { Pair<BackupRestoreTask, Long> taskWithResult = (Pair<BackupRestoreTask, Long>) msg.obj; Loading @@ -171,7 +191,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_ADB_BACKUP: { case MSG_RUN_ADB_BACKUP: { // TODO: refactor full backup to be a looper-based state machine // similar to normal backup/restore. AdbBackupParams params = (AdbBackupParams) msg.obj; Loading @@ -185,13 +205,13 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_FULL_TRANSPORT_BACKUP: { case MSG_RUN_FULL_TRANSPORT_BACKUP: { PerformFullTransportBackupTask task = (PerformFullTransportBackupTask) msg.obj; (new Thread(task, "transport-backup")).start(); break; } case RefactoredBackupManagerService.MSG_RUN_RESTORE: { case MSG_RUN_RESTORE: { RestoreParams params = (RestoreParams) msg.obj; Slog.d(RefactoredBackupManagerService.TAG, "MSG_RUN_RESTORE observer=" + params.observer); Loading @@ -215,15 +235,14 @@ public class BackupHandler extends Handler { Slog.d(RefactoredBackupManagerService.TAG, "Starting restore."); } backupManagerService.setRestoreInProgress(true); Message restoreMsg = obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, task); Message restoreMsg = obtainMessage(MSG_BACKUP_RESTORE_STEP, task); sendMessage(restoreMsg); } } break; } case RefactoredBackupManagerService.MSG_RUN_ADB_RESTORE: { case MSG_RUN_ADB_RESTORE: { // TODO: refactor full restore to be a looper-based state machine // similar to normal backup/restore. AdbRestoreParams params = (AdbRestoreParams) msg.obj; Loading @@ -235,21 +254,21 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_CLEAR: { case MSG_RUN_CLEAR: { ClearParams params = (ClearParams) msg.obj; (new PerformClearTask(backupManagerService, params.transport, params.packageInfo)).run(); break; } case RefactoredBackupManagerService.MSG_RETRY_CLEAR: { case MSG_RETRY_CLEAR: { // reenqueues if the transport remains unavailable ClearRetryParams params = (ClearRetryParams) msg.obj; backupManagerService.clearBackupData(params.transportName, params.packageName); break; } case RefactoredBackupManagerService.MSG_RUN_INITIALIZE: { case MSG_RUN_INITIALIZE: { HashSet<String> queue; // Snapshot the pending-init queue and work on that Loading @@ -262,7 +281,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RETRY_INIT: { case MSG_RETRY_INIT: { synchronized (backupManagerService.getQueueLock()) { backupManagerService.recordInitPendingLocked(msg.arg1 != 0, (String) msg.obj); backupManagerService.getAlarmManager().set(AlarmManager.RTC_WAKEUP, Loading @@ -272,7 +291,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_RUN_GET_RESTORE_SETS: { case MSG_RUN_GET_RESTORE_SETS: { // Like other async operations, this is entered with the wakelock held RestoreSet[] sets = null; RestoreGetSetsParams params = (RestoreGetSetsParams) msg.obj; Loading Loading @@ -302,9 +321,9 @@ public class BackupHandler extends Handler { } // Done: reset the session timeout clock removeMessages(RefactoredBackupManagerService.MSG_RESTORE_SESSION_TIMEOUT); removeMessages(MSG_RESTORE_SESSION_TIMEOUT); sendEmptyMessageDelayed( RefactoredBackupManagerService.MSG_RESTORE_SESSION_TIMEOUT, MSG_RESTORE_SESSION_TIMEOUT, RefactoredBackupManagerService.TIMEOUT_RESTORE_INTERVAL); backupManagerService.getWakelock().release(); Loading @@ -312,15 +331,15 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_BACKUP_OPERATION_TIMEOUT: case RefactoredBackupManagerService.MSG_RESTORE_OPERATION_TIMEOUT: { case MSG_BACKUP_OPERATION_TIMEOUT: case MSG_RESTORE_OPERATION_TIMEOUT: { Slog.d(RefactoredBackupManagerService.TAG, "Timeout message received for token=" + Integer.toHexString(msg.arg1)); backupManagerService.handleCancel(msg.arg1, false); break; } case RefactoredBackupManagerService.MSG_RESTORE_SESSION_TIMEOUT: { case MSG_RESTORE_SESSION_TIMEOUT: { synchronized (backupManagerService) { if (backupManagerService.getActiveRestoreSession() != null) { // Client app left the restore session dangling. We know that it Loading @@ -338,7 +357,7 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_FULL_CONFIRMATION_TIMEOUT: { case MSG_FULL_CONFIRMATION_TIMEOUT: { synchronized (backupManagerService.getAdbBackupRestoreConfirmations()) { AdbParams params = backupManagerService.getAdbBackupRestoreConfirmations().get( msg.arg1); Loading Loading @@ -368,13 +387,13 @@ public class BackupHandler extends Handler { break; } case RefactoredBackupManagerService.MSG_WIDGET_BROADCAST: { case MSG_WIDGET_BROADCAST: { final Intent intent = (Intent) msg.obj; backupManagerService.getContext().sendBroadcastAsUser(intent, UserHandle.SYSTEM); break; } case RefactoredBackupManagerService.MSG_REQUEST_BACKUP: { case MSG_REQUEST_BACKUP: { BackupParams params = (BackupParams) msg.obj; if (RefactoredBackupManagerService.MORE_DEBUG) { Slog.d(RefactoredBackupManagerService.TAG, Loading @@ -392,13 +411,12 @@ public class BackupHandler extends Handler { params.transport, params.dirName, kvQueue, null, params.observer, params.monitor, params.fullPackages, true, params.nonIncrementalBackup); Message pbtMessage = obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, pbt); Message pbtMessage = obtainMessage(MSG_BACKUP_RESTORE_STEP, pbt); sendMessage(pbtMessage); break; } case RefactoredBackupManagerService.MSG_SCHEDULE_BACKUP_PACKAGE: { case MSG_SCHEDULE_BACKUP_PACKAGE: { String pkgName = (String) msg.obj; if (RefactoredBackupManagerService.MORE_DEBUG) { Slog.d(RefactoredBackupManagerService.TAG, Loading
services/backup/java/com/android/server/backup/internal/PerformBackupTask.java +7 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.backup.internal; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_RESTORE_STEP; import android.app.ApplicationThreadConstants; import android.app.IBackupAgent; import android.app.backup.BackupDataInput; Loading Loading @@ -322,7 +325,7 @@ public class PerformBackupTask implements BackupRestoreTask { // backup callback and returned. Blow away the lingering (spurious) // pending timeout message for it. backupManagerService.getBackupHandler().removeMessages( RefactoredBackupManagerService.MSG_BACKUP_OPERATION_TIMEOUT); MSG_BACKUP_OPERATION_TIMEOUT); } } Loading Loading @@ -846,8 +849,7 @@ public class PerformBackupTask implements BackupRestoreTask { BackupManagerMonitor.EXTRA_LOG_ILLEGAL_KEY, key)); backupManagerService.getBackupHandler().removeMessages( RefactoredBackupManagerService .MSG_BACKUP_OPERATION_TIMEOUT); MSG_BACKUP_OPERATION_TIMEOUT); BackupObserverUtils .sendBackupOnPackageResult(mObserver, pkgName, BackupManager.ERROR_AGENT_FAILURE); Loading Loading @@ -885,8 +887,7 @@ public class PerformBackupTask implements BackupRestoreTask { "operationComplete(): sending data to transport for " + pkgName); } backupManagerService.getBackupHandler().removeMessages( RefactoredBackupManagerService.MSG_BACKUP_OPERATION_TIMEOUT); backupManagerService.getBackupHandler().removeMessages(MSG_BACKUP_OPERATION_TIMEOUT); clearAgentState(); backupManagerService.addBackupTrace("operation complete"); Loading Loading @@ -1115,7 +1116,7 @@ public class PerformBackupTask implements BackupRestoreTask { backupManagerService.addBackupTrace("executeNextState => " + nextState); mCurrentState = nextState; Message msg = backupManagerService.getBackupHandler().obtainMessage( RefactoredBackupManagerService.MSG_BACKUP_RESTORE_STEP, this); MSG_BACKUP_RESTORE_STEP, this); backupManagerService.getBackupHandler().sendMessage(msg); } }
services/backup/java/com/android/server/backup/internal/RunBackupReceiver.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.backup.internal; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_BACKUP; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -66,7 +68,7 @@ public class RunBackupReceiver extends BroadcastReceiver { backupManagerService.getWakelock().acquire(); Message msg = backupManagerService.getBackupHandler().obtainMessage( RefactoredBackupManagerService.MSG_RUN_BACKUP); MSG_RUN_BACKUP); backupManagerService.getBackupHandler().sendMessage(msg); } else { Slog.i(RefactoredBackupManagerService.TAG, Loading
services/backup/java/com/android/server/backup/internal/RunInitializeReceiver.java +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.backup.internal; import static com.android.server.backup.internal.BackupHandler.MSG_RUN_INITIALIZE; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -44,7 +46,7 @@ public class RunInitializeReceiver extends BroadcastReceiver { backupManagerService.getWakelock().acquire(); Message msg = backupManagerService.getBackupHandler().obtainMessage( RefactoredBackupManagerService.MSG_RUN_INITIALIZE); MSG_RUN_INITIALIZE); backupManagerService.getBackupHandler().sendMessage(msg); } } Loading