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

Commit 08488a61 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Don't defer client hidden if activity is already paused

We defer client hidden to allow activities that support pip to
enter pip before onPause() returns. However, the condition only
checked for stopping and stopped states. There are situations
where the app is already paused and we are now moving it to the
invisible-stopped state. For does cases we need to make sure not
to defer client hidden, so that the right visibility is reported
to the app and the app can in-turn relayout out its windows to
invisible so that window manager can distroy and surfaces
associated with the windows when the exit animation is done.

Change-Id: Ib1c4cf6a989f597ba700ce460fca4b012bf5146b
Fixes: 63117546
Test: go/wm-smoke
parent 1b6f93c1
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_USER_LEAV
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBILITY;
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBILITY;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.am.ActivityStack.ActivityState.PAUSED;
import static com.android.server.am.ActivityStack.ActivityState.STOPPED;
import static com.android.server.am.ActivityStack.ActivityState.STOPPED;
import static com.android.server.am.ActivityStack.ActivityState.STOPPING;
import static com.android.server.am.ActivityStack.ActivityState.STOPPING;
import static com.android.server.am.ActivityStackSupervisor.FindTaskResult;
import static com.android.server.am.ActivityStackSupervisor.FindTaskResult;
@@ -2059,10 +2060,15 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        try {
        try {
            final boolean canEnterPictureInPicture = r.checkEnterPictureInPictureState(
            final boolean canEnterPictureInPicture = r.checkEnterPictureInPictureState(
                    "makeInvisible", true /* beforeStopping */);
                    "makeInvisible", true /* beforeStopping */);
            // Defer telling the client it is hidden if it can enter Pip and isn't current stopped
            // Defer telling the client it is hidden if it can enter Pip and isn't current paused,
            // or stopping. This gives it a chance to enter Pip in onPause().
            // stopped or stopping. This gives it a chance to enter Pip in onPause().
            // TODO: There is still a question surrounding activities in multi-window mode that want
            // to enter Pip after they are paused, but are still visible. I they should be okay to
            // enter Pip in those cases, but not "auto-Pip" which is what this condition covers and
            // the current contract for "auto-Pip" is that the app should enter it before onPause
            // returns. Just need to confirm this reasoning makes sense.
            final boolean deferHidingClient = canEnterPictureInPicture
            final boolean deferHidingClient = canEnterPictureInPicture
                    && r.state != STOPPING && r.state != STOPPED;
                    && r.state != STOPPING && r.state != STOPPED && r.state != PAUSED;
            r.setDeferHidingClient(deferHidingClient);
            r.setDeferHidingClient(deferHidingClient);
            r.setVisible(false);
            r.setVisible(false);