Stop previous user's packages early during user switch
On devices in which the previous user is stopped during user switch, we
will kill the previous user's packages after all SystemServices are
notified of the user switch via onUserSwitching. The entire user switch
flow remains the same, except for this new step. The early killing of
the packages significantly reduces CPU and memory pressure on the
system.
Packages with OOM score below FOREGROUND_APP_ADJ (0) are not killed
given system server binds to them. They will be ultimately killed once
the user is stopped, which is the current behavior.
Test: Manually run user switch on device
Test: atest UserControllerTest ActivityManagerInternalTest
Test: atest ActivityManagerServiceTest ActiveServicesTest
Bug: 323200731
Flag: android.multiuser.stop_previous_user_apps
Change-Id: I83e980432d30885c05a5748e05a360ec38875cc0
6 files changed