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

Commit 58c437f1 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge changes from topic "trusted_overlay_backport" into rvc-dev

* changes:
  DO NOT MERGE: Revert "Map TYPE_TRUSTED_APPLICATION_OVERLAY to system window type for A11y"
  Add mechanism for a task's windows to be trusted overlays
  Change InputWindowInfo::isTrustedOverlay() to be permission and flag based
parents c56d34c2 0cf0d420
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -336,11 +336,12 @@ interface IWindowSession {
    * an input channel where the client can receive input.
    */
    void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
            in IBinder hostInputToken, int flags, int type, out InputChannel outInputChannel);
            in IBinder hostInputToken, int flags, int privateFlags, int type,
            out InputChannel outInputChannel);

    /**
     * Update the flags on an input channel associated with a particular surface.
     */
    void updateInputChannel(in IBinder channelToken, int displayId, in SurfaceControl surface,
            int flags, in Region region);
            int flags, int privateFlags, in Region region);
}
+3 −0
Original line number Diff line number Diff line
@@ -82,6 +82,9 @@ public final class InputWindowHandle {
    // Input event dispatching is paused.
    public boolean paused;

    // Window is trusted overlay.
    public boolean trustedOverlay;

    // Id of process and user that owns the window.
    public int ownerPid;
    public int ownerUid;
+13 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ public final class SurfaceControl implements Parcelable {
            int blurRadius);
    private static native void nativeSetLayerStack(long transactionObj, long nativeObject,
            int layerStack);
    private static native void nativeSetTrustedOverlay(long transactionObj, long nativeObject,
            boolean isTrustedOverlay);

    private static native boolean nativeClearContentFrameStats(long nativeObject);
    private static native boolean nativeGetContentFrameStats(long nativeObject, WindowContentFrameStats outStats);
@@ -3037,6 +3039,17 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the
         * children. The caller must hold the ACCESS_SURFACE_FLINGER permission.
         * @hide
         */
        public Transaction setTrustedOverlay(SurfaceControl sc, boolean isTrustedOverlay) {
            checkPreconditions(sc);
            nativeSetTrustedOverlay(mNativeObject, sc.mNativeObject, isTrustedOverlay);
            return this;
        }

        /**
         * Merge the other transaction into this transaction, clearing the
         * other transaction as if it had been applied.
+19 −8
Original line number Diff line number Diff line
@@ -1216,14 +1216,6 @@ public interface WindowManager extends ViewManager {
         */
        public static final int TYPE_STATUS_BAR_ADDITIONAL = FIRST_SYSTEM_WINDOW + 41;

        /**
         * Similar to TYPE_APPLICATION_OVERLAY, but trusted to overlay other windows since it is
         * is coming from the system.
         * @hide
         */
        // TODO(b/155781676): Remove and replace call points with trustedOverlay when that is ready.
        public static final int TYPE_TRUSTED_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 42;

        /**
         * End of types of system windows.
         */
@@ -2032,6 +2024,11 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_FIT_INSETS_CONTROLLED = 0x10000000;

        /**
         * Flag to indicate that the window is a trusted overlay.
         * @hide
         */
        public static final int PRIVATE_FLAG_TRUSTED_OVERLAY = 0x20000000;
        /**
         * An internal annotation for flags that can be specified to {@link #softInputMode}.
         *
@@ -2940,6 +2937,20 @@ public interface WindowManager extends ViewManager {
            privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
        }

        /**
         * Specifies that the window should be considered a trusted system overlay. Trusted system
         * overlays are ignored when considering whether windows are obscured during input
         * dispatch. Requires the {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW}
         * permission.
         *
         * {@see android.view.MotionEvent#FLAG_WINDOW_IS_OBSCURED}
         * {@see android.view.MotionEvent#FLAG_WINDOW_IS_PARTIALLY_OBSCURED}
         * @hide
         */
        public void setTrustedOverlay() {
            privateFlags |= PRIVATE_FLAG_TRUSTED_OVERLAY;
        }

        /**
         * @return the insets types that this window is avoiding overlapping.
         */
+7 −5
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ public class WindowlessWindowManager implements IWindowSession {
            if (state.mInputChannelToken != null) {
                try {
                    mRealWm.updateInputChannel(state.mInputChannelToken, state.mDisplayId,
                            state.mSurfaceControl, state.mParams.flags, state.mInputRegion);
                            state.mSurfaceControl, state.mParams.flags, state.mParams.privateFlags,
                            state.mInputRegion);
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to update surface input channel: ", e);
                }
@@ -144,7 +145,7 @@ public class WindowlessWindowManager implements IWindowSession {
                WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0)) {
            try {
                mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, attrs.flags,
                        attrs.type, outInputChannel);
                        attrs.privateFlags, attrs.type, outInputChannel);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to grant input to surface: ", e);
            }
@@ -262,7 +263,7 @@ public class WindowlessWindowManager implements IWindowSession {
                && state.mInputChannelToken != null) {
            try {
                mRealWm.updateInputChannel(state.mInputChannelToken, state.mDisplayId, sc,
                        attrs.flags, state.mInputRegion);
                        attrs.flags, attrs.privateFlags, state.mInputRegion);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to update surface input channel: ", e);
            }
@@ -432,12 +433,13 @@ public class WindowlessWindowManager implements IWindowSession {

    @Override
    public void grantInputChannel(int displayId, SurfaceControl surface, IWindow window,
            IBinder hostInputToken, int flags, int type, InputChannel outInputChannel) {
            IBinder hostInputToken, int flags, int privateFlags, int type,
            InputChannel outInputChannel) {
    }

    @Override
    public void updateInputChannel(IBinder channelToken, int displayId, SurfaceControl surface,
            int flags, Region region) {
            int flags, int privateFlags, Region region) {
    }

    @Override
Loading