Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 097d283c authored by Adam Bookatz's avatar Adam Bookatz
Browse files

stopExcessUsers avoids stopping audio/alarm users

If we have too many running users, we try to stop some excess ones. We
take into account how recently the user was started, and whether it (or
its parent) is currently running, but not much else.
In particular, if the user (or its profile) is currently playing audio
or has an upcoming alarm, we may still stop it, which isn't ideal. So we
now take this into account. In such cases, we try to stop other users
instead, and if we cannot, we will schedule stopping the user for later.

Note that this requires making the scheduled-background-user-stop
infrastructure also work with profiles. This is pretty straightforward;
we just need to make sure not to stop the current user's profiles, nor
schedule stopping the current user's profiles. This can be done via
!stopProfileRegardlessOfParent and !isCurrentProfile, respectively.
Just to make the logic easier to think about, some extra checks related
to this have been added (even if, strictly speaking, they cannot happen
since they've already been checked by the caller.)

Bug: 401340391
Bug: 330351042
Bug: 378575468
Test: UserControllerTest
Flag: android.multiuser.schedule_stop_of_background_user
Change-Id: I9e63fb27b6bb25e3b3c1654d6b11adefd39856d8
parent 16ff8bfa
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment