diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 131e449630335..d177c12362e8c 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4785,16 +4785,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (!task.hasChild(this)) { throw new IllegalStateException("Activity not found in its task"); } - final ActivityRecord activityAbove = task.getActivityAbove(this); - if (activityAbove == null) { - // It's the topmost activity in the task - should become resumed now - return true; - } - // Check if activity above is finishing now and this one becomes the topmost in task. - if (activityAbove.finishing) { - return true; - } - return false; + return task.topRunningActivity() == this; } void handleAlreadyVisible() { 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 8cfe96f0db5ae..2bc347883dfa1 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -487,6 +487,16 @@ public class ActivityRecordTests extends ActivityTestsBase { assertEquals(true, mActivity.shouldMakeActive(null /* activeActivity */)); } + @Test + public void testShouldMakeActive_nonTopVisible() { + ActivityRecord finishingActivity = new ActivityBuilder(mService).setTask(mTask).build(); + finishingActivity.finishing = true; + ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); + mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing"); + + assertEquals(false, mActivity.shouldMakeActive(null /* activeActivity */)); + } + @Test public void testShouldResume_stackVisibility() { mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");