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

Commit 294382ac authored by bkchoi's avatar bkchoi
Browse files

Fix a bug in computeTpl() when there are multiple displays.

coveredRegionsAbove computed for one display could affect another
display. We need to extend coveredRegionsAbove to be per-display data so
that each display can be independently calculated.

Bug: 383679189
Flag: EXEMPT bugfix
Test: atest android.view.surfacecontrol.cts.TrustedPresentationListenerTest

Change-Id: I6e9f4fd06a5fcd5b1218c678b43c7f585ccb91e4
parent e09cce99
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.graphics.Matrix.MSCALE_X;
import static android.graphics.Matrix.MSCALE_Y;
import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.view.Display.INVALID_DISPLAY;

import static com.android.internal.protolog.WmProtoLogGroups.WM_DEBUG_TPL;

@@ -35,6 +36,7 @@ import android.util.ArrayMap;
import android.util.IntArray;
import android.util.Pair;
import android.util.Size;
import android.util.SparseArray;
import android.view.InputWindowHandle;
import android.window.ITrustedPresentationListener;
import android.window.TrustedPresentationThresholds;
@@ -251,7 +253,7 @@ public class TrustedPresentationListenerController {
        Rect tmpLogicalDisplaySize = new Rect();
        Matrix tmpInverseMatrix = new Matrix();
        float[] tmpMatrix = new float[9];
        Region coveredRegionsAbove = new Region();
        SparseArray<Region> coveredRegionsAboveByDisplay = new SparseArray<>();
        long currTimeMs = System.currentTimeMillis();
        ProtoLog.v(WM_DEBUG_TPL, "Checking %d windows", mLastWindowHandles.first.length);

@@ -262,7 +264,7 @@ public class TrustedPresentationListenerController {
                ProtoLog.v(WM_DEBUG_TPL, "Skipping %s", windowHandle.name);
                continue;
            }
            var displayFound = false;
            int displayId = INVALID_DISPLAY;
            tmpRectF.set(windowHandle.frame);
            for (var displayHandle : mLastWindowHandles.second) {
                if (displayHandle.mDisplayId == windowHandle.displayId) {
@@ -273,17 +275,18 @@ public class TrustedPresentationListenerController {
                    tmpLogicalDisplaySize.set(0, 0, displayHandle.mLogicalSize.getWidth(),
                            displayHandle.mLogicalSize.getHeight());
                    tmpRect.intersect(tmpLogicalDisplaySize);
                    displayFound = true;
                    displayId = displayHandle.mDisplayId;
                    break;
                }
            }

            if (!displayFound) {
            if (displayId == INVALID_DISPLAY) {
                ProtoLog.v(WM_DEBUG_TPL, "Skipping %s, no associated display %d", windowHandle.name,
                        windowHandle.displayId);
                continue;
            }

            Region coveredRegionsAbove = coveredRegionsAboveByDisplay.get(displayId, new Region());
            var listeners = mRegisteredListeners.get(windowHandle.getWindowToken());
            if (listeners != null) {
                Region region = new Region();
@@ -304,6 +307,7 @@ public class TrustedPresentationListenerController {
            }

            coveredRegionsAbove.op(tmpRect, Region.Op.UNION);
            coveredRegionsAboveByDisplay.put(displayId, coveredRegionsAbove);
            ProtoLog.v(WM_DEBUG_TPL, "coveredRegionsAbove updated with %s frame:%s region:%s",
                    windowHandle.name, tmpRect.toShortString(), coveredRegionsAbove);
        }