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

Commit 740da917 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Reduce unnecessary surface operation of setting trusted overlay" into main

parents d64b75d5 08ad2e5d
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
@@ -2261,6 +2261,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);
@@ -2273,6 +2274,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
@@ -1189,7 +1189,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)
@@ -5205,9 +5218,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            updateFrameRateSelectionPriorityIfNeeded();
            updateScaleIfNeeded();
            mWinAnimator.prepareSurfaceLocked(getSyncTransaction());
            if (surfaceTrustedOverlay()) {
                getSyncTransaction().setTrustedOverlay(mSurfaceControl, isWindowTrustedOverlay());
            }
        }
        super.prepareSurfaces();
    }