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

Commit f6e6e686 authored by Momoko Hattori's avatar Momoko Hattori
Browse files

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
parent 2e195e44
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