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

Commit 08ad2e5d authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce unnecessary surface operation of setting trusted overlay

It only needs to update at surface creation or the related attributes
are changed, rather than setting on every frame.

Bug: 303982379
Test: TrustedOverlayTests
Change-Id: Iaafff343dbf4ce95d312d5efc23c78b92dc2343f
parent 437b648e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ class InputConsumerImpl implements IBinder.DeathRecipient {
    private final Rect mOldWindowCrop = new Rect();

    InputConsumerImpl(WindowManagerService service, IBinder token, String name,
            InputChannel inputChannel, int clientPid, UserHandle clientUser, int displayId) {
            InputChannel inputChannel, int clientPid, UserHandle clientUser, int displayId,
            SurfaceControl.Transaction t) {
        mService = service;
        mToken = token;
        mName = name;
@@ -82,6 +83,7 @@ class InputConsumerImpl implements IBinder.DeathRecipient {
                .setName("Input Consumer " + name)
                .setCallsite("InputConsumerImpl")
                .build();
        mWindowHandle.setTrustedOverlay(t, mInputSurface, true);
    }

    void linkToDeathRecipient() {
@@ -129,14 +131,12 @@ class InputConsumerImpl implements IBinder.DeathRecipient {

    void show(SurfaceControl.Transaction t, WindowContainer w) {
        t.show(mInputSurface);
        mWindowHandle.setTrustedOverlay(t, mInputSurface, true);
        t.setInputWindowInfo(mInputSurface, mWindowHandle);
        t.setRelativeLayer(mInputSurface, w.getSurfaceControl(), 1);
    }

    void show(SurfaceControl.Transaction t, int layer) {
        t.show(mInputSurface);
        mWindowHandle.setTrustedOverlay(t, mInputSurface, true);
        t.setInputWindowInfo(mInputSurface, mWindowHandle);
        t.setLayer(mInputSurface, layer);
    }
+1 −6
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ final class InputMonitor {
        }

        final InputConsumerImpl consumer = new InputConsumerImpl(mService, token, name,
                inputChannel, clientPid, clientUser, mDisplayId);
                inputChannel, clientPid, clientUser, mDisplayId, mInputTransaction);
        switch (name) {
            case INPUT_CONSUMER_WALLPAPER:
                consumer.mWindowHandle.inputConfig |= InputConfig.DUPLICATE_TOUCH_TO_WALLPAPER;
@@ -675,11 +675,6 @@ final class InputMonitor {
                    w.getKeyInterceptionInfo());

            if (w.mWinAnimator.hasSurface()) {
                // Update trusted overlay changes here because they are tied to input info. Input
                // changes can be updated even if surfaces aren't.
                inputWindowHandle.setTrustedOverlay(mInputTransaction,
                        w.mWinAnimator.mSurfaceController.mSurfaceControl,
                        w.isWindowTrustedOverlay());
                populateInputWindowHandle(inputWindowHandle, w);
                setInputWindowInfoIfNeeded(mInputTransaction,
                        w.mWinAnimator.mSurfaceController.mSurfaceControl, inputWindowHandle);
+4 −0
Original line number Diff line number Diff line
@@ -2251,6 +2251,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                }

                final boolean wasTrustedOverlay = win.isWindowTrustedOverlay();
                flagChanges = win.mAttrs.flags ^ attrs.flags;
                privateFlagChanges = win.mAttrs.privateFlags ^ attrs.privateFlags;
                attrChanges = win.mAttrs.copyFrom(attrs);
@@ -2263,6 +2264,9 @@ public class WindowManagerService extends IWindowManager.Stub
                if (layoutChanged && win.providesDisplayDecorInsets()) {
                    configChanged = displayPolicy.updateDecorInsetsInfo();
                }
                if (wasTrustedOverlay != win.isWindowTrustedOverlay()) {
                    win.updateTrustedOverlay();
                }
                if (win.mActivityRecord != null && ((flagChanges & FLAG_SHOW_WHEN_LOCKED) != 0
                        || (flagChanges & FLAG_DISMISS_KEYGUARD) != 0)) {
                    win.mActivityRecord.checkKeyguardFlagsChanged();
+14 −4
Original line number Diff line number Diff line
@@ -1188,7 +1188,20 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
    }

    public boolean isWindowTrustedOverlay() {
    @Override
    void setInitialSurfaceControlProperties(SurfaceControl.Builder b) {
        super.setInitialSurfaceControlProperties(b);
        if (surfaceTrustedOverlay() && isWindowTrustedOverlay()) {
            getPendingTransaction().setTrustedOverlay(mSurfaceControl, true);
        }
    }

    void updateTrustedOverlay() {
        mInputWindowHandle.setTrustedOverlay(getPendingTransaction(), mSurfaceControl,
                isWindowTrustedOverlay());
    }

    boolean isWindowTrustedOverlay() {
        return InputMonitor.isTrustedOverlay(mAttrs.type)
                || ((mAttrs.privateFlags & PRIVATE_FLAG_TRUSTED_OVERLAY) != 0
                        && mSession.mCanAddInternalSystemWindow)
@@ -5190,9 +5203,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            updateFrameRateSelectionPriorityIfNeeded();
            updateScaleIfNeeded();
            mWinAnimator.prepareSurfaceLocked(getSyncTransaction());
            if (surfaceTrustedOverlay()) {
                getSyncTransaction().setTrustedOverlay(mSurfaceControl, isWindowTrustedOverlay());
            }
        }
        super.prepareSurfaces();
    }