Skip to content
Commit 66c8cb6b authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Update oom score reference state if activity state is changed

Previously, the update of reference state may be scheduled in
display thread. That causes a race for the case of activity stopped:
when ActivityTaskManagerService#activityStopped is called, it will
first set STOPPED state and then invoke trimApplications which will
trigger a full oom-adj calculation. But if the scheduled reference
state is updated later than the calculation, the adj and process
state of the stopped activity may stay at a stale perceptible state
temporally. That seems somewhat inconsistent between ATMS and AMS.

This change ensures that any activity states change applies to the
oom reference state immediately. So any direct or posted oom-adj
calculation can refer to the latest state.

Also correct the place of setting activity state flags that should
be outside of the loop.

Bug: 159104503
Bug: 170685888
Test: ActivityLifecycleTests#testRestoreFromKill
      WindowProcessControllerTests#testComputeOomAdjFromActivities
Change-Id: I42bd43f71315dbf8f5d6abc7ab2f742419f0b6da
parent 5b3573cf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment