Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 676b3d2b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[RefactoredBMS] Offload the mRunningFullBackupTask.handleCancel() call...

Merge "[RefactoredBMS] Offload the mRunningFullBackupTask.handleCancel() call from the main thread to another thread"
parents df9f5f77 f95cf5d9
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -2119,14 +2119,26 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter
    // so tear down any ongoing backup task right away.
    @Override
    public void endFullBackup() {
        // offload the mRunningFullBackupTask.handleCancel() call to another thread,
        // as we might have to wait for mCancelLock
        Runnable endFullBackupRunnable = new Runnable() {
            @Override
            public void run() {
                PerformFullTransportBackupTask pftbt = null;
                synchronized (mQueueLock) {
                    if (mRunningFullBackupTask != null) {
                        pftbt = mRunningFullBackupTask;
                    }
                }
                if (pftbt != null) {
                    if (DEBUG_SCHEDULING) {
                        Slog.i(TAG, "Telling running backup to stop");
                    }
                mRunningFullBackupTask.handleCancel(true);
                    pftbt.handleCancel(true);
                }
            }
        };
        new Thread(endFullBackupRunnable, "end-full-backup").start();
    }

    // Used by both incremental and full restore