ActivityManagerService: explicitly break connection cycles

Currently, it is possible for two services to bind to each other and
receive each other's oom_adj, even if there are no other bindings that
would cause either process to be promoted. This causes a pair of
services to remain at a higher oom_adj level than they intended if
one service was promoted by a binding that was later destroyed.

To fix this, any process that encounters a cycle will be marked for a
later adjustment, and those bindings that encounter a cycle will not be
used to promote processes. After the initial oom_adj adjustments, all
processes that encountered a cycle will be retried. These retries will
continue until no process that encountered a cycle changes its process
state, at which point the process states should be stable.

Test: CTS; boots; runs normally
bug 78894563

Change-Id: I7cb2aa2fc461c08bc8e7f687a673249aef78351b
2 files changed