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

Commit 292ae8c0 authored by Calvin Huang's avatar Calvin Huang
Browse files

Update PAUSE usage state when activity move from RESUMED to STOPPING

In some multitasking scenarios, an activity can be scheduled to move
directly from the RESUMED state to the STOPPED state, bypassing the PAUSED state.
But the activity will cycled through to PAUSED state anyway. Need to
update the PAUSED usage state in this case.

Test: atest com.google.android.gts.playstore.UsageStatsHostTest
Test: atest ActivityRecordTests
Bug: 368228446
Flag: EXEMPT bugfix
Change-Id: Ib66e9627d4c7ed857df9d6ae614e2001ad2d97b6
parent eeac1b7c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -5863,6 +5863,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }

        final State prevState = mState;
        mState = state;

        if (getTaskFragment() != null) {
@@ -5903,6 +5904,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mAtmService.updateBatteryStats(this, false);
                mAtmService.updateActivityUsageStats(this, Event.ACTIVITY_PAUSED);
                break;
            case STOPPING:
                // It is possible that an Activity is scheduled to be STOPPED directly from RESUMED
                // state. Updating the PAUSED usage state in that case, since the Activity will be
                // STOPPED while cycled through the PAUSED state.
                if (prevState == RESUMED) {
                    mAtmService.updateActivityUsageStats(this, Event.ACTIVITY_PAUSED);
                }
                break;
            case STOPPED:
                mAtmService.updateActivityUsageStats(this, Event.ACTIVITY_STOPPED);
                if (mDisplayContent != null) {