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

Commit 0167c302 authored by wilsonshih's avatar wilsonshih
Browse files

Fix non-top activity being boosted while finishing.

The endTask condition should check whether there is no un-finishing
activity in the task.

Fixes: 176942303
Test: atest ActivityRecordTests
Change-Id: Id8e28599ba47af0b17a2f6b834b62acfb8d4e99a
parent ecc7fdfe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2606,7 +2606,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

            finishActivityResults(resultCode, resultData, resultGrants);

            final boolean endTask = task.getActivityBelow(this) == null
            final boolean endTask = task.getTopNonFinishingActivity() == null
                    && !task.isClearingToReuseTask();
            final int transit = endTask ? TRANSIT_OLD_TASK_CLOSE : TRANSIT_OLD_ACTIVITY_CLOSE;
            if (isState(RESUMED)) {
+15 −0
Original line number Diff line number Diff line
@@ -1062,6 +1062,21 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertEquals(STOPPED, nextTop.getState());
    }

    /**
     * Verify that finish bottom activity from a task won't boost it to top.
     */
    @Test
    public void testFinishBottomActivityIfPossible_noZBoost() {
        final ActivityRecord bottomActivity = createActivityWithTask();
        final ActivityRecord topActivity = new ActivityBuilder(mAtm)
                .setTask(bottomActivity.getTask()).build();
        topActivity.mVisibleRequested = true;
        // simulating bottomActivity as a trampoline activity.
        bottomActivity.setState(RESUMED, "test");
        bottomActivity.finishIfPossible("test", false);
        assertFalse(bottomActivity.mNeedsZBoost);
    }

    /**
     * Verify that complete finish request for visible activity must be delayed before the next one
     * becomes visible.