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

Commit 0ee0d7f5 authored by Chris Ye's avatar Chris Ye Committed by Winson Chung
Browse files

Change InputWindowInfo::isTrustedOverlay() to be permission and flag based am: 71633376

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15975848

Bug: 196389741
Change-Id: I3109c9cadb88297ec13751171b15410633bba03a
Merged-In: I70151697cc01e8427129f951f0ebadc4805b2d56
parents 377f1097 71633376
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;
+21 −9
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,12 @@ 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;
      
        /**
         * Flag to indicate that the parent frame of a window should be inset by IME.
         * @hide
@@ -2946,6 +2944,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);
            }
@@ -274,7 +275,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);
            }
@@ -445,12 +446,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
+4 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ static struct {
    jfieldID hasFocus;
    jfieldID hasWallpaper;
    jfieldID paused;
    jfieldID trustedOverlay;
    jfieldID ownerPid;
    jfieldID ownerUid;
    jfieldID inputFeatures;
@@ -151,6 +152,7 @@ bool NativeInputWindowHandle::updateInfo() {
            gInputWindowHandleClassInfo.hasWallpaper);
    mInfo.paused = env->GetBooleanField(obj,
            gInputWindowHandleClassInfo.paused);
    mInfo.trustedOverlay = env->GetBooleanField(obj, gInputWindowHandleClassInfo.trustedOverlay);
    mInfo.ownerPid = env->GetIntField(obj,
            gInputWindowHandleClassInfo.ownerPid);
    mInfo.ownerUid = env->GetIntField(obj,
@@ -329,6 +331,8 @@ int register_android_view_InputWindowHandle(JNIEnv* env) {
    GET_FIELD_ID(gInputWindowHandleClassInfo.paused, clazz,
            "paused", "Z");

    GET_FIELD_ID(gInputWindowHandleClassInfo.trustedOverlay, clazz, "trustedOverlay", "Z");

    GET_FIELD_ID(gInputWindowHandleClassInfo.ownerPid, clazz,
            "ownerPid", "I");

Loading