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

Commit d791cf31 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Add transferHostTouchGestureToEmbedded API

Allow the host to transfer touch gesture to the embedded window.

Renamed focusGrantToken to inputTransferToken so it can be used to
transfer focus and gesture from host to embedded.

Test: SurfaceControlViewHostTests#testTransferHostTouchGestureToEmbedded
Bug: 303254234
Change-Id: Ie09121eccce46237d96b1a3233792bd3f3f3fd23
parent c6e96867
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49810,6 +49810,7 @@ package android.view {
    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);
    method @FlaggedApi("com.android.window.flags.transfer_gesture_to_embedded") public default boolean transferHostTouchGestureToEmbedded(@NonNull android.view.SurfaceControlViewHost.SurfacePackage);
  }
  @UiThread public static interface AttachedSurfaceControl.OnBufferTransformHintChangedListener {
+15 −0
Original line number Diff line number Diff line
@@ -231,4 +231,19 @@ public interface AttachedSurfaceControl {
    default void removeTrustedPresentationCallback(@NonNull SurfaceControl.Transaction t,
            @NonNull Consumer<Boolean> listener) {
    }

    /**
     * Transfer the currently in progress touch gesture from the host to the requested
     * {@link SurfaceControlViewHost.SurfacePackage}. This requires that the
     * SurfaceControlViewHost was created with the current host's inputToken.
     *
     * @param surfacePackage The SurfacePackage to transfer the gesture to.
     * @return Whether the touch stream was transferred.
     */
    @FlaggedApi(Flags.FLAG_TRANSFER_GESTURE_TO_EMBEDDED)
    default boolean transferHostTouchGestureToEmbedded(
            @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage) {
        throw new UnsupportedOperationException(
                "transferHostTouchGestureToEmbedded is unimplemented");
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -357,4 +357,6 @@ interface IWindowSession {
    boolean cancelDraw(IWindow window);

    boolean transferEmbeddedTouchFocusToHost(IWindow embeddedWindow);

    boolean transferHostTouchGestureToEmbedded(IWindow hostWindow, IBinder transferTouchToken);
}
+4 −2
Original line number Diff line number Diff line
@@ -287,7 +287,8 @@ public class SurfaceControlViewHost {
        }

        /**
         * Returns an input token used which can be used to request focus on the embedded surface.
         * Returns an input token used which can be used to request focus on the embedded surface
         * or to transfer touch gesture to the embedded surface.
         *
         * @hide
         */
@@ -526,7 +527,8 @@ public class SurfaceControlViewHost {
    }

    /**
     * Returns an input token used which can be used to request focus on the embedded surface.
     * Returns an input token used which can be used to request focus on the embedded surface
     * or to transfer touch gesture to the embedded surface.
     *
     * @hide
     */
+13 −0
Original line number Diff line number Diff line
@@ -11893,4 +11893,17 @@ public final class ViewRootImpl implements ViewParent,
        }
        Log.d(mTag, msg);
    }

    @Override
    public boolean transferHostTouchGestureToEmbedded(
            @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage) {
        final IWindowSession realWm = WindowManagerGlobal.getWindowSession();
        try {
            return realWm.transferHostTouchGestureToEmbedded(mWindow,
                    surfacePackage.getInputToken());
        } catch (RemoteException e) {
            e.rethrowAsRuntimeException();
        }
        return false;
    }
}
Loading