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

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

Don't copy null surface control and remove lingering references to leashes

- If a task that should otherwise be organized but does not yet have a
  surface when the task organizer is registered, then skip trying to
  return that task as we can not leash it.  Existing logic will send the
  task to the organizer once a surface control is set on it.
- In the entry points to the shell where leashes are given from WM core
  (ie. the organizers), ensure that we release them when we are notified
  that they are no longer organized

Bug: 235858985
Test: atest ShellTaskOrganizerTests
Test: atest WindowOrganizerTests

Change-Id: I863ab057a4a566060a1efbe8a20f2dd854fa8c74
parent dad802aa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ public class RootDisplayAreaOrganizer extends DisplayAreaOrganizer {
        }

        mDisplayAreasInfo.remove(displayId);
        mLeashes.get(displayId).release();
        mLeashes.remove(displayId);
    }

    @Override
+5 −1
Original line number Diff line number Diff line
@@ -529,7 +529,11 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
            }

            final int taskId = taskInfo.taskId;
            final TaskListener listener = getTaskListener(mTasks.get(taskId).getTaskInfo());
            final TaskAppearedInfo appearedInfo = mTasks.get(taskId);
            final TaskListener listener = getTaskListener(appearedInfo.getTaskInfo());
            if (appearedInfo.getLeash() != null) {
                appearedInfo.getLeash().release();
            }
            mTasks.remove(taskId);
            if (listener != null) {
                listener.onTaskVanished(taskInfo);
+3 −2
Original line number Diff line number Diff line
@@ -128,9 +128,10 @@ class HideDisplayCutoutOrganizer extends DisplayAreaOrganizer {

            final WindowContainerTransaction wct = new WindowContainerTransaction();
            final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            applyBoundsAndOffsets(
                    displayAreaInfo.token, mDisplayAreaMap.get(displayAreaInfo.token), wct, t);
            final SurfaceControl leash = mDisplayAreaMap.get(displayAreaInfo.token);
            applyBoundsAndOffsets(displayAreaInfo.token, leash, wct, t);
            applyTransaction(wct, t);
            leash.release();
            mDisplayAreaMap.remove(displayAreaInfo.token);
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -159,6 +159,10 @@ public class OneHandedDisplayAreaOrganizer extends DisplayAreaOrganizer {

    @Override
    public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {
        final SurfaceControl leash = mDisplayAreaTokenMap.get(displayAreaInfo.token);
        if (leash != null) {
            leash.release();
        }
        mDisplayAreaTokenMap.remove(displayAreaInfo.token);
    }

+1 −0
Original line number Diff line number Diff line
@@ -943,6 +943,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        mPipBoundsState.setBounds(new Rect());
        mPipUiEventLoggerLogger.setTaskInfo(null);
        mMainExecutor.executeDelayed(() -> mPipMenuController.detach(), 0);
        mLeash = null;

        if (info.displayId != Display.DEFAULT_DISPLAY && mOnDisplayIdChangeCallback != null) {
            mOnDisplayIdChangeCallback.accept(Display.DEFAULT_DISPLAY);
Loading