Merge "Offload the mRunningFullBackupTask.handleCancel() call from the main thread to another thread" into oc-dev

This commit is contained in:
Michal Karpinski
2017-04-26 09:44:49 +00:00
committed by Android (Google) Code Review

View File

@@ -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() {
synchronized (mQueueLock) {
if (mRunningFullBackupTask != null) {
if (DEBUG_SCHEDULING) {
Slog.i(TAG, "Telling running backup to stop");
// 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");
}
pftbt = mRunningFullBackupTask;
}
}
mRunningFullBackupTask.handleCancel(true);
pftbt.handleCancel(true);
}
}
};
new Thread(endFullBackupRunnable, "end-full-backup").start();
}
// ----- Restore infrastructure -----