summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Louis Chang <louischang@google.com> 2023-10-24 18:08:23 +0000
committer Louis Chang <louischang@google.com> 2023-10-25 17:38:06 +0000
commit5a8077554e5fda02cde63c19e59f526309698aa8 (patch)
tree37fd246f13a8b5f34d1500fa5a97a9c454dfd322
parent42d5498bc332c766d58178979bfaab27a3ae34ea (diff)
Pausing the transient-hide activities immediately
...when the transient-launch is set to resume-while-pausing In the legacy transition, the previous top activity is paused immediately when transition is completed while swiping up to return to home because the home activity is resume-while-pausing=true. Somehow, the home activity is already resumed due to transient launch in shell transition and therefore the ATM would wait for the previous activity to be paused before able to start new activities. Bug: 304181511 Test: atest TransitionTests Test: swiping up to home Change-Id: I397522c3725c348f9236ca300e4979f38f9e2d0a
-rw-r--r--services/core/java/com/android/server/wm/Transition.java26
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TransitionTests.java3
2 files changed, 25 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 7d65c61193b5..fe2f0036609a 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -1046,7 +1046,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
* @return true if we are *guaranteed* to enter-pip. This means we return false if there's
* a chance we won't thus legacy-entry (via pause+userLeaving) will return false.
*/
- private boolean checkEnterPipOnFinish(@NonNull ActivityRecord ar) {
+ private boolean checkEnterPipOnFinish(@NonNull ActivityRecord ar,
+ @Nullable ActivityRecord resuming) {
if (!mCanPipOnFinish || !ar.isVisible() || ar.getTask() == null || !ar.isState(RESUMED)) {
return false;
}
@@ -1091,8 +1092,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
try {
// If not going auto-pip, the activity should be paused with user-leaving.
mController.mAtm.mTaskSupervisor.mUserLeaving = true;
- ar.getTaskFragment().startPausing(false /* uiSleeping */,
- null /* resuming */, "finishTransition");
+ ar.getTaskFragment().startPausing(false /* uiSleeping */, resuming, "finishTransition");
} finally {
mController.mAtm.mTaskSupervisor.mUserLeaving = false;
}
@@ -1190,7 +1190,9 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
final boolean isScreenOff = ar.mDisplayContent == null
|| ar.mDisplayContent.getDisplayInfo().state == Display.STATE_OFF;
if ((!visibleAtTransitionEnd || isScreenOff) && !ar.isVisibleRequested()) {
- final boolean commitVisibility = !checkEnterPipOnFinish(ar);
+ final ActivityRecord resuming = getVisibleTransientLaunch(
+ ar.getTaskDisplayArea());
+ final boolean commitVisibility = !checkEnterPipOnFinish(ar, resuming);
// Avoid commit visibility if entering pip or else we will get a sudden
// "flash" / surface going invisible for a split second.
if (commitVisibility) {
@@ -1410,6 +1412,22 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
mController.mSnapshotController.onTransitionFinish(mType, mTargets);
}
+ @Nullable
+ private ActivityRecord getVisibleTransientLaunch(TaskDisplayArea taskDisplayArea) {
+ if (mTransientLaunches == null) return null;
+ for (int i = mTransientLaunches.size() - 1; i >= 0; --i) {
+ final ActivityRecord candidateActivity = mTransientLaunches.keyAt(i);
+ if (candidateActivity.getTaskDisplayArea() != taskDisplayArea) {
+ continue;
+ }
+ if (!candidateActivity.isVisible()) {
+ continue;
+ }
+ return candidateActivity;
+ }
+ return null;
+ }
+
void abort() {
// This calls back into itself via controller.abort, so just early return here.
if (mState == STATE_ABORT) return;
diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
index c8546c613995..8998044d4803 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
@@ -1439,6 +1439,7 @@ public class TransitionTests extends WindowTestsBase {
activity1.setVisibleRequested(true);
activity1.setVisible(true);
activity2.setVisibleRequested(false);
+ activity1.setState(ActivityRecord.State.RESUMED, "test");
// Using abort to force-finish the sync (since we can't wait for drawing in unit test).
// We didn't call abort on the transition itself, so it will still run onTransactionReady
@@ -1517,6 +1518,8 @@ public class TransitionTests extends WindowTestsBase {
// Make sure activity1 visibility was committed
assertFalse(activity1.isVisible());
assertFalse(activity1.app.hasActivityInVisibleTask());
+ // Make sure the userLeaving is true and the resuming activity is given,
+ verify(task1).startPausing(eq(true), anyBoolean(), eq(activity2), any());
verify(taskSnapshotController, times(1)).recordSnapshot(eq(task1));
assertTrue(enteringAnimReports.contains(activity2));