summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andrii Kulian <akulian@google.com> 2019-01-31 18:20:11 -0800
committer Andrii Kulian <akulian@google.com> 2019-01-31 18:20:11 -0800
commitf21953666ddc644c5cf4996a682ec00a2820d0ba (patch)
tree0cec969d5f97699b0ee2fc36aff2f96f9c6c43db
parent8b7275695adffd2c65210d45d0121aa0c299097d (diff)
Fix deferring making activities active
New logic for checking whether activities should be made active did not take into account deferring resume during launch. This lead to making activity resumed before actually launching it, and top-resumed state change callback was ignored on the client side since activity was not registered on the client yet. This in turn made the client think that it was never made top-resumed before loosing the top-resumed position. Bug: 123587738 Test: atest WmTests:ActivityRecordTests#testShouldMakeActive_deferredResume Change-Id: Ieb3b98b4ddb4819805fa0e818ecf8359487eaaff
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java11
2 files changed, 18 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index aa0c62c65973..38e8785b0692 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -2065,7 +2065,8 @@ final class ActivityRecord extends ConfigurationContainer {
* - should be either the topmost in task, or right below the top activity that is finishing
* If all of these conditions are not met at the same time, the activity cannot be made active.
*/
- private boolean shouldMakeActive(ActivityRecord activeActivity) {
+ @VisibleForTesting
+ boolean shouldMakeActive(ActivityRecord activeActivity) {
// If the activity is stopped, stopping, cycle to an active state. We avoid doing
// this when there is an activity waiting to become translucent as the extra binder
// calls will lead to noticeable jank. A later call to
@@ -2080,6 +2081,11 @@ final class ActivityRecord extends ConfigurationContainer {
return false;
}
+ if (!mStackSupervisor.readyToResume()) {
+ // Making active is currently deferred (e.g. because an activity launch is in progress).
+ return false;
+ }
+
if (this.mLaunchTaskBehind) {
// This activity is being launched from behind, which means that it's not intended to be
// presented to user right now, even if it's set to be visible.
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index 319ffed3778c..f1506a0ebc22 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -368,4 +368,15 @@ public class ActivityRecordTests extends ActivityTestsBase {
verify(mService.getLifecycleManager()).scheduleTransaction(eq(mActivity.app.getThread()),
eq(mActivity.appToken), eq(expected));
}
+
+ @Test
+ public void testShouldMakeActive_deferredResume() {
+ mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");
+
+ mSupervisor.beginDeferResume();
+ assertEquals(false, mActivity.shouldMakeActive(null /* activeActivity */));
+
+ mSupervisor.endDeferResume();
+ assertEquals(true, mActivity.shouldMakeActive(null /* activeActivity */));
+ }
}