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

Commit 37522072 authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge changes I22e22050,Ie278f678

* changes:
  WM/SurfacePackage: Forward insets to WindowContainer overlays
  Reland "SurfaceControlViewHost: Restrict disclosure of input token""
parents f214e0d9 b41528c5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.view;

import android.content.res.Configuration;
import android.graphics.Rect;
import android.view.InsetsState;

/**
 * API from content embedder back to embedded content in SurfaceControlViewHost
@@ -25,4 +27,5 @@ import android.content.res.Configuration;
oneway interface ISurfaceControlViewHost {
    void onConfigurationChanged(in Configuration newConfig);
    void onDispatchDetachedFromWindow();
    void onInsetsChanged(in InsetsState state, in Rect insetFrame);
}
+1 −1
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ interface IWindowSession {
    */
    void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
            in IBinder hostInputToken, int flags, int privateFlags, int type,
            out InputChannel outInputChannel);
            in IBinder focusGrantToken, out InputChannel outInputChannel);

    /**
     * Update the flags on an input channel associated with a particular surface.
+13 −1
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ import android.annotation.TestApi;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.accessibility.IAccessibilityEmbeddedConnection;
import android.view.InsetsState;

import java.util.Objects;

@@ -71,6 +73,16 @@ public class SurfaceControlViewHost {
                release();
            });
        }

        @Override
        public void onInsetsChanged(InsetsState state, Rect frame) {
            if (mViewRoot != null) {
                mViewRoot.mHandler.post(() -> {
                    mViewRoot.setOverrideInsetsFrame(frame);
                });
            }
            mWm.setInsetsState(state);
        }
    }

    private ISurfaceControlViewHost mRemoteInterface = new ISurfaceControlViewHostImpl();
@@ -274,7 +286,7 @@ public class SurfaceControlViewHost {
    public @Nullable SurfacePackage getSurfacePackage() {
        if (mSurfaceControl != null && mAccessibilityEmbeddedConnection != null) {
            return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection,
                mViewRoot.getInputToken(), mRemoteInterface);
                mWm.getFocusGrantToken(), mRemoteInterface);
        } else {
            return null;
        }
+17 −1
Original line number Diff line number Diff line
@@ -643,6 +643,7 @@ public final class ViewRootImpl implements ViewParent,

    // These are accessed by multiple threads.
    final Rect mWinFrame; // frame given by window manager.
    Rect mOverrideInsetsFrame;

    final Rect mPendingBackDropFrame = new Rect();

@@ -8069,7 +8070,22 @@ public final class ViewRootImpl implements ViewParent,

    private void setFrame(Rect frame) {
        mWinFrame.set(frame);
        mInsetsController.onFrameChanged(frame);
        mInsetsController.onFrameChanged(mOverrideInsetsFrame != null ?
            mOverrideInsetsFrame : frame);
    }

    /**
     * In the normal course of operations we compute insets relative to
     * the frame returned from relayout window. In the case of
     * SurfaceControlViewHost, this frame is in local coordinates
     * instead of global coordinates. We support this override
     * frame so we can allow SurfaceControlViewHost to set a frame
     * to be used to calculate insets, without disturbing the main
     * mFrame.
     */
    void setOverrideInsetsFrame(Rect frame) {
        mOverrideInsetsFrame = new Rect(frame);
        mInsetsController.onFrameChanged(mOverrideInsetsFrame);
    }

    /**
+31 −5
Original line number Diff line number Diff line
@@ -21,11 +21,14 @@ import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.util.Log;
import android.util.MergedConfiguration;
import android.view.InsetsState;
import android.view.IWindow;
import android.window.ClientWindowFrames;
import android.window.IOnBackInvokedCallback;

@@ -48,12 +51,14 @@ public class WindowlessWindowManager implements IWindowSession {
        int mDisplayId;
        IBinder mInputChannelToken;
        Region mInputRegion;
        IWindow mClient;
        State(SurfaceControl sc, WindowManager.LayoutParams p, int displayId,
                IBinder inputChannelToken) {
              IBinder inputChannelToken, IWindow client) {
            mSurfaceControl = sc;
            mParams.copyFrom(p);
            mDisplayId = displayId;
            mInputChannelToken = inputChannelToken;
            mClient = client;
        }
    };

@@ -75,6 +80,8 @@ public class WindowlessWindowManager implements IWindowSession {
    private final Configuration mConfiguration;
    private final IWindowSession mRealWm;
    private final IBinder mHostInputToken;
    private final IBinder mFocusGrantToken = new Binder();
    private InsetsState mInsetsState;

    private int mForceHeight = -1;
    private int mForceWidth = -1;
@@ -91,6 +98,10 @@ public class WindowlessWindowManager implements IWindowSession {
        mConfiguration.setTo(configuration);
    }

    IBinder getFocusGrantToken() {
        return mFocusGrantToken;
    }

    /**
     * Utility API.
     */
@@ -153,10 +164,10 @@ public class WindowlessWindowManager implements IWindowSession {
                    mRealWm.grantInputChannel(displayId,
                        new SurfaceControl(sc, "WindowlessWindowManager.addToDisplay"),
                        window, mHostInputToken, attrs.flags, attrs.privateFlags, attrs.type,
                        outInputChannel);
                        mFocusGrantToken, outInputChannel);
                } else {
                    mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, attrs.flags,
                        attrs.privateFlags, attrs.type, outInputChannel);
                        attrs.privateFlags, attrs.type, mFocusGrantToken, outInputChannel);
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to grant input to surface: ", e);
@@ -164,7 +175,7 @@ public class WindowlessWindowManager implements IWindowSession {
        }

        final State state = new State(sc, attrs, displayId,
                outInputChannel != null ? outInputChannel.getToken() : null);
            outInputChannel != null ? outInputChannel.getToken() : null, window);
        synchronized (this) {
            mStateForWindow.put(window.asBinder(), state);
        }
@@ -312,6 +323,10 @@ public class WindowlessWindowManager implements IWindowSession {
            }
        }

        if (mInsetsState != null) {
            outInsetsState.set(mInsetsState);
        }

        // Include whether the window is in touch mode.
        return isInTouchMode() ? WindowManagerGlobal.RELAYOUT_RES_IN_TOUCH_MODE : 0;
    }
@@ -469,7 +484,7 @@ public class WindowlessWindowManager implements IWindowSession {

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

@@ -501,4 +516,15 @@ public class WindowlessWindowManager implements IWindowSession {
    public boolean dropForAccessibility(IWindow window, int x, int y) {
        return false;
    }

    public void setInsetsState(InsetsState state) {
        mInsetsState = state;
        for (State s : mStateForWindow.values()) {
            try {
                s.mClient.insetsChanged(state, false, false);
            } catch (RemoteException e) {
                // Too bad
            }
        }
    }
}
Loading