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

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

Merge "PiP: Attach PiP Menu at showMenu() if it's not yet attached."

parents 6e83a6ba f9b6fb1e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -551,6 +551,11 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
            return;
        }

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

        if (Looper.getMainLooper() != Looper.myLooper()) {
            throw new RuntimeException("PipMenuView needs to be attached on the main thread.");
        }
@@ -580,6 +585,13 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
        }
    }

    /**
     * Return whether the PiP Menu has been attached to the leash yet.
     */
    public boolean isPipMenuViewHostAttached() {
        return mPipViewHost != null;
    }


    /**
     * Note that dismissing PiP is now originated from SystemUI, see {@link #exitPip(int)}.
+13 −9
Original line number Diff line number Diff line
@@ -118,12 +118,7 @@ public class PipMenuActivityController {
    }

    public void onActivityPinned() {
        if (mPipMenuView == null) {
            WindowManager.LayoutParams lp =
                    getPipMenuLayoutParams(0, 0);
            mPipMenuView = new PipMenuView(mContext, this);
            mPipTaskOrganizer.attachPipMenuViewHost(mPipMenuView, lp);
        }
        attachPipMenuView();
        mInputConsumerController.registerInputConsumer(true /* withSfVsync */);
    }

@@ -140,6 +135,14 @@ public class PipMenuActivityController {
        }
    }

    private void attachPipMenuView() {
        if (mPipMenuView == null) {
            mPipMenuView = new PipMenuView(mContext, this);

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

    /**
     * Adds a new menu activity listener.
     */
@@ -197,10 +200,11 @@ public class PipMenuActivityController {
                    + " callers=\n" + Debug.getCallers(5, "    "));
        }

        if (mPipMenuView == null) {
            Log.e(TAG, "PipMenu has not been attached yet.");
            return;
        if (!mPipTaskOrganizer.isPipMenuViewHostAttached()) {
            Log.d(TAG, "PipMenu has not been attached yet. Attaching now at showMenuInternal().");
            attachPipMenuView();
        }

        mPipMenuView.showMenu(menuState, stackBounds, allowMenuTimeout, willResizeMenu, withDelay,
                showResizeHandle);
    }