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

Commit fe5347e9 authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Explicitly focus PIP Menu when shown."

parents 8b45facc e565c60b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -548,16 +548,17 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize

    /**
     * Setup the ViewHost and attach the provided menu view to the ViewHost.
     * @return The input token belonging to the PipMenuView.
     */
    public void attachPipMenuViewHost(View menuView, WindowManager.LayoutParams lp) {
    public IBinder attachPipMenuViewHost(View menuView, WindowManager.LayoutParams lp) {
        if (mPipMenuSurface != null) {
            Log.e(TAG, "PIP Menu View already created and attached.");
            return;
            return null;
        }

        if (mLeash == null) {
            Log.e(TAG, "PiP Leash is not yet ready.");
            return;
            return null;
        }

        if (Looper.getMainLooper() != Looper.myLooper()) {
@@ -573,6 +574,8 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
        transaction.setRelativeLayer(mPipMenuSurface, mLeash, 1);
        transaction.apply();
        mPipViewHost.setView(menuView, lp);

        return mPipViewHost.getSurfacePackage().getInputToken();
    }


+18 −1
Original line number Diff line number Diff line
@@ -27,10 +27,12 @@ import android.content.pm.ParceledListSlice;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Debug;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;

import com.android.systemui.pip.PipTaskOrganizer;
import com.android.systemui.pip.phone.PipMediaController.ActionListener;
@@ -92,6 +94,7 @@ public class PipMenuActivityController {
    private int mMenuState;

    private PipMenuView mPipMenuView;
    private IBinder mPipMenuInputToken;

    private ActionListener mMediaActionListener = new ActionListener() {
        @Override
@@ -120,6 +123,7 @@ public class PipMenuActivityController {
        hideMenu();
        mPipTaskOrganizer.detachPipMenuViewHost();
        mPipMenuView = null;
        mPipMenuInputToken = null;
    }

    public void onPinnedStackAnimationEnded() {
@@ -133,7 +137,13 @@ public class PipMenuActivityController {
            mPipMenuView = new PipMenuView(mContext, this);

        }
        mPipTaskOrganizer.attachPipMenuViewHost(mPipMenuView, getPipMenuLayoutParams(0, 0));

        // If we haven't gotten the input toekn, that means we haven't had a success attempt
        // yet at attaching the PipMenuView
        if (mPipMenuInputToken == null) {
            mPipMenuInputToken = mPipTaskOrganizer.attachPipMenuViewHost(mPipMenuView,
                    getPipMenuLayoutParams(0, 0));
        }
    }

    /**
@@ -352,6 +362,13 @@ public class PipMenuActivityController {
                // the menu actions to be updated again.
                mMediaController.removeListener(mMediaActionListener);
            }

            try {
                WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
                        mPipMenuInputToken, menuState != MENU_STATE_NONE /* grantFocus */);
            } catch (RemoteException e) {
                Log.e(TAG, "Unable to update focus as menu appears/disappears", e);
            }
        }
        mMenuState = menuState;
    }
+0 −4
Original line number Diff line number Diff line
@@ -154,10 +154,6 @@ public class PipMenuView extends FrameLayout {
                expandPip();
            }
        });
        // TODO (b/161710689): Remove this once focusability for Windowless window is working
        findViewById(R.id.expand_button).setFocusable(false);
        mDismissButton.setFocusable(false);
        mSettingsButton.setFocusable(false);

        mResizeHandle = findViewById(R.id.resize_handle);
        mResizeHandle.setAlpha(0);