diff options
| -rw-r--r-- | core/api/current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 50 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerGlobal.java | 12 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerImpl.java | 12 | ||||
| -rw-r--r-- | core/java/android/window/InputTransferToken.java | 12 |
5 files changed, 65 insertions, 25 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index f55098600ab3..41d4fd6a1db7 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -54372,9 +54372,9 @@ package android.view { method @Deprecated public android.view.Display getDefaultDisplay(); method @NonNull public default android.view.WindowMetrics getMaximumWindowMetrics(); method public default boolean isCrossWindowBlurEnabled(); - method @FlaggedApi("com.android.window.flags.surface_control_input_receiver") public default void registerBatchedSurfaceControlInputReceiver(int, @NonNull android.window.InputTransferToken, @NonNull android.view.SurfaceControl, @NonNull android.view.Choreographer, @NonNull android.view.SurfaceControlInputReceiver); + method @FlaggedApi("com.android.window.flags.surface_control_input_receiver") @NonNull public default android.window.InputTransferToken registerBatchedSurfaceControlInputReceiver(int, @NonNull android.window.InputTransferToken, @NonNull android.view.SurfaceControl, @NonNull android.view.Choreographer, @NonNull android.view.SurfaceControlInputReceiver); method @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public default void registerTrustedPresentationListener(@NonNull android.os.IBinder, @NonNull android.window.TrustedPresentationThresholds, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>); - method @FlaggedApi("com.android.window.flags.surface_control_input_receiver") public default void registerUnbatchedSurfaceControlInputReceiver(int, @NonNull android.window.InputTransferToken, @NonNull android.view.SurfaceControl, @NonNull android.os.Looper, @NonNull android.view.SurfaceControlInputReceiver); + method @FlaggedApi("com.android.window.flags.surface_control_input_receiver") @NonNull public default android.window.InputTransferToken registerUnbatchedSurfaceControlInputReceiver(int, @NonNull android.window.InputTransferToken, @NonNull android.view.SurfaceControl, @NonNull android.os.Looper, @NonNull android.view.SurfaceControlInputReceiver); method public default void removeCrossWindowBlurEnabledListener(@NonNull java.util.function.Consumer<java.lang.Boolean>); method public default void removeProposedRotationListener(@NonNull java.util.function.IntConsumer); method @FlaggedApi("com.android.window.flags.screen_recording_callbacks") @RequiresPermission(android.Manifest.permission.DETECT_SCREEN_RECORDING) public default void removeScreenRecordingCallback(@NonNull java.util.function.Consumer<java.lang.Integer>); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index bc9b4fe37a2f..0343afbda38b 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -6115,12 +6115,15 @@ public interface WindowManager extends ViewManager { * rendering Choreographer. * @param receiver The SurfaceControlInputReceiver that will receive the input * events + * @return Returns the {@link InputTransferToken} that can be used to transfer touch gesture + * to or from other windows. */ @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) - default void registerBatchedSurfaceControlInputReceiver(int displayId, + @NonNull + default InputTransferToken registerBatchedSurfaceControlInputReceiver(int displayId, @NonNull InputTransferToken hostInputTransferToken, - @NonNull SurfaceControl surfaceControl, - @NonNull Choreographer choreographer, @NonNull SurfaceControlInputReceiver receiver) { + @NonNull SurfaceControl surfaceControl, @NonNull Choreographer choreographer, + @NonNull SurfaceControlInputReceiver receiver) { throw new UnsupportedOperationException( "registerBatchedSurfaceControlInputReceiver is not implemented"); } @@ -6145,9 +6148,12 @@ public interface WindowManager extends ViewManager { * @param looper The looper to use when invoking callbacks. * @param receiver The SurfaceControlInputReceiver that will receive the input * events. + * @return Returns the {@link InputTransferToken} that can be used to transfer touch gesture + * to or from other windows. */ @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) - default void registerUnbatchedSurfaceControlInputReceiver(int displayId, + @NonNull + default InputTransferToken registerUnbatchedSurfaceControlInputReceiver(int displayId, @NonNull InputTransferToken hostInputTransferToken, @NonNull SurfaceControl surfaceControl, @NonNull Looper looper, @NonNull SurfaceControlInputReceiver receiver) { @@ -6200,9 +6206,21 @@ public interface WindowManager extends ViewManager { * transferToToken. * <p><br> * This requires that the fromToken and toToken are associated with each other. The association - * can be done by creating a {@link SurfaceControlViewHost} and passing the host's + * can be done different ways, depending on how the embedded window is created. + * <ul> + * <li> + * Creating a {@link SurfaceControlViewHost} and passing the host's * {@link InputTransferToken} for * {@link SurfaceControlViewHost#SurfaceControlViewHost(Context, Display, InputTransferToken)}. + * </li> + * <li> + * Registering a SurfaceControl for input and passing the host's token to either + * {@link #registerBatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl, + * Choreographer, SurfaceControlInputReceiver)} or + * {@link #registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken, + * SurfaceControl, Looper, SurfaceControlInputReceiver)}. + * </li> + * </ul> * <p> * The host is likely to be an {@link AttachedSurfaceControl} so the host token can be * retrieved via {@link AttachedSurfaceControl#getInputTransferToken()}. @@ -6212,12 +6230,16 @@ public interface WindowManager extends ViewManager { * transfer. * <p><br> * When the host wants to transfer touch gesture to the embedded, it can retrieve the embedded - * token via {@link SurfaceControlViewHost.SurfacePackage#getInputTransferToken()} and pass its - * own token as the transferFromToken. + * token via {@link SurfaceControlViewHost.SurfacePackage#getInputTransferToken()} or use the + * value returned from either + * {@link #registerBatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl, + * Choreographer, SurfaceControlInputReceiver)} or + * {@link #registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl, + * Looper, SurfaceControlInputReceiver)} and pass its own token as the transferFromToken. * <p> - * When the embedded wants to transfer touch gesture to the host, it can pass in its own token - * as the transferFromToken and use the associated host's {@link InputTransferToken} as the - * transferToToken + * When the embedded wants to transfer touch gesture to the host, it can pass in its own + * token as the transferFromToken and use the associated host's {@link InputTransferToken} as + * the transferToToken * <p><br> * When the touch is transferred, the window currently receiving touch gets an ACTION_CANCEL * and does not receive any further input events for this gesture. @@ -6226,10 +6248,10 @@ public interface WindowManager extends ViewManager { * events for this gesture. It does not receive any of the previous events of this gesture that * the originating window received. * <p> - * The transferTouchGesture API only works for the current gesture. When a new gesture arrives, - * input dispatcher will do a new round of hit testing. So, if the host window is still the - * first thing that's being touched, then it will receive the new gesture again. It will again - * be up to the host to transfer this new gesture to the embedded. + * The transferTouchGesture API only works for the current gesture. When a new gesture + * arrives, input dispatcher will do a new round of hit testing. So, if the host window is + * still the first thing that's being touched, then it will receive the new gesture again. It + * will again be up to the host to transfer this new gesture to the embedded. * * @param transferFromToken the InputTransferToken for the currently active gesture * @param transferToToken the InputTransferToken to transfer the gesture to. diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index 2c98d9a6091d..584219a55032 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -839,14 +839,15 @@ public final class WindowManagerGlobal { mTrustedPresentationListener.removeListener(listener); } - void registerBatchedSurfaceControlInputReceiver(int displayId, + InputTransferToken registerBatchedSurfaceControlInputReceiver(int displayId, @NonNull InputTransferToken hostToken, @NonNull SurfaceControl surfaceControl, @NonNull Choreographer choreographer, @NonNull SurfaceControlInputReceiver receiver) { IBinder clientToken = new Binder(); + InputTransferToken inputTransferToken = new InputTransferToken(); InputChannel inputChannel = new InputChannel(); try { WindowManagerGlobal.getWindowSession().grantInputChannel(displayId, surfaceControl, - clientToken, hostToken, 0, 0, TYPE_APPLICATION, 0, null, null, + clientToken, hostToken, 0, 0, TYPE_APPLICATION, 0, null, inputTransferToken, surfaceControl.getName(), inputChannel); } catch (RemoteException e) { Log.e(TAG, "Failed to create input channel", e); @@ -865,16 +866,18 @@ public final class WindowManagerGlobal { } })); } + return inputTransferToken; } - void registerUnbatchedSurfaceControlInputReceiver(int displayId, + InputTransferToken registerUnbatchedSurfaceControlInputReceiver(int displayId, @NonNull InputTransferToken hostToken, @NonNull SurfaceControl surfaceControl, @NonNull Looper looper, @NonNull SurfaceControlInputReceiver receiver) { IBinder clientToken = new Binder(); + InputTransferToken inputTransferToken = new InputTransferToken(); InputChannel inputChannel = new InputChannel(); try { WindowManagerGlobal.getWindowSession().grantInputChannel(displayId, surfaceControl, - clientToken, hostToken, 0, 0, TYPE_APPLICATION, 0, null, null, + clientToken, hostToken, 0, 0, TYPE_APPLICATION, 0, null, inputTransferToken, surfaceControl.getName(), inputChannel); } catch (RemoteException e) { Log.e(TAG, "Failed to create input channel", e); @@ -892,6 +895,7 @@ public final class WindowManagerGlobal { } })); } + return inputTransferToken; } void unregisterSurfaceControlInputReceiver(SurfaceControl surfaceControl) { diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 44e24932aef6..897222879e8f 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -533,22 +533,24 @@ public final class WindowManagerImpl implements WindowManager { mGlobal.unregisterTrustedPresentationListener(listener); } + @NonNull @Override - public void registerBatchedSurfaceControlInputReceiver(int displayId, + public InputTransferToken registerBatchedSurfaceControlInputReceiver(int displayId, @NonNull InputTransferToken hostInputTransferToken, @NonNull SurfaceControl surfaceControl, @NonNull Choreographer choreographer, @NonNull SurfaceControlInputReceiver receiver) { - mGlobal.registerBatchedSurfaceControlInputReceiver(displayId, hostInputTransferToken, + return mGlobal.registerBatchedSurfaceControlInputReceiver(displayId, hostInputTransferToken, surfaceControl, choreographer, receiver); } + @NonNull @Override - public void registerUnbatchedSurfaceControlInputReceiver(int displayId, + public InputTransferToken registerUnbatchedSurfaceControlInputReceiver(int displayId, @NonNull InputTransferToken hostInputTransferToken, @NonNull SurfaceControl surfaceControl, @NonNull Looper looper, @NonNull SurfaceControlInputReceiver receiver) { - mGlobal.registerUnbatchedSurfaceControlInputReceiver(displayId, hostInputTransferToken, - surfaceControl, looper, receiver); + return mGlobal.registerUnbatchedSurfaceControlInputReceiver(displayId, + hostInputTransferToken, surfaceControl, looper, receiver); } @Override diff --git a/core/java/android/window/InputTransferToken.java b/core/java/android/window/InputTransferToken.java index f1b37bf19ef3..e572853e5d5d 100644 --- a/core/java/android/window/InputTransferToken.java +++ b/core/java/android/window/InputTransferToken.java @@ -20,8 +20,12 @@ import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.os.Binder; import android.os.IBinder; +import android.os.Looper; import android.os.Parcel; import android.os.Parcelable; +import android.view.Choreographer; +import android.view.SurfaceControl; +import android.view.SurfaceControlInputReceiver; import android.view.SurfaceControlViewHost; import com.android.window.flags.Flags; @@ -32,6 +36,14 @@ import java.util.Objects; * A token that can be used to request focus on or to transfer touch gesture to a * {@link SurfaceControlViewHost} or {@link android.view.SurfaceControl} that has an input channel. * <p> + * The {@link android.view.SurfaceControl} needs to have been registered for input via + * {@link android.view.WindowManager#registerUnbatchedSurfaceControlInputReceiver(int, + * InputTransferToken, SurfaceControl, Looper, SurfaceControlInputReceiver)} or + * {@link android.view.WindowManager#registerBatchedSurfaceControlInputReceiver(int, + * InputTransferToken, SurfaceControl, Choreographer, SurfaceControlInputReceiver)} and the + * returned token can be used to call + * {@link android.view.WindowManager#transferTouchGesture(InputTransferToken, InputTransferToken)} + * <p> * For {@link SurfaceControlViewHost}, the token can be retrieved via * {@link SurfaceControlViewHost.SurfacePackage#getInputTransferToken()} * |