Loading services/backup/java/com/android/server/backup/BackupManagerService.java +46 −11 Original line number Diff line number Diff line Loading @@ -2682,20 +2682,33 @@ public class BackupManagerService { mStateDir = new File(mBaseStateDir, dirName); mCurrentOpToken = generateToken(); mCurrentState = BackupState.INITIAL; mFinished = false; synchronized (mCurrentOpLock) { if (isBackupOperationInProgress()) { if (DEBUG) { Slog.d(TAG, "Skipping backup since one is already in progress."); } mCancelAll = true; mFullBackupTask = null; mCurrentState = BackupState.FINAL; addBackupTrace("Skipped. Backup already in progress."); } else { mCurrentState = BackupState.INITIAL; CountDownLatch latch = new CountDownLatch(1); String[] fullBackups = mPendingFullBackups.toArray(new String[mPendingFullBackups.size()]); mFullBackupTask = new PerformFullTransportBackupTask(/*fullBackupRestoreObserver*/ null, fullBackups, /*updateSchedule*/ false, /*runningJob*/ null, latch, fullBackups, /*updateSchedule*/ false, /*runningJob*/ null, latch, mObserver, mMonitor, mUserInitiated); registerTask(); addBackupTrace("STATE => INITIAL"); } } } /** * Put this task in the repository of running tasks. Loading Loading @@ -3077,7 +3090,9 @@ public class BackupManagerService { mWakelock.acquire(); (new Thread(mFullBackupTask, "full-transport-requested")).start(); } else if (mCancelAll) { if (mFullBackupTask != null) { mFullBackupTask.unregisterTask(); } sendBackupFinished(mObserver, BackupManager.ERROR_BACKUP_CANCELLED); } else { mFullBackupTask.unregisterTask(); Loading Loading @@ -3561,6 +3576,18 @@ public class BackupManagerService { } } private boolean isBackupOperationInProgress() { synchronized (mCurrentOpLock) { for (int i = 0; i < mCurrentOperations.size(); i++) { Operation op = mCurrentOperations.valueAt(i); if (op.type == OP_TYPE_BACKUP && op.state == OP_PENDING) { return true; } } } return false; } // ----- Full backup/restore to a file/socket ----- Loading Loading @@ -4543,6 +4570,14 @@ public class BackupManagerService { mCurrentOpToken = generateToken(); mBackupRunnerOpToken = generateToken(); if (isBackupOperationInProgress()) { if (DEBUG) { Slog.d(TAG, "Skipping full backup. A backup is already in progress."); } mCancelAll = true; return; } registerTask(); for (String pkg : whichPackages) { Loading Loading
services/backup/java/com/android/server/backup/BackupManagerService.java +46 −11 Original line number Diff line number Diff line Loading @@ -2682,20 +2682,33 @@ public class BackupManagerService { mStateDir = new File(mBaseStateDir, dirName); mCurrentOpToken = generateToken(); mCurrentState = BackupState.INITIAL; mFinished = false; synchronized (mCurrentOpLock) { if (isBackupOperationInProgress()) { if (DEBUG) { Slog.d(TAG, "Skipping backup since one is already in progress."); } mCancelAll = true; mFullBackupTask = null; mCurrentState = BackupState.FINAL; addBackupTrace("Skipped. Backup already in progress."); } else { mCurrentState = BackupState.INITIAL; CountDownLatch latch = new CountDownLatch(1); String[] fullBackups = mPendingFullBackups.toArray(new String[mPendingFullBackups.size()]); mFullBackupTask = new PerformFullTransportBackupTask(/*fullBackupRestoreObserver*/ null, fullBackups, /*updateSchedule*/ false, /*runningJob*/ null, latch, fullBackups, /*updateSchedule*/ false, /*runningJob*/ null, latch, mObserver, mMonitor, mUserInitiated); registerTask(); addBackupTrace("STATE => INITIAL"); } } } /** * Put this task in the repository of running tasks. Loading Loading @@ -3077,7 +3090,9 @@ public class BackupManagerService { mWakelock.acquire(); (new Thread(mFullBackupTask, "full-transport-requested")).start(); } else if (mCancelAll) { if (mFullBackupTask != null) { mFullBackupTask.unregisterTask(); } sendBackupFinished(mObserver, BackupManager.ERROR_BACKUP_CANCELLED); } else { mFullBackupTask.unregisterTask(); Loading Loading @@ -3561,6 +3576,18 @@ public class BackupManagerService { } } private boolean isBackupOperationInProgress() { synchronized (mCurrentOpLock) { for (int i = 0; i < mCurrentOperations.size(); i++) { Operation op = mCurrentOperations.valueAt(i); if (op.type == OP_TYPE_BACKUP && op.state == OP_PENDING) { return true; } } } return false; } // ----- Full backup/restore to a file/socket ----- Loading Loading @@ -4543,6 +4570,14 @@ public class BackupManagerService { mCurrentOpToken = generateToken(); mBackupRunnerOpToken = generateToken(); if (isBackupOperationInProgress()) { if (DEBUG) { Slog.d(TAG, "Skipping full backup. A backup is already in progress."); } mCancelAll = true; return; } registerTask(); for (String pkg : whichPackages) { Loading