summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chavi Weingarten <chaviw@google.com> 2024-02-08 16:48:20 +0000
committer Chavi Weingarten <chaviw@google.com> 2024-02-13 20:55:21 +0000
commit849f2ad9948c9c466e01bc474963f9d762093507 (patch)
tree9fde133f4fc2b88334109bb49cc5dd0fef9dbb3e
parentec80ac3980882d5d301f86d7d767321106b7597e (diff)
Expose InputTransferToken API and usages of it as public API
Test: SurfaceControlInputReceiverTests Test: AttachedSurfaceControlTest Test: SurfaceControlViewHostTests Flag: ACONFIG com.android.window.flags.surface_control_input_receiver TRUNKFOOD Bug: 287076178 Change-Id: I3b951ed62c18771661e96cffe493c44941148973
-rw-r--r--core/api/current.txt13
-rw-r--r--core/java/android/view/AttachedSurfaceControl.java38
-rw-r--r--core/java/android/view/SurfaceControlViewHost.java22
-rw-r--r--core/java/android/view/ViewRootImpl.java18
-rw-r--r--core/java/android/view/WindowManager.java82
-rw-r--r--core/java/android/view/WindowManagerImpl.java18
-rw-r--r--core/java/android/window/InputTransferToken.java5
-rw-r--r--core/java/android/window/flags/window_surfaces.aconfig8
-rw-r--r--tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/EmbeddedWindowService.java5
-rw-r--r--tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/IAttachEmbeddedWindow.aidl4
-rw-r--r--tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/SurfaceInputTestActivity.java8
11 files changed, 120 insertions, 101 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 7052fd1c08e9..0db3214d8f72 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -50441,7 +50441,7 @@ package android.view {
method public boolean applyTransactionOnDraw(@NonNull android.view.SurfaceControl.Transaction);
method @Nullable public android.view.SurfaceControl.Transaction buildReparentTransaction(@NonNull android.view.SurfaceControl);
method public default int getBufferTransformHint();
- method @FlaggedApi("com.android.window.flags.get_host_token_api") @Nullable public default android.os.IBinder getHostToken();
+ method @FlaggedApi("com.android.window.flags.surface_control_input_receiver") @NonNull public default android.window.InputTransferToken getInputTransferToken();
method public default void removeOnBufferTransformHintChangedListener(@NonNull android.view.AttachedSurfaceControl.OnBufferTransformHintChangedListener);
method public default void setChildBoundingInsets(@NonNull android.graphics.Rect);
method public default void setTouchableRegion(@Nullable android.graphics.Region);
@@ -52151,6 +52151,7 @@ package android.view {
public class SurfaceControlViewHost {
ctor public SurfaceControlViewHost(@NonNull android.content.Context, @NonNull android.view.Display, @Nullable android.os.IBinder);
+ ctor @FlaggedApi("com.android.window.flags.surface_control_input_receiver") public SurfaceControlViewHost(@NonNull android.content.Context, @NonNull android.view.Display, @Nullable android.window.InputTransferToken);
method @Nullable public android.view.SurfaceControlViewHost.SurfacePackage getSurfacePackage();
method @Nullable public android.view.View getView();
method public void relayout(int, int);
@@ -54289,9 +54290,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.os.IBinder, @NonNull android.view.SurfaceControl, @NonNull android.view.Choreographer, @NonNull android.view.SurfaceControlInputReceiver);
+ 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.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.os.IBinder, @NonNull android.view.SurfaceControl, @NonNull android.os.Looper, @NonNull android.view.SurfaceControlInputReceiver);
+ 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 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>);
@@ -61272,6 +61273,12 @@ package android.window {
field public static final int EDGE_RIGHT = 1; // 0x1
}
+ @FlaggedApi("com.android.window.flags.surface_control_input_receiver") public final class InputTransferToken implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.window.InputTransferToken> CREATOR;
+ }
+
public interface OnBackAnimationCallback extends android.window.OnBackInvokedCallback {
method public default void onBackCancelled();
method public default void onBackProgressed(@NonNull android.window.BackEvent);
diff --git a/core/java/android/view/AttachedSurfaceControl.java b/core/java/android/view/AttachedSurfaceControl.java
index ffe0c716905d..9413f5c0868e 100644
--- a/core/java/android/view/AttachedSurfaceControl.java
+++ b/core/java/android/view/AttachedSurfaceControl.java
@@ -19,10 +19,11 @@ import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UiThread;
+import android.content.Context;
import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.HardwareBuffer;
-import android.os.IBinder;
+import android.os.Looper;
import android.window.InputTransferToken;
import android.window.SurfaceSyncGroup;
@@ -180,32 +181,25 @@ public interface AttachedSurfaceControl {
}
/**
- * Gets the token used for associating this {@link AttachedSurfaceControl} with
- * {@link SurfaceControlViewHost} instances.
- *
- * <p>This token should be passed to {@link SurfaceControlViewHost}'s constructor.
- * This token will be {@code null} if the window does not have an input channel.
- *
- * @return The SurfaceControlViewHost link token.
- */
- @Nullable
- @FlaggedApi(Flags.FLAG_GET_HOST_TOKEN_API)
- default IBinder getHostToken() {
- throw new UnsupportedOperationException("The getHostToken needs to be "
- + "implemented before making this call.");
- }
-
- /**
* Gets the token used for associating this {@link AttachedSurfaceControl} with an embedded
* {@link SurfaceControlViewHost} or {@link SurfaceControl}
*
- * @return The SurfaceControlViewHost link token. This can return {@code null} if the
- * {@link AttachedSurfaceControl} was created with no registered input
- * @hide
+ * <p>This token should be passed to
+ * {@link SurfaceControlViewHost#SurfaceControlViewHost(Context, Display, InputTransferToken)}
+ * or
+ * {@link WindowManager#registerBatchedSurfaceControlInputReceiver(int, InputTransferToken,
+ * SurfaceControl, Choreographer, SurfaceControlInputReceiver)} or
+ * {@link WindowManager#registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken,
+ * SurfaceControl, Looper, SurfaceControlInputReceiver)}
+ *
+ * @return The SurfaceControlViewHost link token.
+ * @throws IllegalStateException if the {@link AttachedSurfaceControl} was created with no
+ * registered input
*/
- @Nullable
+ @NonNull
+ @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER)
default InputTransferToken getInputTransferToken() {
- throw new UnsupportedOperationException("The getHostToken needs to be "
+ throw new UnsupportedOperationException("The getInputTransferToken needs to be "
+ "implemented before making this call.");
}
diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java
index 58765b46a05a..1dd9cbb76a9f 100644
--- a/core/java/android/view/SurfaceControlViewHost.java
+++ b/core/java/android/view/SurfaceControlViewHost.java
@@ -16,6 +16,7 @@
package android.view;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
@@ -33,6 +34,8 @@ import android.window.ISurfaceSyncGroup;
import android.window.InputTransferToken;
import android.window.WindowTokenClient;
+import com.android.window.flags.Flags;
+
import dalvik.system.CloseGuard;
import java.util.Objects;
@@ -347,6 +350,25 @@ public class SurfaceControlViewHost {
@Nullable IBinder hostToken) {
this(context, display, hostToken == null ? null : new InputTransferToken(hostToken),
"untracked");
+
+ }
+
+ /**
+ * Construct a new SurfaceControlViewHost. The root Surface will be
+ * allocated internally and is accessible via getSurfacePackage().
+ * <p>
+ * The hostInputTransferToken parameter allows the host and embedded to be associated with
+ * each other to allow transferring touch gesture and focus. This is also used for ANR
+ * reporting. It's accessible from {@link AttachedSurfaceControl#getInputTransferToken()}.
+ *
+ * @param context The Context object for your activity or application.
+ * @param display The Display the hierarchy will be placed on.
+ * @param hostInputTransferToken The host input transfer token, as discussed above.
+ */
+ @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER)
+ public SurfaceControlViewHost(@NonNull Context context, @NonNull Display display,
+ @Nullable InputTransferToken hostInputTransferToken) {
+ this(context, display, hostInputTransferToken, "untracked");
}
/**
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 28a73344b731..657c8e644f3a 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -103,7 +103,6 @@ import android.accessibilityservice.AccessibilityService;
import android.animation.AnimationHandler;
import android.animation.LayoutTransition;
import android.annotation.AnyThread;
-import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Size;
@@ -240,7 +239,6 @@ import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.SurfaceCallbackHelper;
import com.android.modules.expresslog.Counter;
-import com.android.window.flags.Flags;
import java.io.IOException;
import java.io.OutputStream;
@@ -11220,25 +11218,15 @@ public final class ViewRootImpl implements ViewParent,
}
/**
- * @return Returns a token used for associating the root surface
- * to {@link SurfaceControlViewHost}.
- */
- @Nullable
- @Override
- @FlaggedApi(Flags.FLAG_GET_HOST_TOKEN_API)
- public IBinder getHostToken() {
- return getInputToken();
- }
-
- /**
* {@inheritDoc}
*/
- @Nullable
+ @NonNull
@Override
public InputTransferToken getInputTransferToken() {
IBinder inputToken = getInputToken();
if (inputToken == null) {
- return null;
+ throw new IllegalStateException(
+ "Called getInputTransferToken for Window with no input channel");
}
return new InputTransferToken(inputToken);
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 58fb273212f7..0302a0df35c0 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -123,6 +123,7 @@ import android.view.WindowInsets.Side.InsetsSide;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.window.InputTransferToken;
import android.window.TaskFpsCallback;
import android.window.TrustedPresentationThresholds;
@@ -6097,25 +6098,28 @@ public interface WindowManager extends ViewManager {
* receive batched input event. For those events that are batched, the invocation will happen
* once per {@link Choreographer} frame, and other input events will be delivered immediately.
* This is different from
- * {@link #registerUnbatchedSurfaceControlInputReceiver(int, IBinder, SurfaceControl, Looper,
- * SurfaceControlInputReceiver)} in that the input events are received batched. The caller must
- * invoke {@link #unregisterSurfaceControlInputReceiver(SurfaceControl)} to clean up the
- * resources when no longer needing to use the {@link SurfaceControlInputReceiver}
- *
- * @param displayId The display that the SurfaceControl will be placed on. Input will
- * only work
- * if SurfaceControl is on that display and that display was touched.
- * @param surfaceControl The SurfaceControl to register the InputChannel for
- * @param hostToken The host token to link the InputChannel for. This is primarily for ANRs
- * to ensure the host receives the ANR if any issues with touch on the
- * InputChannel
- * @param choreographer The Choreographer used for batching. This should match the rendering
- * Choreographer.
- * @param receiver The SurfaceControlInputReceiver that will receive the input events
+ * { #registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl,
+ * Looper, SurfaceControlInputReceiver)} in that the input events are received batched. The
+ * caller must invoke {@link #unregisterSurfaceControlInputReceiver(SurfaceControl)} to clean up
+ * the resources when no longer needing to use the {@link SurfaceControlInputReceiver}
+ *
+ * @param displayId The display that the SurfaceControl will be placed on. Input
+ * will only work if SurfaceControl is on that display and that
+ * display was touched.
+ * @param surfaceControl The SurfaceControl to register the InputChannel for
+ * @param hostInputTransferToken The host token to link the embedded. This is used to handle
+ * transferring touch gesture from host to embedded and for ANRs
+ * to ensure the host receives the ANR if any issues with
+ * touch on the embedded.
+ * @param choreographer The Choreographer used for batching. This should match the
+ * rendering Choreographer.
+ * @param receiver The SurfaceControlInputReceiver that will receive the input
+ * events
*/
@FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER)
default void registerBatchedSurfaceControlInputReceiver(int displayId,
- @NonNull IBinder hostToken, @NonNull SurfaceControl surfaceControl,
+ @NonNull InputTransferToken hostInputTransferToken,
+ @NonNull SurfaceControl surfaceControl,
@NonNull Choreographer choreographer, @NonNull SurfaceControlInputReceiver receiver) {
throw new UnsupportedOperationException(
"registerBatchedSurfaceControlInputReceiver is not implemented");
@@ -6123,26 +6127,30 @@ public interface WindowManager extends ViewManager {
/**
* Registers a {@link SurfaceControlInputReceiver} for a {@link SurfaceControl} that will
- * receive every input event. This is different than calling @link
- * #registerBatchedSurfaceControlInputReceiver(int, IBinder, SurfaceControl, Choreographer,
- * SurfaceControlInputReceiver)} in that the input events are received unbatched. The caller
- * must invoke {@link #unregisterSurfaceControlInputReceiver(SurfaceControl)} to clean up the
- * resources when no longer needing to use the {@link SurfaceControlInputReceiver}
- *
- * @param displayId The display that the SurfaceControl will be placed on. Input will only
- * work if SurfaceControl is on that display and that display was
- * touched.
- * @param hostToken The host token to link the InputChannel for. This is primarily for ANRs
- * to ensure the host receives the ANR if any issues with touch on the
- * InputChannel
- * @param surfaceControl The SurfaceControl to register the InputChannel for
- * @param looper The looper to use when invoking callbacks.
- * @param receiver The SurfaceControlInputReceiver that will receive the input events
- **/
+ * receive every input event. This is different than calling
+ * {@link #registerBatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl,
+ * Choreographer, SurfaceControlInputReceiver)} in that the input events are received
+ * unbatched.
+ * The caller must invoke {@link #unregisterSurfaceControlInputReceiver(SurfaceControl)} to
+ * clean up the resources when no longer needing to use the {@link SurfaceControlInputReceiver}
+ *
+ * @param displayId The display that the SurfaceControl will be placed on. Input
+ * will only work if SurfaceControl is on that display and that
+ * display was touched.
+ * @param surfaceControl The SurfaceControl to register the InputChannel for
+ * @param hostInputTransferToken The host token to link the embedded. This is used to handle
+ * transferring touch gesture from host to embedded and for ANRs
+ * to ensure the host receives the ANR if any issues with
+ * touch on the embedded.
+ * @param looper The looper to use when invoking callbacks.
+ * @param receiver The SurfaceControlInputReceiver that will receive the input
+ * events.
+ */
@FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER)
default void registerUnbatchedSurfaceControlInputReceiver(int displayId,
- @NonNull IBinder hostToken, @NonNull SurfaceControl surfaceControl,
- @NonNull Looper looper, @NonNull SurfaceControlInputReceiver receiver) {
+ @NonNull InputTransferToken hostInputTransferToken,
+ @NonNull SurfaceControl surfaceControl, @NonNull Looper looper,
+ @NonNull SurfaceControlInputReceiver receiver) {
throw new UnsupportedOperationException(
"registerUnbatchedSurfaceControlInputReceiver is not implemented");
}
@@ -6152,10 +6160,10 @@ public interface WindowManager extends ViewManager {
* specified token.
* <p>
* Must be called on the same {@link Looper} thread to which was passed to the
- * {@link #registerBatchedSurfaceControlInputReceiver(int, IBinder, SurfaceControl,
+ * {@link #registerBatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl,
* Choreographer,
* SurfaceControlInputReceiver)} or
- * {@link #registerUnbatchedSurfaceControlInputReceiver(int, IBinder, SurfaceControl, Looper,
+ * {@link #registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl, Looper,
* SurfaceControlInputReceiver)}
*
* @param surfaceControl The SurfaceControl to remove and unregister the input channel for.
@@ -6171,7 +6179,7 @@ public interface WindowManager extends ViewManager {
* if the SurfaceControl was registered for input via
* { #registerBatchedSurfaceControlInputReceiver(int, IBinder, SurfaceControl, Choreographer,
* SurfaceControlInputReceiver)} or
- * {@link #registerUnbatchedSurfaceControlInputReceiver(int, IBinder, SurfaceControl, Looper,
+ * {@link #registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl, Looper,
* SurfaceControlInputReceiver)}.
* <p>
* This is helpful for testing to ensure the test waits for the layer to be registered with
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index 2fb5213279a6..1e3d0624a95b 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -535,19 +535,19 @@ public final class WindowManagerImpl implements WindowManager {
@Override
public void registerBatchedSurfaceControlInputReceiver(int displayId,
- @NonNull IBinder hostToken, @NonNull SurfaceControl surfaceControl,
- @NonNull Choreographer choreographer, @NonNull SurfaceControlInputReceiver receiver) {
- mGlobal.registerBatchedSurfaceControlInputReceiver(displayId,
- new InputTransferToken(hostToken),
+ @NonNull InputTransferToken hostInputTransferToken,
+ @NonNull SurfaceControl surfaceControl, @NonNull Choreographer choreographer,
+ @NonNull SurfaceControlInputReceiver receiver) {
+ mGlobal.registerBatchedSurfaceControlInputReceiver(displayId, hostInputTransferToken,
surfaceControl, choreographer, receiver);
}
@Override
- public void registerUnbatchedSurfaceControlInputReceiver(
- int displayId, @NonNull IBinder hostToken, @NonNull SurfaceControl surfaceControl,
- @NonNull Looper looper, @NonNull SurfaceControlInputReceiver receiver) {
- mGlobal.registerUnbatchedSurfaceControlInputReceiver(displayId,
- new InputTransferToken(hostToken),
+ public void registerUnbatchedSurfaceControlInputReceiver(int displayId,
+ @NonNull InputTransferToken hostInputTransferToken,
+ @NonNull SurfaceControl surfaceControl, @NonNull Looper looper,
+ @NonNull SurfaceControlInputReceiver receiver) {
+ mGlobal.registerUnbatchedSurfaceControlInputReceiver(displayId, hostInputTransferToken,
surfaceControl, looper, receiver);
}
diff --git a/core/java/android/window/InputTransferToken.java b/core/java/android/window/InputTransferToken.java
index 0601b2a79268..bed0e0e8a225 100644
--- a/core/java/android/window/InputTransferToken.java
+++ b/core/java/android/window/InputTransferToken.java
@@ -16,6 +16,7 @@
package android.window;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.os.Binder;
import android.os.IBinder;
@@ -23,13 +24,15 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.view.SurfaceControlViewHost;
+import com.android.window.flags.Flags;
+
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.
- * @hide
*/
+@FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER)
public final class InputTransferToken implements Parcelable {
/**
* @hide
diff --git a/core/java/android/window/flags/window_surfaces.aconfig b/core/java/android/window/flags/window_surfaces.aconfig
index 069affb4c06c..3ffa27451557 100644
--- a/core/java/android/window/flags/window_surfaces.aconfig
+++ b/core/java/android/window/flags/window_surfaces.aconfig
@@ -20,14 +20,6 @@ flag {
flag {
namespace: "window_surfaces"
- name: "get_host_token_api"
- description: "Feature flag to associate the host and embedded windows"
- is_fixed_read_only: true
- bug: "304508760"
-}
-
-flag {
- namespace: "window_surfaces"
name: "transfer_gesture_to_embedded"
description: "Enable public API for Window Surfaces"
bug: "287076178"
diff --git a/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/EmbeddedWindowService.java b/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/EmbeddedWindowService.java
index 14230fe4c323..0fb4f90f354f 100644
--- a/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/EmbeddedWindowService.java
+++ b/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/EmbeddedWindowService.java
@@ -42,6 +42,7 @@ import android.view.SurfaceControlViewHost;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
+import android.window.InputTransferToken;
public class EmbeddedWindowService extends Service {
private static final String TAG = "EmbeddedWindowService";
@@ -118,7 +119,7 @@ public class EmbeddedWindowService extends Service {
@Override
public void attachEmbeddedSurfaceControl(SurfaceControl parentSc, int displayId,
- IBinder hostToken) {
+ InputTransferToken inputTransferToken) {
mHandler.post(() -> {
Paint paint = new Paint();
paint.setTextSize(40);
@@ -134,7 +135,7 @@ public class EmbeddedWindowService extends Service {
c.drawText("Remote", 250, 250, paint);
surface.unlockCanvasAndPost(c);
WindowManager wm = getSystemService(WindowManager.class);
- wm.registerBatchedSurfaceControlInputReceiver(displayId, hostToken,
+ wm.registerBatchedSurfaceControlInputReceiver(displayId, inputTransferToken,
mSurfaceControl,
Choreographer.getInstance(), event -> {
Log.d(TAG, "onInputEvent-remote " + event);
diff --git a/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/IAttachEmbeddedWindow.aidl b/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/IAttachEmbeddedWindow.aidl
index 6b65b40ef8c6..e81f5f81481a 100644
--- a/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/IAttachEmbeddedWindow.aidl
+++ b/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/IAttachEmbeddedWindow.aidl
@@ -20,10 +20,12 @@ import android.os.IBinder;
import com.android.test.viewembed.IAttachEmbeddedWindowCallback;
import android.view.WindowManager.LayoutParams;
import android.view.SurfaceControl;
+import android.window.InputTransferToken;
interface IAttachEmbeddedWindow {
void attachEmbedded(IBinder hostToken, int width, int height, in IAttachEmbeddedWindowCallback callback);
void relayout(in LayoutParams lp);
- oneway void attachEmbeddedSurfaceControl(in SurfaceControl parentSurfaceControl, int displayId, IBinder hostToken);
+ oneway void attachEmbeddedSurfaceControl(in SurfaceControl parentSurfaceControl, int displayId,
+ in InputTransferToken inputTransferToken);
oneway void tearDownEmbeddedSurfaceControl();
} \ No newline at end of file
diff --git a/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/SurfaceInputTestActivity.java b/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/SurfaceInputTestActivity.java
index 7330ec14011b..e700bc2f3d21 100644
--- a/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/SurfaceInputTestActivity.java
+++ b/tests/SurfaceControlViewHostTest/src/com/android/test/viewembed/SurfaceInputTestActivity.java
@@ -139,7 +139,7 @@ public class SurfaceInputTestActivity extends Activity {
surface.unlockCanvasAndPost(c);
WindowManager wm = getSystemService(WindowManager.class);
wm.registerBatchedSurfaceControlInputReceiver(getDisplayId(),
- attachedSurfaceControl.getHostToken(), mLocalSurfaceControl,
+ attachedSurfaceControl.getInputTransferToken(), mLocalSurfaceControl,
Choreographer.getInstance(), event -> {
Log.d(TAG, "onInputEvent-sc " + event);
return false;
@@ -160,7 +160,8 @@ public class SurfaceInputTestActivity extends Activity {
WindowManager wm = getSystemService(WindowManager.class);
wm.registerBatchedSurfaceControlInputReceiver(getDisplayId(),
- mLocalSurfaceView.getHostToken(), mLocalSurfaceView.getSurfaceControl(),
+ mLocalSurfaceView.getRootSurfaceControl().getInputTransferToken(),
+ mLocalSurfaceView.getSurfaceControl(),
Choreographer.getInstance(), event -> {
Log.d(TAG, "onInputEvent-local " + event);
return false;
@@ -210,7 +211,8 @@ public class SurfaceInputTestActivity extends Activity {
}
try {
mIAttachEmbeddedWindow.attachEmbeddedSurfaceControl(mParentSurfaceControl,
- getDisplayId(), mRemoteSurfaceView.getHostToken());
+ getDisplayId(),
+ mRemoteSurfaceView.getRootSurfaceControl().getInputTransferToken());
} catch (RemoteException e) {
Log.e(TAG, "Failed to load embedded SurfaceControl", e);
}