Loading services/core/java/com/android/server/pm/HsumBootUserInitializer.java +6 −0 Original line number Diff line number Diff line Loading @@ -370,6 +370,12 @@ public final class HsumBootUserInitializer { private void switchToBootUser(@UserIdInt int bootUserId) { Slogf.i(TAG, "Switching to boot user %d", bootUserId); if (bootUserId == UserHandle.USER_SYSTEM) { // System user is already the foreground user, so onUserSwitching() will not be called // for the system user to record the last entered foreground time. Therefore explicitly // set the time now. mUms.setLastEnteredForegroundTimeToNow(bootUserId); } final boolean started = mAms.startUserInForegroundWithListener(bootUserId, /* unlockListener= */ null); if (!started) { Loading services/core/java/com/android/server/pm/UserManagerService.java +26 −11 Original line number Diff line number Diff line Loading @@ -189,16 +189,6 @@ import com.android.server.utils.Slogf; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wm.ActivityTaskManagerInternal; import java.nio.file.DirectoryStream; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.stream.Collectors; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; Loading @@ -215,11 +205,19 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.file.DirectoryStream; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; import java.util.Set; Loading Loading @@ -1034,7 +1032,12 @@ public class UserManagerService extends IUserManager.Stub { if (user != null) { user.startRealtime = SystemClock.elapsedRealtime(); if (targetUser.getUserIdentifier() == UserHandle.USER_SYSTEM && user.info.supportsSwitchTo()) { && user.info.isFull()) { // On interactive HSUM devices (where the system user is not a full user but // can be in foreground), the last entered foreground time for the system // user will be set later in HsumBootUserInitializer only when it is the // boot user. This is because we don't know yet if the system user will be // the boot user (e.g., setBootUser could be called later). mUms.setLastEnteredForegroundTimeToNow(user); } } Loading Loading @@ -7891,6 +7894,18 @@ public class UserManagerService extends IUserManager.Stub { || someUserHasSeedAccountNoChecks(accountName, accountType)); } /** * Sets the last entered foreground time to the current time for the given user. */ public void setLastEnteredForegroundTimeToNow(@UserIdInt int userId) { UserData userData = getUserDataNoChecks(userId); if (userData == null) { Slog.w(LOG_TAG, "setLastEnteredForegroundTimeToNow: unknown user #" + userId); return; } setLastEnteredForegroundTimeToNow(userData); } private void setLastEnteredForegroundTimeToNow(@NonNull UserData userData) { userData.mLastEnteredForegroundTimeMillis = System.currentTimeMillis(); scheduleWriteUser(userData.info.id); Loading Loading
services/core/java/com/android/server/pm/HsumBootUserInitializer.java +6 −0 Original line number Diff line number Diff line Loading @@ -370,6 +370,12 @@ public final class HsumBootUserInitializer { private void switchToBootUser(@UserIdInt int bootUserId) { Slogf.i(TAG, "Switching to boot user %d", bootUserId); if (bootUserId == UserHandle.USER_SYSTEM) { // System user is already the foreground user, so onUserSwitching() will not be called // for the system user to record the last entered foreground time. Therefore explicitly // set the time now. mUms.setLastEnteredForegroundTimeToNow(bootUserId); } final boolean started = mAms.startUserInForegroundWithListener(bootUserId, /* unlockListener= */ null); if (!started) { Loading
services/core/java/com/android/server/pm/UserManagerService.java +26 −11 Original line number Diff line number Diff line Loading @@ -189,16 +189,6 @@ import com.android.server.utils.Slogf; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wm.ActivityTaskManagerInternal; import java.nio.file.DirectoryStream; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.stream.Collectors; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; Loading @@ -215,11 +205,19 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.file.DirectoryStream; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; import java.util.Set; Loading Loading @@ -1034,7 +1032,12 @@ public class UserManagerService extends IUserManager.Stub { if (user != null) { user.startRealtime = SystemClock.elapsedRealtime(); if (targetUser.getUserIdentifier() == UserHandle.USER_SYSTEM && user.info.supportsSwitchTo()) { && user.info.isFull()) { // On interactive HSUM devices (where the system user is not a full user but // can be in foreground), the last entered foreground time for the system // user will be set later in HsumBootUserInitializer only when it is the // boot user. This is because we don't know yet if the system user will be // the boot user (e.g., setBootUser could be called later). mUms.setLastEnteredForegroundTimeToNow(user); } } Loading Loading @@ -7891,6 +7894,18 @@ public class UserManagerService extends IUserManager.Stub { || someUserHasSeedAccountNoChecks(accountName, accountType)); } /** * Sets the last entered foreground time to the current time for the given user. */ public void setLastEnteredForegroundTimeToNow(@UserIdInt int userId) { UserData userData = getUserDataNoChecks(userId); if (userData == null) { Slog.w(LOG_TAG, "setLastEnteredForegroundTimeToNow: unknown user #" + userId); return; } setLastEnteredForegroundTimeToNow(userData); } private void setLastEnteredForegroundTimeToNow(@NonNull UserData userData) { userData.mLastEnteredForegroundTimeMillis = System.currentTimeMillis(); scheduleWriteUser(userData.info.id); Loading