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

Commit 95d3b5b8 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Use InputTransferToken instead of IBinder for embedded windows

When an app is embedding another window, it needs to send the embedded a
token so the host can be associated with the embedded window. The
current API uses a raw IBinder token, but change to use an
InputTransferToken instead. This also modifies the transferTouchGesture
API so it accepts a InputTransferToken from and to objects.

Test: SurfaceControlInputReceiverTests
Test: AttachedSurfaceControlTest
Test: SurfaceControlViewHostTests
Flag: ACONFIG com.android.window.flags.surface_control_input_receiver TRUNKFOOD
Bug: 287076178
Change-Id: Iaa4dca0ca57f9c8760a81783cd384808985e6263
parent 6c2f890b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.view.SurfaceControlViewHost;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.window.InputTransferToken;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -166,7 +167,7 @@ public abstract class InlineSuggestionRenderService extends Service {
                    PixelFormat.TRANSPARENT);

            final SurfaceControlViewHost host = new SurfaceControlViewHost(this, getDisplay(),
                    hostInputToken, "InlineSuggestionRenderService");
                    new InputTransferToken(hostInputToken), "InlineSuggestionRenderService");
            host.setView(suggestionRoot, lp);

            // Set the suggestion view to be non-focusable so that if its background is set to a
+3 −4
Original line number Diff line number Diff line
@@ -24,12 +24,12 @@ import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.hardware.display.DisplayManager;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.view.Display;
import android.view.SurfaceControlViewHost;
import android.view.WindowManager;
import android.window.InputTransferToken;

import com.android.internal.infra.AndroidFuture;
import com.android.internal.util.function.pooled.PooledLambda;
@@ -118,14 +118,13 @@ public abstract class GameSessionService extends Service {
            return;
        }

        IBinder hostToken = new Binder();

        // Use a WindowContext so that views attached to the SurfaceControlViewHost will receive
        // configuration changes (rather than always perceiving the global configuration).
        final Context windowContext = createWindowContext(display,
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, /*options=*/ null);
        SurfaceControlViewHost surfaceControlViewHost =
                new SurfaceControlViewHost(windowContext, display, hostToken, "GameSessionService");
                new SurfaceControlViewHost(windowContext, display,
                        new InputTransferToken(), "GameSessionService");

        gameSession.attach(
                gameSessionController,
+15 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.HardwareBuffer;
import android.os.IBinder;
import android.window.InputTransferToken;
import android.window.SurfaceSyncGroup;

import com.android.window.flags.Flags;
@@ -194,6 +195,20 @@ public interface AttachedSurfaceControl {
            + "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
     */
    @Nullable
    default InputTransferToken getInputTransferToken() {
        throw new UnsupportedOperationException("The getHostToken needs to be "
                + "implemented before making this call.");
    }

    /**
     * Transfer the currently in progress touch gesture from the host to the requested
     * {@link SurfaceControlViewHost.SurfacePackage}. This requires that the
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.window.IScreenRecordingCallback;
import android.window.ISurfaceSyncGroupCompletedListener;
import android.window.ITaskFpsCallback;
import android.window.ITrustedPresentationListener;
import android.window.InputTransferToken;
import android.window.ScreenCapture;
import android.window.TrustedPresentationThresholds;
import android.window.WindowContextInfo;
+8 −4
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.window.ClientWindowFrames;
import android.window.InputTransferToken;
import android.window.OnBackInvokedCallbackInfo;

import java.util.List;
@@ -310,8 +311,9 @@ interface IWindowSession {
    * be used as unique identifier.
    */
    void grantInputChannel(int displayId, in SurfaceControl surface, in IBinder clientToken,
            in IBinder hostInputToken, int flags, int privateFlags, int inputFeatures, int type,
            in IBinder windowToken, in IBinder focusGrantToken, String inputHandleName,
            in @nullable InputTransferToken hostInputTransferToken, int flags, int privateFlags,
            int inputFeatures, int type, in IBinder windowToken,
            in InputTransferToken embeddedInputTransferToken, String inputHandleName,
            out InputChannel outInputChannel);

    /**
@@ -332,7 +334,8 @@ interface IWindowSession {
     *                     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);
    void grantEmbeddedWindowFocus(IWindow window, in InputTransferToken inputToken,
            boolean grantFocus);

    /**
     * Generates an DisplayHash that can be used to validate whether specific content was on
@@ -369,7 +372,8 @@ interface IWindowSession {

    boolean transferEmbeddedTouchFocusToHost(IWindow embeddedWindow);

    boolean transferHostTouchGestureToEmbedded(IWindow hostWindow, IBinder transferTouchToken);
    boolean transferHostTouchGestureToEmbedded(IWindow hostWindow,
        in InputTransferToken transferTouchToken);

    /**
     * Moves the focus to the adjacent window if there is one in the given direction. This can only
Loading