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

Commit a3f984ca authored by nergi's avatar nergi
Browse files

Adds a new flag to toggle OverlayDisplayWindow interactability

Currently, OverlayDisplayWindow is treated as a system overlay and will
block any touch going through it. In default display, this will obstruct
testing process as apps will be behind the overlay.

The new flag is an extension of an existing DISABLE_MOVE_AND_RESIZE
constant in OverlayDisplayWindow.

Doc: go/connected-displays-overlay-display-testing

Bug: 402671705
Test: Manual test + presubmit
Flag: EXEMPT adding a new dev-only flag
Change-Id: I5e9ae96258088b9b9cd8f5de393d4c0a7d94424c
parent ab631004
Loading
Loading
Loading
Loading
+22 −4
Original line number Original line Diff line number Diff line
@@ -130,6 +130,14 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
    private static final String OVERLAY_DISPLAY_FLAG_FIXED_CONTENT_MODE =
    private static final String OVERLAY_DISPLAY_FLAG_FIXED_CONTENT_MODE =
            "fixed_content_mode";
            "fixed_content_mode";


    /**
     * When this flag is set, disables support for moving and resizing the overlay window.
     * As the window is made non-touchable, this also makes it possible to directly interact with
     * the content underneath.
     */
    private static final String OVERLAY_DISPLAY_FLAG_DISABLE_WINDOW_INTERACTION =
            "disable_window_interaction";

    // Gravity flags to decide where the overlay should be shown.
    // Gravity flags to decide where the overlay should be shown.
    private static final String GRAVITY_TOP_LEFT = "gravity_top_left";
    private static final String GRAVITY_TOP_LEFT = "gravity_top_left";
    private static final String GRAVITY_BOTTOM_RIGHT = "gravity_bottom_right";
    private static final String GRAVITY_BOTTOM_RIGHT = "gravity_bottom_right";
@@ -571,9 +579,9 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
            @Override
            @Override
            public void run() {
            public void run() {
                OverlayMode mode = mModes.get(mActiveMode);
                OverlayMode mode = mModes.get(mActiveMode);
                OverlayDisplayWindow window = new OverlayDisplayWindow(getContext(),
                OverlayDisplayWindow window = new OverlayDisplayWindow(getContext(), mName,
                        mName, mode.mWidth, mode.mHeight, mode.mDensityDpi, mGravity,
                        mode.mWidth, mode.mHeight, mode.mDensityDpi, mGravity, mFlags.mSecure,
                        mFlags.mSecure, OverlayDisplayHandle.this);
                        mFlags.mDisableWindowInteraction, OverlayDisplayHandle.this);
                window.show();
                window.show();


                synchronized (getSyncRoot()) {
                synchronized (getSyncRoot()) {
@@ -655,6 +663,9 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
        /** See {@link #OVERLAY_DISPLAY_FLAG_FIXED_CONTENT_MODE}. */
        /** See {@link #OVERLAY_DISPLAY_FLAG_FIXED_CONTENT_MODE}. */
        final boolean mFixedContentMode;
        final boolean mFixedContentMode;


        /** See {@link #OVERLAY_DISPLAY_FLAG_DISABLE_WINDOW_INTERACTION}. */
        final boolean mDisableWindowInteraction;

        final int mGravity;
        final int mGravity;


        OverlayFlags(
        OverlayFlags(
@@ -662,11 +673,13 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
                boolean ownContentOnly,
                boolean ownContentOnly,
                boolean shouldShowSystemDecorations,
                boolean shouldShowSystemDecorations,
                boolean fixedContentMode,
                boolean fixedContentMode,
                boolean disableWindowInteraction,
                int gravity) {
                int gravity) {
            mSecure = secure;
            mSecure = secure;
            mOwnContentOnly = ownContentOnly;
            mOwnContentOnly = ownContentOnly;
            mShouldShowSystemDecorations = shouldShowSystemDecorations;
            mShouldShowSystemDecorations = shouldShowSystemDecorations;
            mFixedContentMode = fixedContentMode;
            mFixedContentMode = fixedContentMode;
            mDisableWindowInteraction = disableWindowInteraction;
            mGravity = gravity;
            mGravity = gravity;
        }
        }


@@ -677,6 +690,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
                        false /* ownContentOnly */,
                        false /* ownContentOnly */,
                        false /* shouldShowSystemDecorations */,
                        false /* shouldShowSystemDecorations */,
                        false /* fixedContentMode */,
                        false /* fixedContentMode */,
                        false /* disableWindowInteraction */,
                        Gravity.NO_GRAVITY);
                        Gravity.NO_GRAVITY);
            }
            }


@@ -684,6 +698,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
            boolean ownContentOnly = false;
            boolean ownContentOnly = false;
            boolean shouldShowSystemDecorations = false;
            boolean shouldShowSystemDecorations = false;
            boolean fixedContentMode = false;
            boolean fixedContentMode = false;
            boolean disableWindowInteraction = false;
            int gravity = Gravity.NO_GRAVITY;
            int gravity = Gravity.NO_GRAVITY;
            for (String flag: flagString.split(FLAG_SPLITTER)) {
            for (String flag: flagString.split(FLAG_SPLITTER)) {
                if (OVERLAY_DISPLAY_FLAG_SECURE.equals(flag)) {
                if (OVERLAY_DISPLAY_FLAG_SECURE.equals(flag)) {
@@ -694,12 +709,14 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
                    shouldShowSystemDecorations = true;
                    shouldShowSystemDecorations = true;
                } else if (OVERLAY_DISPLAY_FLAG_FIXED_CONTENT_MODE.equals(flag)) {
                } else if (OVERLAY_DISPLAY_FLAG_FIXED_CONTENT_MODE.equals(flag)) {
                    fixedContentMode = true;
                    fixedContentMode = true;
                } else if (OVERLAY_DISPLAY_FLAG_DISABLE_WINDOW_INTERACTION.equals(flag)) {
                    disableWindowInteraction = true;
                } else {
                } else {
                    gravity = parseOverlayGravity(flag);
                    gravity = parseOverlayGravity(flag);
                }
                }
            }
            }
            return new OverlayFlags(secure, ownContentOnly, shouldShowSystemDecorations,
            return new OverlayFlags(secure, ownContentOnly, shouldShowSystemDecorations,
                    fixedContentMode, gravity);
                    fixedContentMode, disableWindowInteraction, gravity);
        }
        }


        @Override
        @Override
@@ -709,6 +726,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
                    .append(", ownContentOnly=").append(mOwnContentOnly)
                    .append(", ownContentOnly=").append(mOwnContentOnly)
                    .append(", shouldShowSystemDecorations=").append(mShouldShowSystemDecorations)
                    .append(", shouldShowSystemDecorations=").append(mShouldShowSystemDecorations)
                    .append(", fixedContentMode=").append(mFixedContentMode)
                    .append(", fixedContentMode=").append(mFixedContentMode)
                    .append(", disableWindowInteraction=").append(mDisableWindowInteraction)
                    .append(", gravity").append(Gravity.toString(mGravity))
                    .append(", gravity").append(Gravity.toString(mGravity))
                    .append("}")
                    .append("}")
                    .toString();
                    .toString();
+7 −4
Original line number Original line Diff line number Diff line
@@ -69,6 +69,7 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
    private int mDensityDpi;
    private int mDensityDpi;
    private final int mGravity;
    private final int mGravity;
    private final boolean mSecure;
    private final boolean mSecure;
    private final boolean mDisableWindowInteraction;
    private final Listener mListener;
    private final Listener mListener;
    private String mTitle;
    private String mTitle;


@@ -96,15 +97,15 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
    private float mLiveTranslationY;
    private float mLiveTranslationY;
    private float mLiveScale = 1.0f;
    private float mLiveScale = 1.0f;


    public OverlayDisplayWindow(Context context, String name,
    OverlayDisplayWindow(Context context, String name, int width, int height, int densityDpi,
            int width, int height, int densityDpi, int gravity, boolean secure,
            int gravity, boolean secure, boolean disableWindowInteraction, Listener listener) {
            Listener listener) {
        // Workaround device freeze (b/38372997)
        // Workaround device freeze (b/38372997)
        ThreadedRenderer.disableVsync();
        ThreadedRenderer.disableVsync();
        mContext = context;
        mContext = context;
        mName = name;
        mName = name;
        mGravity = gravity;
        mGravity = gravity;
        mSecure = secure;
        mSecure = secure;
        mDisableWindowInteraction = disableWindowInteraction;
        mListener = listener;
        mListener = listener;


        mDisplayManager = (DisplayManager)context.getSystemService(
        mDisplayManager = (DisplayManager)context.getSystemService(
@@ -226,8 +227,10 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
        if (mSecure) {
        if (mSecure) {
            mWindowParams.flags |= WindowManager.LayoutParams.FLAG_SECURE;
            mWindowParams.flags |= WindowManager.LayoutParams.FLAG_SECURE;
        }
        }
        if (DISABLE_MOVE_AND_RESIZE) {
        if (DISABLE_MOVE_AND_RESIZE || mDisableWindowInteraction) {
            mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            mWindowParams.privateFlags |=
                    WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
        }
        }
        mWindowParams.privateFlags |=
        mWindowParams.privateFlags |=
                WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
                WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;