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

Commit 4f95f02d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "PIP: pass grant focus token to focus requests"

parents 812adb84 70190ee1
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.Log;
import android.view.accessibility.IAccessibilityEmbeddedConnection;
import android.view.InsetsState;
import android.view.WindowManagerGlobal;
import android.view.accessibility.IAccessibilityEmbeddedConnection;

import java.util.Objects;

@@ -428,4 +428,11 @@ public class SurfaceControlViewHost {
        WindowManagerGlobal.getInstance().removeWindowlessRoot(mViewRoot);
        mReleased = true;
    }

    /**
     * @hide
     */
    public IBinder getFocusGrantToken() {
        return mWm.getFocusGrantToken();
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -191,6 +191,19 @@ public class SystemWindows {
        return null;
    }

    /**
     * Gets a token associated with the view that can be used to grant the view focus.
     */
    public IBinder getFocusGrantToken(View view) {
        SurfaceControlViewHost root = mViewRoots.get(view);
        if (root == null) {
            Slog.e(TAG, "Couldn't get focus grant token since view does not exist in "
                    + "SystemWindow:" + view);
            return null;
        }
        return root.getFocusGrantToken();
    }

    private class PerDisplay {
        final int mDisplayId;
        private final SparseArray<SysUiWindowManager> mWwms = new SparseArray<>();
+2 −5
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Debug;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.util.Size;
@@ -126,7 +125,6 @@ public class PhonePipMenuController implements PipMenuController {
    private int mMenuState;

    private PipMenuView mPipMenuView;
    private IBinder mPipMenuInputToken;

    private ActionListener mMediaActionListener = new ActionListener() {
        @Override
@@ -206,7 +204,6 @@ public class PhonePipMenuController implements PipMenuController {
        mApplier = null;
        mSystemWindows.removeView(mPipMenuView);
        mPipMenuView = null;
        mPipMenuInputToken = null;
    }

    /**
@@ -392,7 +389,6 @@ public class PhonePipMenuController implements PipMenuController {

        if (mApplier == null) {
            mApplier = new SyncRtSurfaceTransactionApplier(mPipMenuView);
            mPipMenuInputToken = mPipMenuView.getViewRootImpl().getInputToken();
        }

        return mApplier != null;
@@ -539,7 +535,8 @@ public class PhonePipMenuController implements PipMenuController {

            try {
                WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
                        mPipMenuInputToken, menuState != MENU_STATE_NONE /* grantFocus */);
                        mSystemWindows.getFocusGrantToken(mPipMenuView),
                        menuState != MENU_STATE_NONE /* grantFocus */);
            } catch (RemoteException e) {
                Log.e(TAG, "Unable to update focus as menu appears/disappears", e);
            }
+1 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
        mSystemWindows.addView(mPipMenuView,
                getPipMenuLayoutParams(MENU_WINDOW_TITLE, 0 /* width */, 0 /* height */),
                0, SHELL_ROOT_LAYER_PIP);
        mPipMenuView.setFocusGrantToken(mSystemWindows.getFocusGrantToken(mPipMenuView));
    }

    @Override
+7 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.app.PendingIntent;
import android.app.RemoteAction;
import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
@@ -69,6 +70,7 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
    private final ImageView mArrowRight;
    private final ImageView mArrowDown;
    private final ImageView mArrowLeft;
    private IBinder mFocusGrantToken = null;

    public TvPipMenuView(@NonNull Context context) {
        this(context, null);
@@ -108,6 +110,10 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
        mListener = listener;
    }

    void setFocusGrantToken(IBinder token) {
        mFocusGrantToken = token;
    }

    void show(boolean inMoveMode, int gravity) {
        if (DEBUG) Log.d(TAG, "show(), inMoveMode: " + inMoveMode);
        grantWindowFocus(true);
@@ -162,7 +168,7 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {

        try {
            WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
                    getViewRootImpl().getInputToken(), grantFocus);
                    mFocusGrantToken, grantFocus);
        } catch (Exception e) {
            Log.e(TAG, "Unable to update focus", e);
        }