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

Commit 1a2061e5 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Add null check to offsetCaptionLocation

There is currently a bug that is causing window decorations to exist
even after the task they belong to has been deleted. This is causing a
null pointer exception here since we are searching for the TaskInfo of
an already deleted task using TaskOrganizer#getRunningTaskInfo which
causes it to return null.

Bug: 311273642
Test: Move task around and change windowing modes to make sure SysUi is
no longer crashing

Change-Id: I4972f041d36e345a40a026bdfc4c4077ff13dfe0
parent 5cd1f906
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -548,8 +548,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    private PointF offsetCaptionLocation(MotionEvent ev) {
        final PointF result = new PointF(ev.getX(), ev.getY());
        final Point positionInParent = mTaskOrganizer.getRunningTaskInfo(mTaskInfo.taskId)
                .positionInParent;
        final ActivityManager.RunningTaskInfo taskInfo =
                mTaskOrganizer.getRunningTaskInfo(mTaskInfo.taskId);
        if (taskInfo == null) return result;
        final Point positionInParent = taskInfo.positionInParent;
        result.offset(-mRelayoutParams.mCaptionX, -mRelayoutParams.mCaptionY);
        result.offset(-positionInParent.x, -positionInParent.y);
        return result;