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

Commit 02a5b039 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Add focus support for SurfaceControlViewHost"

parents 692d2f91 204c023a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -336,4 +336,17 @@ interface IWindowSession {
     */
    void updateInputChannel(in IBinder channelToken, int displayId, in SurfaceControl surface,
            int flags, int privateFlags, in Region region);

    /**
     * Transfer window focus to an embedded window if the calling window has focus.
     *
     * @param window - calling window owned by the caller. Window can be null if there
     *                 is no host window but the caller must have permissions to create an embedded
     *                 window without a host window.
     * @param inputToken - token identifying the embedded window that should gain focus.
     * @param grantFocus - true if focus should be granted to the embedded window, false if focus
     *                     should be transferred back to the host window. If there is no host
     *                     window, the system will try to find a new focus target.
     */
    void grantEmbeddedWindowFocus(IWindow window, in IBinder inputToken, boolean grantFocus);
}
+17 −2
Original line number Diff line number Diff line
@@ -70,10 +70,13 @@ public class SurfaceControlViewHost {
    public static final class SurfacePackage implements Parcelable {
        private SurfaceControl mSurfaceControl;
        private final IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection;
        private final IBinder mInputToken;

        SurfacePackage(SurfaceControl sc, IAccessibilityEmbeddedConnection connection) {
        SurfacePackage(SurfaceControl sc, IAccessibilityEmbeddedConnection connection,
                       IBinder inputToken) {
            mSurfaceControl = sc;
            mAccessibilityEmbeddedConnection = connection;
            mInputToken = inputToken;
        }

        private SurfacePackage(Parcel in) {
@@ -81,6 +84,7 @@ public class SurfaceControlViewHost {
            mSurfaceControl.readFromParcel(in);
            mAccessibilityEmbeddedConnection = IAccessibilityEmbeddedConnection.Stub.asInterface(
                    in.readStrongBinder());
            mInputToken = in.readStrongBinder();
        }

        /**
@@ -126,6 +130,15 @@ public class SurfaceControlViewHost {
             mSurfaceControl = null;
        }

        /**
         * Returns an input token used which can be used to request focus on the embedded surface.
         *
         * @hide
         */
        public IBinder getInputToken() {
            return mInputToken;
        }

        public static final @NonNull Creator<SurfacePackage> CREATOR
             = new Creator<SurfacePackage>() {
                     public SurfacePackage createFromParcel(Parcel in) {
@@ -198,7 +211,8 @@ public class SurfaceControlViewHost {
     */
    public @Nullable SurfacePackage getSurfacePackage() {
        if (mSurfaceControl != null && mAccessibilityEmbeddedConnection != null) {
            return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection);
            return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection,
                    mViewRoot.getInputToken());
        } else {
            return null;
        }
@@ -210,6 +224,7 @@ public class SurfaceControlViewHost {
    @TestApi
    public void setView(@NonNull View view, @NonNull WindowManager.LayoutParams attrs) {
        Objects.requireNonNull(view);
        view.setLayoutParams(attrs);
        mViewRoot.setView(view, attrs, null);
    }

+17 −0
Original line number Diff line number Diff line
@@ -1846,6 +1846,23 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        }
    }

    @Override
    protected void onFocusChanged(boolean gainFocus, @FocusDirection int direction,
                                  @Nullable Rect previouslyFocusedRect) {
        super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
        final ViewRootImpl viewRoot = getViewRootImpl();
        if (mSurfacePackage == null || viewRoot == null) {
            return;
        }
        try {
            viewRoot.mWindowSession.grantEmbeddedWindowFocus(viewRoot.mWindow,
                    mSurfacePackage.getInputToken(), gainFocus);
        } catch (Exception e) {
            Log.e(TAG, System.identityHashCode(this)
                    + "Exception requesting focus on embedded window", e);
        }
    }

    /**
     * Wrapper of accessibility embedded connection for embedded view hierarchy.
     */
+5 −0
Original line number Diff line number Diff line
@@ -452,4 +452,9 @@ public class WindowlessWindowManager implements IWindowSession {
      return surfaceInsets != null
          ? attrs.height + surfaceInsets.top + surfaceInsets.bottom : attrs.height;
    }

    @Override
    public void grantEmbeddedWindowFocus(IWindow callingWindow, IBinder targetInputToken,
                                         boolean grantFocus) {
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    "-2107721178": {
      "message": "grantEmbeddedWindowFocus win=%s grantFocus=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-2101985723": {
      "message": "Failed looking up window session=%s callers=%s",
      "level": "WARN",
@@ -1597,6 +1603,12 @@
      "group": "WM_DEBUG_BOOT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "397105698": {
      "message": "grantEmbeddedWindowFocus remove request for win=%s dropped since no candidate was found",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "399841913": {
      "message": "SURFACE RECOVER DESTROY: %s",
      "level": "INFO",
Loading