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

Commit dfeea6da authored by Louis Chang's avatar Louis Chang
Browse files

Make sure only the top-most running activity can be active

A visible activity that was behind other non-fullscreen activities
was made active while the activity on above was finishing.

Bug: 155568757
Test: atest ActivityRecordTests
Change-Id: I51097008f12a9f0b02e923a718bd1d374c84195c
parent 83dd0ade
Loading
Loading
Loading
Loading
+1 −10
Original line number Original line Diff line number Diff line
@@ -4783,16 +4783,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (!task.hasChild(this)) {
        if (!task.hasChild(this)) {
            throw new IllegalStateException("Activity not found in its task");
            throw new IllegalStateException("Activity not found in its task");
        }
        }
        final ActivityRecord activityAbove = task.getActivityAbove(this);
        return task.topRunningActivity() == 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;
    }
    }


    void handleAlreadyVisible() {
    void handleAlreadyVisible() {
+10 −0
Original line number Original line Diff line number Diff line
@@ -487,6 +487,16 @@ public class ActivityRecordTests extends ActivityTestsBase {
        assertEquals(true, mActivity.shouldMakeActive(null /* activeActivity */));
        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
    @Test
    public void testShouldResume_stackVisibility() {
    public void testShouldResume_stackVisibility() {
        mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");
        mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");