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

Commit 8d0616af authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Destroy ActivityRecord when it is removed from the hierarchy" into sc-v2-dev

parents 0f7c56a2 eccc88a8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3687,7 +3687,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


    @Override
    @Override
    void removeImmediately() {
    void removeImmediately() {
        if (!finishing) {
        if (!isState(DESTROYING, DESTROYED)) {
            // If Task#removeImmediately is called directly with alive activities, ensure that the
            // If Task#removeImmediately is called directly with alive activities, ensure that the
            // activities are destroyed and detached from process.
            // activities are destroyed and detached from process.
            destroyImmediately("removeImmediately");
            destroyImmediately("removeImmediately");
+15 −0
Original line number Original line Diff line number Diff line
@@ -1615,6 +1615,21 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertFalse(wpc.hasActivities());
        assertFalse(wpc.hasActivities());
    }
    }


    @Test
    public void testRemoveImmediatelyWithFinishingActivity() throws RemoteException {
        final ActivityRecord activity = createActivityWithTask();
        final WindowProcessController wpc = activity.app;
        activity.makeFinishingLocked();
        assertTrue(activity.finishing);

        activity.getTask().removeImmediately("test");

        verify(mAtm.getLifecycleManager()).scheduleTransaction(any(), eq(activity.appToken),
                isA(DestroyActivityItem.class));
        assertFalse(wpc.hasActivities());
        assertEquals(DESTROYING, activity.getState());
    }

    @Test
    @Test
    public void testRemoveFromHistory() {
    public void testRemoveFromHistory() {
        final ActivityRecord activity = createActivityWithTask();
        final ActivityRecord activity = createActivityWithTask();