Loading core/java/android/view/IWindowSession.aidl +13 −0 Original line number Diff line number Diff line Loading @@ -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); } core/java/android/view/SurfaceControlViewHost.java +17 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -81,6 +84,7 @@ public class SurfaceControlViewHost { mSurfaceControl.readFromParcel(in); mAccessibilityEmbeddedConnection = IAccessibilityEmbeddedConnection.Stub.asInterface( in.readStrongBinder()); mInputToken = in.readStrongBinder(); } /** Loading Loading @@ -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) { Loading Loading @@ -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; } Loading @@ -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); } Loading core/java/android/view/SurfaceView.java +17 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading core/java/android/view/WindowlessWindowManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -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) { } } data/etc/services.core.protolog.json +12 −0 Original line number Diff line number Diff line Loading @@ -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", Loading Loading @@ -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 Loading
core/java/android/view/IWindowSession.aidl +13 −0 Original line number Diff line number Diff line Loading @@ -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); }
core/java/android/view/SurfaceControlViewHost.java +17 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -81,6 +84,7 @@ public class SurfaceControlViewHost { mSurfaceControl.readFromParcel(in); mAccessibilityEmbeddedConnection = IAccessibilityEmbeddedConnection.Stub.asInterface( in.readStrongBinder()); mInputToken = in.readStrongBinder(); } /** Loading Loading @@ -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) { Loading Loading @@ -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; } Loading @@ -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); } Loading
core/java/android/view/SurfaceView.java +17 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading
core/java/android/view/WindowlessWindowManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -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) { } }
data/etc/services.core.protolog.json +12 −0 Original line number Diff line number Diff line Loading @@ -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", Loading Loading @@ -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