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

Commit c2c4a32e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Clear idle state of destroyed activity

This is mainly for when the activity process is died in background:
AR#handleAppDied -> cleanUp -> setState(DESTROYED, "cleanUp")

This prevents allResumedActivitiesIdle from misjudging idle state
when cold launching the died activity again.

Bug: 356522395
Flag: EXEMPT bugfix
Test: atest ActivityRecordTests# \
            testDestroyImmediately_hadApp_notFinishing
Test: Launch app A, launch app B. Return to home.
      Use "adb shell kill -9 $pid" to kill B.
      Enter split-screen including A and B.
      The launch mode power should end after B is started.
Change-Id: Ib1cf28c71cfb2fb8ff64cc42fffd2003dce727f4
parent 4cc6b39f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5895,6 +5895,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    mAtmService.updateBatteryStats(this, false);
                }
                mAtmService.updateActivityUsageStats(this, Event.ACTIVITY_DESTROYED);
                idle = false;
                // Fall through.
            case DESTROYING:
                if (app != null && !app.hasActivities()) {
+2 −0
Original line number Diff line number Diff line
@@ -1723,10 +1723,12 @@ public class ActivityRecordTests extends WindowTestsBase {
    @Test
    public void testDestroyImmediately_hadApp_notFinishing() {
        final ActivityRecord activity = createActivityWithTask();
        activity.idle = true;
        activity.finishing = false;
        activity.destroyImmediately("test");

        assertEquals(DESTROYED, activity.getState());
        assertFalse(activity.idle);
    }

    /**