UserController.startInBackgroundTemporarily
Provide a method to start a user in the background for some duration of time, after which - if the user is still in the background - the system will attempt to stop it. This can be used in the situation that we are only starting a user in the background to determine what alarms it has after boot-up. We don't want that user to persist in the background for long, since it will needlessly consume resources. This allows us to instead quickly stop the user in such a case. We switch to using this method for this case. We do this by passing in a parameter to startUser(), indicating when to schedule stopping the user. We really have no choice but to pass a parameter: If we instead tried to complete startUser() and only then schedule the stopping (if the user wasn't already running), we would be stuck in the situation that there are multiple schedules (such as due to mBackgroundUserScheduledStopTimeSecs): depending on our implementation, we would have to *always* either pick the shortest or longest such duration, and we wouldn't want that. Test: UserControllerTest Flag: android.multiuser.schedule_stop_of_background_user Bug: 330351042 Bug: 401340391 Change-Id: I62310c375571e6e91d0e30b200cbba7b98d8cec8
Loading
Please register or sign in to comment