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

Commit 0a830818 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Change Input to use IBinder intead of IWindow for client token.

There's no need for Input to use IWindow object since it's not use the
interface and just using it as a pure client token. Change the system
server code so it accepts an IBinder object instead of IWindow so more
generic tokens can be used to create InputChannels.

Test: Input works
Bug: 278757236
Change-Id: I8eaa0832a9b70818a94ee3e21b7f3269456af9a2
parent 8ff62994
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -296,9 +296,11 @@ interface IWindowSession {

    /**
    * Request the server to call setInputWindowInfo on a given Surface, and return
    * an input channel where the client can receive input.
    * an input channel where the client can receive input. For windows, the clientToken should be
    * the IWindow binder object. For other requests, the token can be any unique IBinder token to
    * be used as unique identifier.
    */
    void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
    void grantInputChannel(int displayId, in SurfaceControl surface, in IBinder clientToken,
            in IBinder hostInputToken, int flags, int privateFlags, int inputFeatures, int type,
            in IBinder windowToken, in IBinder focusGrantToken, String inputHandleName,
            out InputChannel outInputChannel);
+4 −18
Original line number Diff line number Diff line
@@ -82,15 +82,11 @@ public final class InputWindowHandle {
    public IBinder token;

    /**
     * The {@link IWindow} handle if InputWindowHandle is associated with a window, null otherwise.
     * The {@link IBinder} handle if InputWindowHandle is associated with a client token,
     * normally the IWindow token, null otherwise.
     */
    @Nullable
    private IBinder windowToken;
    /**
     * Used to cache IWindow from the windowToken so we don't need to convert every time getWindow
     * is called.
     */
    private IWindow window;

    // The window name.
    public String name;
@@ -177,7 +173,6 @@ public final class InputWindowHandle {
        inputApplicationHandle = new InputApplicationHandle(other.inputApplicationHandle);
        token = other.token;
        windowToken = other.windowToken;
        window = other.window;
        name = other.name;
        layoutParamsFlags = other.layoutParamsFlags;
        layoutParamsType = other.layoutParamsType;
@@ -243,23 +238,14 @@ public final class InputWindowHandle {
        touchableRegionSurfaceControl = new WeakReference<>(bounds);
    }

    public void setWindowToken(IWindow iwindow) {
        windowToken = iwindow.asBinder();
        window = iwindow;
    public void setWindowToken(IBinder iwindow) {
        windowToken = iwindow;
    }

    public @Nullable IBinder getWindowToken() {
        return windowToken;
    }

    public IWindow getWindow() {
        if (window != null) {
            return window;
        }
        window = IWindow.Stub.asInterface(windowToken);
        return window;
    }

    /**
     * Set the provided inputConfig flag values.
     * @param inputConfig the flag values to change
+5 −5
Original line number Diff line number Diff line
@@ -228,14 +228,14 @@ public class WindowlessWindowManager implements IWindowSession {
                if (mRealWm instanceof IWindowSession.Stub) {
                    mRealWm.grantInputChannel(displayId,
                            new SurfaceControl(sc, "WindowlessWindowManager.addToDisplay"),
                            window, mHostInputToken, attrs.flags, attrs.privateFlags,
                            window.asBinder(), mHostInputToken, attrs.flags, attrs.privateFlags,
                            attrs.inputFeatures, attrs.type,
                            attrs.token, state.mInputTransferToken, attrs.getTitle().toString(),
                            outInputChannel);
                } else {
                    mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, attrs.flags,
                            attrs.privateFlags, attrs.inputFeatures, attrs.type, attrs.token,
                            state.mInputTransferToken, attrs.getTitle().toString(),
                    mRealWm.grantInputChannel(displayId, sc, window.asBinder(), mHostInputToken,
                            attrs.flags, attrs.privateFlags, attrs.inputFeatures, attrs.type,
                            attrs.token, state.mInputTransferToken, attrs.getTitle().toString(),
                            outInputChannel);
                }
                state.mInputChannelToken =
@@ -593,7 +593,7 @@ public class WindowlessWindowManager implements IWindowSession {
            List<Rect> unrestrictedRects) {}

    @Override
    public void grantInputChannel(int displayId, SurfaceControl surface, IWindow window,
    public void grantInputChannel(int displayId, SurfaceControl surface, IBinder clientToken,
            IBinder hostInputToken, int flags, int privateFlags, int inputFeatures, int type,
            IBinder windowToken, IBinder focusGrantToken, String inputHandleName,
            InputChannel outInputChannel) {
+2 −2
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class DragResizeInputListener implements AutoCloseable {
            mWindowSession.grantInputChannel(
                    mDisplayId,
                    mDecorationSurface,
                    mFakeWindow,
                    mFakeWindow.asBinder(),
                    null /* hostInputToken */,
                    FLAG_NOT_FOCUSABLE,
                    PRIVATE_FLAG_TRUSTED_OVERLAY,
@@ -155,7 +155,7 @@ class DragResizeInputListener implements AutoCloseable {
            mWindowSession.grantInputChannel(
                    mDisplayId,
                    mInputSinkSurface,
                    mFakeSinkWindow,
                    mFakeSinkWindow.asBinder(),
                    null /* hostInputToken */,
                    FLAG_NOT_FOCUSABLE,
                    0 /* privateFlags */,
+1 −1
Original line number Diff line number Diff line
@@ -558,7 +558,7 @@ final class AccessibilityController {
        }
        if (newTarget != null) {
            int displayId = newTarget.getDisplayId();
            IBinder clientBinder = newTarget.getIWindow().asBinder();
            IBinder clientBinder = newTarget.getWindowToken();
            mFocusedWindow.put(displayId, clientBinder);
        }
    }
Loading