Do not update lru list for dead process
There were multiple wrong states yield a no harm result:
The updateLruProcessLocked only adds the given process to lru list
if the process doesn't have activity. In R it was no problem because
the activities are not detached from process when handling crash,
updateProcessInfo is not called from ActivityRecord#setState with
DESTROYED state. Commit 7fce339 fixed the case but introduced another
bug that WindowProcessController#handleAppDied adds the inactive
activity list to the active list that causes hasActivities returns
true, so it is still no harm because update-lru will ignore the
process with activity.
And then commit 8f7dd59 corrects the inconsistent state accidentally
by the added field mHasActivities. That corrects the return value of
hasActivitiesOrRecentTasks. So updateLruProcessLocked takes effect
to add the dead process into to lru list, which leads to the method
getPackageProcessState gets old process state from a dead process
record (pid=0).
Fixes: 170487962
Test: OneTimePermissionTest#testStickyServiceMaintainsPermissionOnRestart
Change-Id: I4449a5581cac678fd362cc22ad2754f0aada5482
2 files changed