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

Commit 92d5b68e authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Return resume result in resumeFocusedStacksTopActivities"

parents 0dcae0eb 4c9824a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1154,7 +1154,7 @@ class RootActivityContainer extends ConfigurationContainer
                // activity is started and resumed, and no recursion occurs.
                final ActivityStack focusedStack = display.getFocusedStack();
                if (focusedStack != null) {
                    focusedStack.resumeTopActivityUncheckedLocked(target, targetOptions);
                    result |= focusedStack.resumeTopActivityUncheckedLocked(target, targetOptions);
                }
            }
        }
+37 −2
Original line number Diff line number Diff line
@@ -836,6 +836,14 @@ public class ActivityRecordTests extends ActivityTestsBase {
        // Set process to 'null' to allow immediate removal, but don't call mActivity.setProcess() -
        // this will cause NPE when updating task's process.
        mActivity.app = null;

        // Put a visible activity on top, so the finishing activity doesn't have to wait until the
        // next activity reports idle to destroy it.
        final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
        topActivity.visible = true;
        topActivity.nowVisible = true;
        topActivity.setState(RESUMED, "test");

        assertEquals("Activity outside of task/stack cannot be finished", FINISH_RESULT_REMOVED,
                mActivity.finishIfPossible("test", false /* oomAdj */));
        assertTrue(mActivity.finishing);
@@ -1131,8 +1139,11 @@ public class ActivityRecordTests extends ActivityTestsBase {
        // Add another stack to become focused and make the activity there visible. This way it
        // simulates finishing in non-focused stack in split-screen.
        final ActivityStack stack = new StackBuilder(mRootActivityContainer).build();
        stack.getChildAt(0).getChildAt(0).nowVisible = true;
        stack.getChildAt(0).getChildAt(0).visible = true;
        final ActivityRecord focusedActivity = stack.getChildAt(0).getChildAt(0);
        focusedActivity.nowVisible = true;
        focusedActivity.visible = true;
        focusedActivity.setState(RESUMED, "test");
        stack.mResumedActivity = focusedActivity;

        topActivity.completeFinishing("test");

@@ -1179,6 +1190,30 @@ public class ActivityRecordTests extends ActivityTestsBase {
        assertTrue(mActivity.mStackSupervisor.mFinishingActivities.contains(mActivity));
    }

    /**
     * Verify that complete finish request for visible activity must resume next home stack before
     * destroying it immediately if it is the last running activity on a display with a home stack.
     * We must wait for home activity to come up to avoid a black flash in this case.
     */
    @Test
    public void testCompleteFinishing_lastActivityAboveEmptyHomeStack() {
        // Empty the home stack.
        final ActivityStack homeStack = mActivity.getDisplay().getHomeStack();
        for (TaskRecord t : homeStack.getAllTasks()) {
            homeStack.removeTask(t, "test", REMOVE_TASK_MODE_DESTROYING);
        }
        mActivity.finishing = true;
        spyOn(mStack);

        // Try to finish the last activity above the home stack.
        mActivity.completeFinishing("test");

        // Verify that the activity is not destroyed immediately, but waits for next one to come up.
        verify(mActivity, never()).destroyImmediately(eq(true) /* removeFromApp */, anyString());
        assertEquals(FINISHING, mActivity.getState());
        assertTrue(mActivity.mStackSupervisor.mFinishingActivities.contains(mActivity));
    }

    /**
     * Test that the activity will be moved to destroying state and the message to destroy will be
     * sent to the client.