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

Commit 72b40d8f authored by Winson Chung's avatar Winson Chung
Browse files

Prevent adding duplicate overlays



- Hypothetical fix: check for duplicate overlay before adding it to the
  overlay list, otherwise we may attempt to release the same overlay
  twice when cleaning up the overlay later. We keep the rest of the
  setup just to keep it consistent with adding a new overlay though.
- Hold the wm lock when checking the overlay surface package state
  as in ag/25193528 to ensure it's also valid for the duration of the
  WM code running

Bug: 314880864
Test: atest TrustedOverlayTests
Change-Id: Ib7cad1a2265ba82dd1d98b8358380874f9f8719d
Signed-off-by: default avatarWinson Chung <winsonc@google.com>
parent 684e0da6
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -88,7 +88,17 @@ class TrustedOverlayHost {

    void addOverlay(SurfaceControlViewHost.SurfacePackage p, SurfaceControl currentParent) {
        requireOverlaySurfaceControl();

        boolean hasExistingOverlay = false;
        for (int i = mOverlays.size() - 1; i >= 0; i--) {
            SurfaceControlViewHost.SurfacePackage l = mOverlays.get(i);
            if (l.getSurfaceControl().isSameSurface(p.getSurfaceControl())) {
                hasExistingOverlay = true;
            }
        }
        if (!hasExistingOverlay) {
            mOverlays.add(p);
        }

        SurfaceControl.Transaction t = mWmService.mTransactionFactory.get();
        t.reparent(p.getSurfaceControl(), mSurfaceControl)
+5 −4
Original line number Diff line number Diff line
@@ -8468,12 +8468,13 @@ public class WindowManagerService extends IWindowManager.Stub
                SurfaceControlViewHost.SurfacePackage overlay) {
            if (overlay == null) {
                throw new IllegalArgumentException("Invalid overlay passed in for task=" + taskId);
            } else if (overlay.getSurfaceControl() == null
            }
            synchronized (mGlobalLock) {
                if (overlay.getSurfaceControl() == null
                    || !overlay.getSurfaceControl().isValid()) {
                    throw new IllegalArgumentException(
                            "Invalid overlay surfacecontrol passed in for task=" + taskId);
                }
            synchronized (mGlobalLock) {
                final Task task = mRoot.getRootTask(taskId);
                if (task == null) {
                    throw new IllegalArgumentException("no task with taskId" + taskId);