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

Commit f95cf5d9 authored by Michal Karpinski's avatar Michal Karpinski
Browse files

[RefactoredBMS] Offload the mRunningFullBackupTask.handleCancel()

call from the main thread to another thread

This CL replicates both ag/2135862 and ag/2465381 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: I895cb27bc910d9970ab1c33cd54a773b8f9b6cf6
parent 3f09d6cf
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