diff options
-rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java index 51ef0ec60c3a..9ec1c7d65a6e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java @@ -50,7 +50,9 @@ import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.os.Bundle; +import android.os.Debug; import android.os.IBinder; +import android.util.Log; import android.view.SurfaceControl; import android.view.WindowManager; import android.window.TransitionInfo; @@ -315,6 +317,20 @@ public class PipTransition extends PipTransitionController implements return startAlphaTypeEnterAnimation(info, startTransaction, finishTransaction, finishCallback); } + + TransitionInfo.Change pipActivityChange = PipTransitionUtils + .getDeferConfigActivityChange(info, pipChange.getTaskInfo().getToken()); + if (pipActivityChange == null) { + // Legacy-enter and swipe-pip-to-home filters did not resolve a scheduled PiP entry. + // Bounds-type enter animation is the last resort, and it requires a config-at-end + // activity amongst the list of changes. If no such change, something went wrong. + Log.wtf(TAG, String.format(""" + PipTransition.startAnimation didn't handle a scheduled PiP entry + transitionInfo=%s, + callers=%s""", info, Debug.getCallers(4))); + return false; + } + return startBoundsTypeEnterAnimation(info, startTransaction, finishTransaction, finishCallback); } else if (transition == mExitViaExpandTransition) { @@ -839,26 +855,15 @@ public class PipTransition extends PipTransitionController implements return true; } - // Sometimes root PiP task can have TF children. These child containers can be collected - // even if they can promote to their parents: e.g. if they are marked as "organized". - // So we count the chain of containers under PiP task as one "real" changing target; - // iterate through changes bottom-to-top to properly identify parents. - int expectedTargetCount = 1; - WindowContainerToken lastPipChildToken = pipChange.getContainer(); - for (int i = info.getChanges().size() - 1; i >= 0; --i) { - TransitionInfo.Change change = info.getChanges().get(i); - if (change == pipChange || change.getContainer() == null) continue; - if (change.getParent() != null && change.getParent().equals(lastPipChildToken)) { - // Allow an extra change since our pinned root task has a child. - ++expectedTargetCount; - lastPipChildToken = change.getContainer(); - } - } - - // If the only root task change in the changes list is a opening type PiP task, - // then this is legacy-enter PiP. - return info.getChanges().size() == expectedTargetCount - && TransitionUtil.isOpeningMode(pipChange.getMode()); + // #getEnterPipTransaction() always attempts to mark PiP activity as config-at-end one. + // However, the activity will only actually be marked config-at-end by Core if it is + // both isVisible and isVisibleRequested, which is when we can't run bounds animation. + // + // So we can use the absence of a config-at-end activity as a signal that we should run + // a legacy-enter PiP animation instead. + return TransitionUtil.isOpeningMode(pipChange.getMode()) + && PipTransitionUtils.getDeferConfigActivityChange( + info, pipChange.getContainer()) == null; } return false; } |