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

Commit ed187ae6 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Pass through some input-related layout flags for windowless surfaces"

parents aeacd548 680377e1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4979,6 +4979,11 @@ package android.view {
    method public abstract String asyncImpl() default "";
  }

  public class SurfaceControlViewHost {
    method public void addView(@NonNull android.view.View, android.view.WindowManager.LayoutParams);
    method public void relayout(android.view.WindowManager.LayoutParams);
  }

  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
    method public android.view.View getTooltipView();
    method public boolean isAutofilled();
+7 −1
Original line number Diff line number Diff line
@@ -318,5 +318,11 @@ interface IWindowSession {
    * an input channel where the client can receive input.
    */
    void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
            in IBinder hostInputToken, out InputChannel outInputChannel);
            in IBinder hostInputToken, int flags, 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);
}
+2 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ public class SurfaceControlViewHost {
    /**
     * @hide
     */
    @TestApi
    public void addView(@NonNull View view, WindowManager.LayoutParams attrs) {
        mViewRoot.setView(view, attrs, null);
    }
@@ -161,6 +162,7 @@ public class SurfaceControlViewHost {
    /**
     * @hide
     */
    @TestApi
    public void relayout(WindowManager.LayoutParams attrs) {
        mViewRoot.setLayoutParams(attrs, false);
        mViewRoot.setReportNextDraw();
+34 −9
Original line number Diff line number Diff line
@@ -41,9 +41,14 @@ public class WindowlessWindowManager implements IWindowSession {
    private class State {
        SurfaceControl mSurfaceControl;
        WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
        State(SurfaceControl sc, WindowManager.LayoutParams p) {
        int mDisplayId;
        IBinder mInputChannelToken;
        State(SurfaceControl sc, WindowManager.LayoutParams p, int displayId,
                IBinder inputChannelToken) {
            mSurfaceControl = sc;
            mParams.copyFrom(p);
            mDisplayId = displayId;
            mInputChannelToken = inputChannelToken;
        }
    };

@@ -105,19 +110,23 @@ public class WindowlessWindowManager implements IWindowSession {
                .setFormat(attrs.format)
                .setName(attrs.getTitle().toString());
        final SurfaceControl sc = b.build();
        synchronized (this) {
            mStateForWindow.put(window.asBinder(), new State(sc, attrs));
        }

        if (((attrs.inputFeatures &
                WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0)) {
            try {
                mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, outInputChannel);
                mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, attrs.flags,
                        outInputChannel);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to bless surface: " + e);
                Log.e(TAG, "Failed to grant input to surface: ", e);
            }
        }

        final State state = new State(sc, attrs, displayId,
                outInputChannel != null ? outInputChannel.getToken() : null);
        synchronized (this) {
            mStateForWindow.put(window.asBinder(), state);
        }

        return WindowManagerGlobal.ADD_OKAY | WindowManagerGlobal.ADD_FLAG_APP_VISIBLE;
    }

@@ -162,7 +171,7 @@ public class WindowlessWindowManager implements IWindowSession {
            DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration,
            SurfaceControl outSurfaceControl, InsetsState outInsetsState,
            Point outSurfaceSize, SurfaceControl outBLASTSurfaceControl) {
        State state = null;
        final State state;
        synchronized (this) {
            state = mStateForWindow.get(window.asBinder());
        }
@@ -173,8 +182,9 @@ public class WindowlessWindowManager implements IWindowSession {
        SurfaceControl sc = state.mSurfaceControl;
        SurfaceControl.Transaction t = new SurfaceControl.Transaction();

        int attrChanges = 0;
        if (inAttrs != null) {
            state.mParams.copyFrom(inAttrs);
            attrChanges = state.mParams.copyFrom(inAttrs);
        }
        WindowManager.LayoutParams attrs = state.mParams;

@@ -197,6 +207,16 @@ public class WindowlessWindowManager implements IWindowSession {

        mergedConfiguration.setConfiguration(mConfiguration, mConfiguration);

        if ((attrChanges & WindowManager.LayoutParams.FLAGS_CHANGED) != 0
                && state.mInputChannelToken != null) {
            try {
                mRealWm.updateInputChannel(state.mInputChannelToken, state.mDisplayId, sc,
                        attrs.flags);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to update surface input channel: ", e);
            }
        }

        return 0;
    }

@@ -353,7 +373,12 @@ public class WindowlessWindowManager implements IWindowSession {

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

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

    @Override
+30 −12
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ package com.android.server.wm;
import android.annotation.Nullable;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.view.IWindow;
import android.view.InputApplicationHandle;

/**
 * Keeps track of embedded windows.
@@ -44,21 +46,12 @@ class EmbeddedWindowController {
     *
     * @param inputToken input channel token passed in by the embedding process when it requests
     *                   the server to add an input channel to the embedded surface.
     * @param window     client token used to clean up the map if the embedding process dies
     * @param hostWindowState input channel token belonging to the host window. This is needed to
     *                        handle input callbacks to wm. It's used when raising ANR and when
     *                        the user taps out side of the focused region on screen. This can be
     *                        null if there is no host window.
     * @param ownerUid  calling uid
     * @param ownerPid  calling pid used for anr blaming
     * @param embeddedWindow An {@link EmbeddedWindow} object to add to this controller.
     */
    void add(IBinder inputToken, IWindow window, @Nullable WindowState hostWindowState,
            int ownerUid, int ownerPid) {
        EmbeddedWindow embeddedWindow = new EmbeddedWindow(window, hostWindowState, ownerUid,
                ownerPid);
    void add(IBinder inputToken, EmbeddedWindow embeddedWindow) {
        try {
            mWindows.put(inputToken, embeddedWindow);
            window.asBinder().linkToDeath(()-> {
            embeddedWindow.mClient.asBinder().linkToDeath(()-> {
                synchronized (mWmLock) {
                    mWindows.remove(inputToken);
                }
@@ -101,6 +94,15 @@ class EmbeddedWindowController {
        final int mOwnerUid;
        final int mOwnerPid;

        /**
         * @param clientToken client token used to clean up the map if the embedding process dies
         * @param hostWindowState input channel token belonging to the host window. This is needed
         *                        to handle input callbacks to wm. It's used when raising ANR and
         *                        when the user taps out side of the focused region on screen. This
         *                        can be null if there is no host window.
         * @param ownerUid  calling uid
         * @param ownerPid  calling pid used for anr blaming
         */
        EmbeddedWindow(IWindow clientToken, WindowState hostWindowState, int ownerUid,
                int ownerPid) {
            mClient = clientToken;
@@ -108,5 +110,21 @@ class EmbeddedWindowController {
            mOwnerUid = ownerUid;
            mOwnerPid = ownerPid;
        }

        String getName() {
            final String hostWindowName = (mHostWindowState != null)
                    ? mHostWindowState.getWindowTag().toString() : "Internal";
            return "EmbeddedWindow{ u" + UserHandle.getUserId(mOwnerUid) + " " + hostWindowName
                    + "}";
        }

        InputApplicationHandle getApplicationHandle() {
            if (mHostWindowState == null
                    || mHostWindowState.mInputWindowHandle.inputApplicationHandle == null) {
                return null;
            }
            return new InputApplicationHandle(
                    mHostWindowState.mInputWindowHandle.inputApplicationHandle);
        }
    }
}
Loading