Fix various bugs in OomAdjuster
* The UID state update for pending attach process is missing.
* The legacy partial oom adj update will skip updating the downstream
processes if target process's state isn't changing between fg/bg,
it'll cause issues with downstream processes. Now remove this,
and we'll also scan the whole chain of the downstream, along with
the target app. We're also scanning pending oom adj targets as
an opportunistic thing, given the high overhead of oom adj update.
* The new "skip oom adj update on service binding" actually had
incompatibility with the assumption of partial oom adj updates:
when we update a target process, we always assume the states of
its upstream processes are fixed and we don't need to calculate it.
But it's not true for the new "skip oom adj update on service
binding", because if we skipped the oom adj update of the service
host, if we happen to do an oom adj update for one of its downstream
processes, we may need to re-evaluate that service host, especially
with the legacy oom adj algorithm. As a mitigation to this problem,
now we're enqueueing the service host prior to executing the service,
although we're not necessarily running the oom adj updates for sure.
* The updates of the short fgs info was done after the oom adj
update, this could make the oom adj thinks it's not a short fgs until
the next oom adj update.
* The WM will run oom adj updates asynchronously, meanwhile the proc
state of the top app has been changed - in case before the async
update happens for real, if another partial update happens and the
top app is in the upstream of the target, it may confuse the
algorithm because it didn't expect the top app also needs to be
updated.
* The legacy oom adj update with cycles, will actually skip using
the partial procstate and adj to adjust the effect of the binding,
now fix it. And also check the capability changes too.
Bug: 329505886
Bug: 330410787
Test: atest FrameworksMockingServicesTests:MockingOomAdjusterTests
Test: atest FrameworksMockingServicesTests:ServiceBindingOomAdjPolicyTest
Test: Manual - b/329505886#comment1
Change-Id: I02724e123d2825b2c0eef33b741de3fdd103f290
8 files changed