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

Commit 102603e4 authored by Bryce Lee's avatar Bryce Lee
Browse files

Revert "Always finish activity when moving to a destroyed state."

This reverts commit 7ace395d.

Fixes: 73900028
Change-Id: I8b72dca8e001413d54ab85be07943b6ebc451615
parent c709366f
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -1581,25 +1581,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
    void setState(ActivityState state, String reason) {
        if (DEBUG_STATES) Slog.v(TAG_STATES, "State movement: " + this + " from:" + getState()
                        + " to:" + state + " reason:" + reason);
        final boolean stateChanged = mState != state;
        mState = state;

        if (stateChanged && isState(DESTROYING, DESTROYED)) {
            makeFinishingLocked();

            // When moving to the destroyed state, immediately destroy the activity in the
            // associated stack. Most paths for finishing an activity will handle an activity's path
            // to destroy through mechanisms such as ActivityStackSupervisor#mFinishingActivities.
            // However, moving to the destroyed state directly (as in the case of an app dying) and
            // marking it as finished will lead to cleanup steps that will prevent later handling
            // from happening.
            if (isState(DESTROYED)) {
                final ActivityStack stack = getStack();
                if (stack != null) {
                    stack.activityDestroyedLocked(this, reason);
                }
            }
        }
    }

    ActivityState getState() {
+0 −16
Original line number Diff line number Diff line
@@ -204,20 +204,4 @@ public class ActivityRecordTests extends ActivityTestsBase {
        verify(mService.mStackSupervisor, times(1)).canPlaceEntityOnDisplay(anyInt(), eq(expected),
                anyInt(), anyInt(), eq(record.info));
    }

    @Test
    public void testFinishingAfterDestroying() throws Exception {
        assertFalse(mActivity.finishing);
        mActivity.setState(DESTROYING, "testFinishingAfterDestroying");
        assertTrue(mActivity.isState(DESTROYING));
        assertTrue(mActivity.finishing);
    }

    @Test
    public void testFinishingAfterDestroyed() throws Exception {
        assertFalse(mActivity.finishing);
        mActivity.setState(DESTROYED, "testFinishingAfterDestroyed");
        assertTrue(mActivity.isState(DESTROYED));
        assertTrue(mActivity.finishing);
    }
}