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

Commit b3778a93 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure to resume home if there is no other activity" into qt-dev

parents 885109a4 2b9a6d7c
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -1323,14 +1323,17 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        }
    }

    /** Returns true if the focus activity was adjusted to the home stack top activity. */
    boolean moveHomeActivityToTop(String reason) {
    /**
     * Moves the focusable home activity to top. If there is no such activity, the home stack will
     * still move to top.
     */
    void moveHomeActivityToTop(String reason) {
        final ActivityRecord top = getHomeActivity();
        if (top == null) {
            return false;
            moveHomeStackToFront(reason);
            return;
        }
        top.moveFocusableActivityToTop(reason);
        return true;
    }

    @Nullable
+17 −0
Original line number Diff line number Diff line
@@ -929,6 +929,23 @@ public class ActivityStackTests extends ActivityTestsBase {
        assertThat(mStack.getAllTasks()).isEmpty();
    }

    @Test
    public void testAdjustFocusedStackToHomeWhenNoActivity() {
        final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
        mStack.moveToFront("testAdjustFocusedStack");

        final ActivityStack homeStask = mDefaultDisplay.getHomeStack();
        final TaskRecord homeTask = homeStask.topTask();
        // Simulate that home activity has not been started or is force-stopped.
        homeStask.removeTask(homeTask, "testAdjustFocusedStack", REMOVE_TASK_MODE_DESTROYING);

        // Finish the only activity.
        mStack.finishActivityLocked(topActivity, 0 /* resultCode */, null /* resultData */,
                "testAdjustFocusedStack", false /* oomAdj */);
        // Although home stack is empty, it should still be the focused stack.
        assertEquals(homeStask, mDefaultDisplay.getFocusedStack());
    }

    @Test
    public void testWontFinishHomeStackImmediately() {
        final ActivityStack homeStack = createStackForShouldBeVisibleTest(mDefaultDisplay,