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

Commit fe47d228 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Update SCVH InputTransferToken when available" into main

parents 037ca2ad 29372d3f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.graphics.Rect;
import android.view.InsetsState;
import android.view.ISurfaceControlViewHostParent;
import android.window.ISurfaceSyncGroup;
import android.window.InputTransferToken;

/**
 * API from content embedder back to embedded content in SurfaceControlViewHost
@@ -32,6 +33,7 @@ interface ISurfaceControlViewHost {
     * APIs that are blocking
     */
    oneway void onConfigurationChanged(in Configuration newConfig);
    oneway void onDispatchAttachedToWindow(in InputTransferToken token);
    oneway void onDispatchDetachedFromWindow();
    oneway void onInsetsChanged(in InsetsState state, in Rect insetFrame);
    ISurfaceSyncGroup getSurfaceSyncGroup();
+3 −2
Original line number Diff line number Diff line
@@ -313,8 +313,9 @@ interface IWindowSession {
    /**
     * Update the flags on an input channel associated with a particular surface.
     */
    oneway void updateInputChannel(in IBinder channelToken, int displayId,
            in SurfaceControl surface, int flags, int privateFlags, int inputFeatures,
    oneway void updateInputChannel(in IBinder channelToken,
            in @nullable InputTransferToken hostInputTransferToken,
            int displayId, in SurfaceControl surface, int flags, int privateFlags, int inputFeatures,
            in Region region);

    /**
+14 −0
Original line number Diff line number Diff line
@@ -78,6 +78,20 @@ public class SurfaceControlViewHost {
            });
        }

        @Override
        public void onDispatchAttachedToWindow(InputTransferToken hostInputTransferToken) {
            boolean hostInputTransferTokenChanged =
                    !Objects.equals(hostInputTransferToken, mWm.mHostInputTransferToken);
            if (!hostInputTransferTokenChanged) {
                return;
            }

            mWm.setHostInputTransferToken(hostInputTransferToken);
            if (mViewRoot != null && mViewRoot.mView != null) {
                mWm.updateInputChannel(getWindowToken().asBinder());
            }
        }

        @Override
        public void onDispatchDetachedFromWindow() {
            if (mViewRoot == null) {
+33 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;


import static android.view.flags.Flags.FLAG_DEPRECATE_SURFACE_VIEW_Z_ORDER_APIS;
import static android.view.flags.Flags.FLAG_SURFACE_VIEW_GET_SURFACE_PACKAGE;
import static android.view.flags.Flags.FLAG_SURFACE_VIEW_SET_COMPOSITION_ORDER;
@@ -23,6 +24,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static android.view.WindowManagerPolicyConstants.APPLICATION_MEDIA_OVERLAY_SUBLAYER;
import static android.view.WindowManagerPolicyConstants.APPLICATION_MEDIA_SUBLAYER;
import static android.view.WindowManagerPolicyConstants.APPLICATION_PANEL_SUBLAYER;
import static android.view.flags.Flags.FLAG_SURFACE_VIEW_GET_SURFACE_PACKAGE;
import static android.view.flags.Flags.FLAG_SURFACE_VIEW_SET_COMPOSITION_ORDER;

import android.annotation.FlaggedApi;
import android.annotation.FloatRange;
@@ -59,6 +62,7 @@ import android.util.Log;
import android.view.SurfaceControl.Transaction;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.IAccessibilityEmbeddedConnection;
import android.window.InputTransferToken;
import android.window.SurfaceSyncGroup;

import com.android.graphics.hwui.flags.Flags;
@@ -347,7 +351,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                    sv.mSurfacePackage.getRemoteInterface().attachParentInterface(this);
                    mSurfaceView = sv;
                } catch (RemoteException e) {
                    Log.d(TAG, "Failed to attach parent interface to SCVH. Likely SCVH is alraedy "
                    Log.d(TAG, "Failed to attach parent interface to SCVH. Likely SCVH is already "
                            + "dead.");
                }
            }
@@ -492,10 +496,37 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        mTag = "SV[" + System.identityHashCode(this) + windowName + "]";
    }

    private void dispatchScvhAttachedToHost() {
        final ViewRootImpl viewRoot = getViewRootImpl();
        if (viewRoot == null) {
            return;
        }

        IBinder inputToken = viewRoot.getInputToken();
        if (inputToken == null) {
            // We don't have an input channel so we can't transfer focus or active
            // touch gestures to embedded.
            return;
        }

        try {
            mSurfacePackage
                    .getRemoteInterface()
                    .onDispatchAttachedToWindow(new InputTransferToken(inputToken));
        } catch (RemoteException e) {
            Log.d(TAG,
                    "Failed to onDispatchAttachedToWindow to SCVH. Likely SCVH is already "
                            + "dead.");
        }
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        setTag();
        if (mSurfacePackage != null) {
            dispatchScvhAttachedToHost();
        }
        getViewRootImpl().addSurfaceChangedCallback(this);
        mWindowStopped = false;
        mViewVisibility = getVisibility() == VISIBLE;
@@ -2189,6 +2220,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
            applyTransactionOnVriDraw(transaction);
        }
        mSurfacePackage = p;
        dispatchScvhAttachedToHost();
        mSurfaceControlViewHostParent.attach(this);

        if (isFocused()) {
+3 −2
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_HIGH_HINT;
import static android.view.Surface.FRAME_RATE_CATEGORY_LOW;
import static android.view.Surface.FRAME_RATE_CATEGORY_NORMAL;
import static android.view.Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_AT_LEAST;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
import static android.view.View.FRAME_RATE_CATEGORY_REASON_BOOST;
import static android.view.View.FRAME_RATE_CATEGORY_REASON_CONFLICTED;
import static android.view.View.FRAME_RATE_CATEGORY_REASON_INTERMITTENT;
@@ -2683,7 +2683,8 @@ public final class ViewRootImpl implements ViewParent,
            mStopped = stopped;
            final ThreadedRenderer renderer = mAttachInfo.mThreadedRenderer;
            if (renderer != null) {
                if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle() + " set to " + mStopped);
                if (DEBUG_DRAW)
                    Log.d(mTag, "WindowStopped on " + getTitle() + " set to " + mStopped);
                renderer.setStopped(mStopped);
            }
            if (!mStopped) {
Loading