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

Commit a28d78a5 authored by Nergi Rahardi's avatar Nergi Rahardi Committed by Android (Google) Code Review
Browse files

Merge "Adds a new flag to toggle OverlayDisplayWindow interactability" into main

parents fc16110c a3f984ca
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -130,6 +130,14 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
    private static final String OVERLAY_DISPLAY_FLAG_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.
    private static final String GRAVITY_TOP_LEFT = "gravity_top_left";
    private static final String GRAVITY_BOTTOM_RIGHT = "gravity_bottom_right";
@@ -571,9 +579,9 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
            @Override
            public void run() {
                OverlayMode mode = mModes.get(mActiveMode);
                OverlayDisplayWindow window = new OverlayDisplayWindow(getContext(),
                        mName, mode.mWidth, mode.mHeight, mode.mDensityDpi, mGravity,
                        mFlags.mSecure, OverlayDisplayHandle.this);
                OverlayDisplayWindow window = new OverlayDisplayWindow(getContext(), mName,
                        mode.mWidth, mode.mHeight, mode.mDensityDpi, mGravity, mFlags.mSecure,
                        mFlags.mDisableWindowInteraction, OverlayDisplayHandle.this);
                window.show();

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

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

        final int mGravity;

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

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

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

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

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

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

        mDisplayManager = (DisplayManager)context.getSystemService(
@@ -226,8 +227,10 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
        if (mSecure) {
            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.privateFlags |=
                    WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
        }
        mWindowParams.privateFlags |=
                WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;