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

Commit 510dcd6f authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15463863

Change-Id: I352d1cb3f87b6cce1a6d3f27643f0b5b16dbba9f
parents 8ae201fa 8d0616af
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3687,7 +3687,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    @Override
    void removeImmediately() {
        if (!finishing) {
        if (!isState(DESTROYING, DESTROYED)) {
            // If Task#removeImmediately is called directly with alive activities, ensure that the
            // activities are destroyed and detached from process.
            destroyImmediately("removeImmediately");
+15 −0
Original line number Diff line number Diff line
@@ -1615,6 +1615,21 @@ public class ActivityRecordTests extends WindowTestsBase {
        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
    public void testRemoveFromHistory() {
        final ActivityRecord activity = createActivityWithTask();