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

Commit b69258b2 authored by Winson Chung's avatar Winson Chung
Browse files

Fix crash when deleting task

- There are several code paths from the loaders (which run on a background
  thread) which post the call to notify an update on the task which was
  loaded. Not all of these are cleared when a task is unbound, and can
  result in a notifyTaskDataLoaded() after the task is unbound. For now,
  just ensure that the TaskView is bound to the Task before updating.

Bug: 62194807
Test: Have not been able to repro, just ensure that recents thumbnails still
      load

Change-Id: Id9301025275f4b14a2832f7f6c1ebd5a1ce124ea
parent 69a9c170
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks

    @ViewDebug.ExportedProperty(deepExport=true, prefix="task_")
    private Task mTask;
    private boolean mTaskBound;
    @ViewDebug.ExportedProperty(category="recents")
    private boolean mClipViewInStack = true;
    @ViewDebug.ExportedProperty(category="recents")
@@ -607,6 +608,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks
        SystemServicesProxy ssp = Recents.getSystemServices();
        mTouchExplorationEnabled = touchExplorationEnabled;
        mTask = t;
        mTaskBound = true;
        mTask.addCallback(this);
        mIsDisabledInSafeMode = !mTask.isSystemApp && ssp.isInSafeMode();
        mThumbnailView.bindToTask(mTask, mIsDisabledInSafeMode, displayOrientation, displayRect);
@@ -627,10 +629,12 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks

    @Override
    public void onTaskDataLoaded(Task task, ThumbnailData thumbnailData) {
        if (mTaskBound) {
            // Update each of the views to the new task data
            mThumbnailView.onTaskDataLoaded(thumbnailData);
            mHeaderView.onTaskDataLoaded();
        }
    }

    @Override
    public void onTaskDataUnloaded() {
@@ -638,6 +642,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks
        mTask.removeCallback(this);
        mThumbnailView.unbindFromTask();
        mHeaderView.unbindFromTask(mTouchExplorationEnabled);
        mTaskBound = false;
    }

    @Override