Fix getPreviousForegroundUser() after boot on HSUM with boot user switch
In commit c21b1cb6 we fixed UserManagerService.LifeCycle#onUserStarting so that the last foreground time for the system user 0 can be updated when interactive HSUM devices boot as well. However, on HSUM devices, HsumBootUserInitializer triggers user switch to the boot user after the system user is started, which causes getPreviousForegroundUser() to always return 0 right after boot even when the perceived previous foreground user isn't 0, like as in the following case: 1. The device's current user is X (not 0) 2. The device reboots. 3. The device's current user is Y (not 0 or X), but getPreviousForegroundUser() returns 0 instead of X To fix the behavior, avoid updating the last foreground time of system user 0 on HSUM devices, and update it later in HsumBootUserInitializer#switchToBootUser(), at which point the boot user should have been finalized. This change also modifies the import as requested by preupload check. Bug: 418780738 Bug: 412630247 Test: `atest android.host.multiuser.UserManagerHostTest` passes on auto and desktop Flag: EXEMPT bug fix Change-Id: Ic5fa226400a56b0a41b4fd1015bcc4305f7566e9
Loading
Please register or sign in to comment