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

Commit 9abde299 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Update task surface visibility with reparent for pip

When a pip activity is reparented to its original task on top,
the task becomes visible because now it contains a visible activity.
This happens when leaving pip to fullscreen, i.e. finishTransition.
Currently the reparent operation is not included in a transition,
so the surface operations use pending transaction. But there can
be a orientation change happens in finishTransition, which triggers
to start collecting all visible tasks, which will make them use
sync transaction. Then if prepareSurfaces is called after that,
the "reparent" and "show" will be applied by different transactions.
Which could causes to flicker. So this change makes sure the
"reparent" and "show" are applied in the same transaction.

It was lucky that surface placement contains all prepareSurface,
since it was optimized out, invoke it explicitly.

Bug: 335046662
Test: Enter pip from a task which contains multiple activities.
      Expand the pip activity from portrait to landscape.
      The task should not disappear a few frames.
Change-Id: I48021aecf64311016747c58d1fdcb9e3381e5f92
parent b3942280
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -4813,6 +4813,14 @@ class Task extends TaskFragment {
                                topActivity.getSyncTransaction());
                                topActivity.getSyncTransaction());
                    }
                    }
                    lastParentBeforePip.moveToFront("movePinnedActivityToOriginalTask");
                    lastParentBeforePip.moveToFront("movePinnedActivityToOriginalTask");
                    // If the reparent is not included in transition, make sure the visibility of
                    // task is still updated by core. Otherwise if the task is collected (e.g.
                    // rotation change) after leaving this scope, the visibility operation will be
                    // put in sync transaction, then it is not synced with reparent.
                    if (com.android.window.flags.Flags.removePrepareSurfaceInPlacement()
                            && lastParentBeforePip.mSyncState == SYNC_STATE_NONE) {
                        lastParentBeforePip.prepareSurfaces();
                    }
                }
                }
                if (isPip2ExperimentEnabled) {
                if (isPip2ExperimentEnabled) {
                    super.setWindowingMode(windowingMode);
                    super.setWindowingMode(windowingMode);