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

Commit b061b389 authored by Joseph Jang's avatar Joseph Jang
Browse files

Revert "SurfaceControlViewHost: Restrict disclosure of input token"

This reverts commit 131444d5.

Reason for revert: <Test break by b/216355943>

Change-Id: I172db29e4eebea9214d05fc1309abbc0c4487804
parent 131444d5
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -295,7 +295,7 @@ interface IWindowSession {
    */
    */
    void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
    void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
            in IBinder hostInputToken, int flags, int privateFlags, int type,
            in IBinder hostInputToken, int flags, int privateFlags, int type,
            in IBinder focusGrantToken, out InputChannel outInputChannel);
            out InputChannel outInputChannel);


    /**
    /**
     * Update the flags on an input channel associated with a particular surface.
     * Update the flags on an input channel associated with a particular surface.
+1 −1
Original line number Original line Diff line number Diff line
@@ -274,7 +274,7 @@ public class SurfaceControlViewHost {
    public @Nullable SurfacePackage getSurfacePackage() {
    public @Nullable SurfacePackage getSurfacePackage() {
        if (mSurfaceControl != null && mAccessibilityEmbeddedConnection != null) {
        if (mSurfaceControl != null && mAccessibilityEmbeddedConnection != null) {
            return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection,
            return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection,
                mWm.getFocusGrantToken(), mRemoteInterface);
                mViewRoot.getInputToken(), mRemoteInterface);
        } else {
        } else {
            return null;
            return null;
        }
        }
+3 −9
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
import android.os.Binder;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteCallback;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -76,7 +75,6 @@ public class WindowlessWindowManager implements IWindowSession {
    private final Configuration mConfiguration;
    private final Configuration mConfiguration;
    private final IWindowSession mRealWm;
    private final IWindowSession mRealWm;
    private final IBinder mHostInputToken;
    private final IBinder mHostInputToken;
    private final IBinder mFocusGrantToken = new Binder();


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


    IBinder getFocusGrantToken() {
        return mFocusGrantToken;
    }

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


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


+4 −31
Original line number Original line Diff line number Diff line
@@ -41,8 +41,6 @@ class EmbeddedWindowController {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "EmbeddedWindowController" : TAG_WM;
    private static final String TAG = TAG_WITH_CLASS_NAME ? "EmbeddedWindowController" : TAG_WM;
    /* maps input token to an embedded window */
    /* maps input token to an embedded window */
    private ArrayMap<IBinder /*input token */, EmbeddedWindow> mWindows = new ArrayMap<>();
    private ArrayMap<IBinder /*input token */, EmbeddedWindow> mWindows = new ArrayMap<>();
    private ArrayMap<IBinder /*focus grant token */, EmbeddedWindow> mWindowsByFocusToken =
        new ArrayMap<>();
    private final Object mGlobalLock;
    private final Object mGlobalLock;
    private final ActivityTaskManagerService mAtmService;
    private final ActivityTaskManagerService mAtmService;


@@ -61,13 +59,10 @@ class EmbeddedWindowController {
    void add(IBinder inputToken, EmbeddedWindow window) {
    void add(IBinder inputToken, EmbeddedWindow window) {
        try {
        try {
            mWindows.put(inputToken, window);
            mWindows.put(inputToken, window);
            final IBinder focusToken = window.getFocusGrantToken();
            mWindowsByFocusToken.put(focusToken, window);
            updateProcessController(window);
            updateProcessController(window);
            window.mClient.asBinder().linkToDeath(()-> {
            window.mClient.asBinder().linkToDeath(()-> {
                synchronized (mGlobalLock) {
                synchronized (mGlobalLock) {
                    mWindows.remove(inputToken);
                    mWindows.remove(inputToken);
                    mWindowsByFocusToken.remove(focusToken);
                }
                }
            }, 0);
            }, 0);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
@@ -112,10 +107,8 @@ class EmbeddedWindowController {


    void remove(IWindow client) {
    void remove(IWindow client) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
            EmbeddedWindow ew = mWindows.valueAt(i);
            if (mWindows.valueAt(i).mClient.asBinder() == client.asBinder()) {
            if (ew.mClient.asBinder() == client.asBinder()) {
                mWindows.removeAt(i).onRemoved();
                mWindows.removeAt(i).onRemoved();
                mWindowsByFocusToken.remove(ew.getFocusGrantToken());
                return;
                return;
            }
            }
        }
        }
@@ -123,10 +116,8 @@ class EmbeddedWindowController {


    void onWindowRemoved(WindowState host) {
    void onWindowRemoved(WindowState host) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
            EmbeddedWindow ew = mWindows.valueAt(i);
            if (mWindows.valueAt(i).mHostWindowState == host) {
            if (ew.mHostWindowState == host) {
                mWindows.removeAt(i).onRemoved();
                mWindows.removeAt(i).onRemoved();
                mWindowsByFocusToken.remove(ew.getFocusGrantToken());
            }
            }
        }
        }
    }
    }
@@ -135,10 +126,6 @@ class EmbeddedWindowController {
        return mWindows.get(inputToken);
        return mWindows.get(inputToken);
    }
    }


    EmbeddedWindow getByFocusToken(IBinder focusGrantToken) {
        return mWindowsByFocusToken.get(focusGrantToken);
    }

    void onActivityRemoved(ActivityRecord activityRecord) {
    void onActivityRemoved(ActivityRecord activityRecord) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
        for (int i = mWindows.size() - 1; i >= 0; i--) {
            final EmbeddedWindow window = mWindows.valueAt(i);
            final EmbeddedWindow window = mWindows.valueAt(i);
@@ -170,8 +157,6 @@ class EmbeddedWindowController {
        // and this variable is mostly used for tracking that.
        // and this variable is mostly used for tracking that.
        boolean mIsOverlay = false;
        boolean mIsOverlay = false;


        private IBinder mFocusGrantToken;

        /**
        /**
         * @param session  calling session to check ownership of the window
         * @param session  calling session to check ownership of the window
         * @param clientToken client token used to clean up the map if the embedding process dies
         * @param clientToken client token used to clean up the map if the embedding process dies
@@ -186,7 +171,7 @@ class EmbeddedWindowController {
         */
         */
        EmbeddedWindow(Session session, WindowManagerService service, IWindow clientToken,
        EmbeddedWindow(Session session, WindowManagerService service, IWindow clientToken,
                       WindowState hostWindowState, int ownerUid, int ownerPid, int windowType,
                       WindowState hostWindowState, int ownerUid, int ownerPid, int windowType,
                       int displayId, IBinder focusGrantToken) {
                       int displayId) {
            mSession = session;
            mSession = session;
            mWmService = service;
            mWmService = service;
            mClient = clientToken;
            mClient = clientToken;
@@ -197,7 +182,6 @@ class EmbeddedWindowController {
            mOwnerPid = ownerPid;
            mOwnerPid = ownerPid;
            mWindowType = windowType;
            mWindowType = windowType;
            mDisplayId = displayId;
            mDisplayId = displayId;
            mFocusGrantToken = focusGrantToken;
        }
        }


        @Override
        @Override
@@ -258,17 +242,6 @@ class EmbeddedWindowController {
            return mIsOverlay;
            return mIsOverlay;
        }
        }


        IBinder getFocusGrantToken() {
            return mFocusGrantToken;
        }

        IBinder getInputChannelToken() {
            if (mInputChannel != null) {
                return mInputChannel.getToken();
            }
            return null;
        }

        /**
        /**
         * System hosted overlays need the WM to invoke grantEmbeddedWindowFocus and
         * System hosted overlays need the WM to invoke grantEmbeddedWindowFocus and
         * so we need to participate inside handlePointerDownOutsideFocus logic
         * so we need to participate inside handlePointerDownOutsideFocus logic
@@ -282,7 +255,7 @@ class EmbeddedWindowController {


        private void handleTap(boolean grantFocus) {
        private void handleTap(boolean grantFocus) {
            if (mInputChannel != null) {
            if (mInputChannel != null) {
                mWmService.grantEmbeddedWindowFocus(mSession, mFocusGrantToken, grantFocus);
                mWmService.grantEmbeddedWindowFocus(mSession, mInputChannel.getToken(), grantFocus);
            }
            }
        }
        }


+2 −2
Original line number Original line Diff line number Diff line
@@ -798,7 +798,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
    @Override
    @Override
    public void grantInputChannel(int displayId, SurfaceControl surface,
    public void grantInputChannel(int displayId, SurfaceControl surface,
            IWindow window, IBinder hostInputToken, int flags, int privateFlags, int type,
            IWindow window, IBinder hostInputToken, int flags, int privateFlags, int type,
            IBinder focusGrantToken, InputChannel outInputChannel) {
            InputChannel outInputChannel) {
        if (hostInputToken == null && !mCanAddInternalSystemWindow) {
        if (hostInputToken == null && !mCanAddInternalSystemWindow) {
            // Callers without INTERNAL_SYSTEM_WINDOW permission cannot grant input channel to
            // Callers without INTERNAL_SYSTEM_WINDOW permission cannot grant input channel to
            // embedded windows without providing a host window input token
            // embedded windows without providing a host window input token
@@ -814,7 +814,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
        try {
        try {
            mService.grantInputChannel(this, mUid, mPid, displayId, surface, window, hostInputToken,
            mService.grantInputChannel(this, mUid, mPid, displayId, surface, window, hostInputToken,
                    flags, mCanAddInternalSystemWindow ? privateFlags : 0,
                    flags, mCanAddInternalSystemWindow ? privateFlags : 0,
                    mCanAddInternalSystemWindow ? type : 0, focusGrantToken, outInputChannel);
                    mCanAddInternalSystemWindow ? type : 0, outInputChannel);
        } finally {
        } finally {
            Binder.restoreCallingIdentity(identity);
            Binder.restoreCallingIdentity(identity);
        }
        }
Loading