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

Commit 32a9012d authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Add a null check to move_pip_to_pinned

Since HIERARCHY_OP_TYPE_MOVE_PIP_ACTIVITY_TO_PINNED_TASK
can be technically used wherein any token is provided for the task,
not necessarily one including a PiP activity, we should have a null
check for PiP activity.

We aren't supposed to hit a case like this in normal PiP CUJs;
instead this is relevant for Desktoop Windowing CUJs (e.g. minimize)
where this could be called directly without a pipCandidate provided
earlier through handleRequest into the handler.

Bug: 406374716
Flag: com.android.wm.shell.enable_pip2
Test: minimize to potentially PiP a non-PiPable activity in DW
Change-Id: Ia25989cc8dcfd2c0629e2185cb93f65be68e20a0
parent 3fc3ac3f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1344,10 +1344,17 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
                TaskFragment pipTaskFragment = container.asTaskFragment();
                if (pipTaskFragment == null) {
                    Slog.w(TAG, "Skip applying hierarchy operation " + hop
                            + " as there is no valid task provided");
                    break;
                }
                ActivityRecord pipActivity = pipTaskFragment.getActivity(
                        (activity) -> activity.pictureInPictureArgs != null);
                if (pipActivity == null) {
                    Slog.w(TAG, "Skip applying hierarchy operation " + hop
                            + " as the provided task has no PiP-able activity");
                    break;
                }

                if (pipActivity.isState(RESUMED)) {
                    // schedulePauseActivity() call uses this flag when entering PiP after Recents