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

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

Offload the mRunningFullBackupTask.handleCancel() call from the main

thread to another thread

The system_server process was being killed by Watchdog, as the main
thread was waiting for the mCancelLock for over a minute.

Bug: 35968123
Test: make gts -j40 && gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.backup.BackupManagerHostTest
Change-Id: Ia146569d2c741b35a6f6c9bfc4c5ddf8539b6242
parent a31f49a0
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -5641,14 +5641,24 @@ public class BackupManagerService {
    // The job scheduler says our constraints don't hold any more,
    // so tear down any ongoing backup task right away.
    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) {
                        if (DEBUG_SCHEDULING) {
                            Slog.i(TAG, "Telling running backup to stop");
                        }
                mRunningFullBackupTask.handleCancel(true);
                        pftbt = mRunningFullBackupTask;
                    }
                }
                pftbt.handleCancel(true);
            }
        };
        new Thread(endFullBackupRunnable, "end-full-backup").start();
    }
    // ----- Restore infrastructure -----