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

Commit e22d70dc authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Prevent adding duplicate overlays" into main

parents bbedd457 72b40d8f
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -88,7 +88,17 @@ class TrustedOverlayHost {


    void addOverlay(SurfaceControlViewHost.SurfacePackage p, SurfaceControl currentParent) {
    void addOverlay(SurfaceControlViewHost.SurfacePackage p, SurfaceControl currentParent) {
        requireOverlaySurfaceControl();
        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);
            mOverlays.add(p);
        }


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