Check for pre-created users during garage mode
Bug: 163138337
Test: atest CarServiceUnitTest:com.android.car.user.CarUserServiceTest
Change-Id: I5f62cb8fa29e4ecc7eec8ea99edac80c1e8b689d
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java
index f846d35..b2963aa 100644
--- a/service/src/com/android/car/user/CarUserService.java
+++ b/service/src/com/android/car/user/CarUserService.java
@@ -239,14 +239,15 @@
@NonNull CarUserManagerHelper carUserManagerHelper, @NonNull UserManager userManager,
@NonNull IActivityManager am, int maxRunningUsers) {
this(context, hal, carUserManagerHelper, userManager, am, maxRunningUsers,
- /* initialUserSetter= */ null);
+ /* initialUserSetter= */ null, /* userPreCreator= */ null);
}
@VisibleForTesting
CarUserService(@NonNull Context context, @NonNull UserHalService hal,
@NonNull CarUserManagerHelper carUserManagerHelper, @NonNull UserManager userManager,
@NonNull IActivityManager am, int maxRunningUsers,
- @Nullable InitialUserSetter initialUserSetter) {
+ @Nullable InitialUserSetter initialUserSetter,
+ @Nullable UserPreCreator userPreCreator) {
if (Log.isLoggable(TAG_USER, Log.DEBUG)) {
Log.d(TAG_USER, "constructed");
}
@@ -257,12 +258,11 @@
mMaxRunningUsers = maxRunningUsers;
mUserManager = userManager;
mLastPassengerId = UserHandle.USER_NULL;
- if (initialUserSetter == null) {
- mInitialUserSetter = new InitialUserSetter(context, (u) -> setInitialUser(u));
- } else {
- mInitialUserSetter = initialUserSetter;
- }
- mUserPreCreator = new UserPreCreator(mUserManager);
+ mInitialUserSetter =
+ initialUserSetter == null ? new InitialUserSetter(context, (u) -> setInitialUser(u))
+ : initialUserSetter;
+ mUserPreCreator =
+ userPreCreator == null ? new UserPreCreator(mUserManager) : userPreCreator;
Resources resources = context.getResources();
mEnablePassengerSupport = resources.getBoolean(R.bool.enablePassengerSupport);
mSwitchGuestUserBeforeSleep = resources.getBoolean(
@@ -689,6 +689,8 @@
if (mSwitchGuestUserBeforeSleep) {
initResumeReplaceGuest();
}
+
+ preCreateUsers();
}
/**