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

Commit e823afc2 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Use CanOccludePresentation state to calculate TrustedPresentationThresholds

Switch from window token to using CanOccludePresentation state to calculate
TrustedPresentationThresholds. All app windows should have this flag set. If the
window is transient, and is a system window like Toast or notification shade,
the window should not set this flag since the user or the app cannot use the
window to occlude content in a persistent manner.

Test: presubmit
Bug: b/275574214
Change-Id: Icc9b2ef19ae0c9cdc54afd643669b6154d8ad90e
parent 896f3a25
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.os.HandlerThread;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.IntArray;
import android.util.Pair;
import android.util.Size;
@@ -159,10 +158,6 @@ public class TrustedPresentationListenerController {

    private InputWindowHandle[] mLastWindowHandles;

    private final Object mIgnoredWindowTokensLock = new Object();

    private final ArraySet<IBinder> mIgnoredWindowTokens = new ArraySet<>();

    private void startHandlerThreadIfNeeded() {
        synchronized (mHandlerThreadLock) {
            if (mHandler == null) {
@@ -173,18 +168,6 @@ public class TrustedPresentationListenerController {
        }
    }

    void addIgnoredWindowTokens(IBinder token) {
        synchronized (mIgnoredWindowTokensLock) {
            mIgnoredWindowTokens.add(token);
        }
    }

    void removeIgnoredWindowTokens(IBinder token) {
        synchronized (mIgnoredWindowTokensLock) {
            mIgnoredWindowTokens.remove(token);
        }
    }

    void registerListener(IBinder window, ITrustedPresentationListener listener,
            TrustedPresentationThresholds thresholds, int id) {
        startHandlerThreadIfNeeded();
@@ -271,12 +254,8 @@ public class TrustedPresentationListenerController {

        ArrayMap<ITrustedPresentationListener, Pair<IntArray, IntArray>> listenerUpdates =
                new ArrayMap<>();
        ArraySet<IBinder> ignoredWindowTokens;
        synchronized (mIgnoredWindowTokensLock) {
            ignoredWindowTokens = new ArraySet<>(mIgnoredWindowTokens);
        }
        for (var windowHandle : mLastWindowHandles) {
            if (ignoredWindowTokens.contains(windowHandle.getWindowToken())) {
            if (!windowHandle.canOccludePresentation) {
                ProtoLog.v(WM_DEBUG_TPL, "Skipping %s", windowHandle.name);
                continue;
            }
+3 −7
Original line number Diff line number Diff line
@@ -1148,10 +1148,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            parentWindow.addChild(this, sWindowSubLayerComparator);
        }

        if (token.mRoundedCornerOverlay) {
            mWmService.mTrustedPresentationListenerController.addIgnoredWindowTokens(
                    getWindowToken());
        }
    }

    @Override
@@ -1163,6 +1159,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        if (secureWindowState()) {
            getPendingTransaction().setSecure(mSurfaceControl, isSecureLocked());
        }
        // All apps should be considered as occluding when computing TrustedPresentation Thresholds.
        final boolean canOccludePresentation = !mSession.mCanAddInternalSystemWindow;
        getPendingTransaction().setCanOccludePresentation(mSurfaceControl, canOccludePresentation);
    }

    void updateTrustedOverlay() {
@@ -2344,9 +2343,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mSession.onWindowRemoved(this);
        mWmService.postWindowRemoveCleanupLocked(this);

        mWmService.mTrustedPresentationListenerController.removeIgnoredWindowTokens(
                getWindowToken());

        consumeInsetsChange();
    }

+6 −0
Original line number Diff line number Diff line
@@ -320,4 +320,10 @@ public class StubTransaction extends SurfaceControl.Transaction {
        mWindowInfosReportedListeners.add(listener);
        return this;
    }

    @Override
    public SurfaceControl.Transaction setCanOccludePresentation(SurfaceControl sc,
                boolean canOccludePresentation) {
        return this;
    }
}