Merge "Extracts UserRecord out of UserSwitcherController." into tm-qpr-dev
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index 3517d22..d0baf3d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -89,7 +89,7 @@
 import com.android.systemui.shared.system.SysUiStatsLog;
 import com.android.systemui.statusbar.policy.UserSwitcherController;
 import com.android.systemui.statusbar.policy.UserSwitcherController.BaseUserAdapter;
-import com.android.systemui.statusbar.policy.UserSwitcherController.UserRecord;
+import com.android.systemui.user.data.source.UserRecord;
 import com.android.systemui.util.settings.GlobalSettings;
 
 import java.util.ArrayList;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
index ce6aaae..0ec4eef 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
@@ -43,6 +43,7 @@
 import com.android.systemui.qs.user.UserSwitchDialogController;
 import com.android.systemui.statusbar.phone.SystemUIDialog;
 import com.android.systemui.statusbar.policy.UserSwitcherController;
+import com.android.systemui.user.data.source.UserRecord;
 
 import javax.inject.Inject;
 
@@ -95,7 +96,7 @@
 
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
-            UserSwitcherController.UserRecord item = getItem(position);
+            UserRecord item = getItem(position);
             return createUserDetailItemView(convertView, parent, item);
         }
 
@@ -113,7 +114,7 @@
         }
 
         public UserDetailItemView createUserDetailItemView(View convertView, ViewGroup parent,
-                UserSwitcherController.UserRecord item) {
+                UserRecord item) {
             UserDetailItemView v = UserDetailItemView.convertOrInflate(
                     parent.getContext(), convertView, parent);
             if (!item.isCurrent || item.isGuest) {
@@ -134,7 +135,7 @@
                 v.bind(name, drawable, item.info.id);
             }
             v.setActivated(item.isCurrent);
-            v.setDisabledByAdmin(item.isDisabledByAdmin);
+            v.setDisabledByAdmin(mController.isDisabledByAdmin(item));
             v.setEnabled(item.isSwitchToEnabled);
             v.setAlpha(v.isEnabled() ? USER_SWITCH_ENABLED_ALPHA : USER_SWITCH_DISABLED_ALPHA);
 
@@ -146,7 +147,7 @@
         }
 
         private static Drawable getDrawable(Context context,
-                UserSwitcherController.UserRecord item) {
+                UserRecord item) {
             Drawable icon = getIconDrawable(context, item);
             int iconColorRes;
             if (item.isCurrent) {
@@ -171,22 +172,24 @@
             }
 
             Trace.beginSection("UserDetailView.Adapter#onClick");
-            UserSwitcherController.UserRecord tag =
-                    (UserSwitcherController.UserRecord) view.getTag();
-            if (tag.isDisabledByAdmin) {
+            UserRecord userRecord =
+                    (UserRecord) view.getTag();
+            if (mController.isDisabledByAdmin(userRecord)) {
                 final Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent(
-                        mContext, tag.enforcedAdmin);
+                        mContext, mController.getEnforcedAdmin(userRecord));
                 mController.startActivity(intent);
-            } else if (tag.isSwitchToEnabled) {
+            } else if (userRecord.isSwitchToEnabled) {
                 MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER);
                 mUiEventLogger.log(QSUserSwitcherEvent.QS_USER_SWITCH);
-                if (!tag.isAddUser && !tag.isRestricted && !tag.isDisabledByAdmin) {
+                if (!userRecord.isAddUser
+                        && !userRecord.isRestricted
+                        && !mController.isDisabledByAdmin(userRecord)) {
                     if (mCurrentUserView != null) {
                         mCurrentUserView.setActivated(false);
                     }
                     view.setActivated(true);
                 }
-                onUserListItemClicked(tag, mDialogShower);
+                onUserListItemClicked(userRecord, mDialogShower);
             }
             Trace.endSection();
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java
index 169347a..16306081 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java
@@ -49,6 +49,7 @@
 import com.android.systemui.statusbar.phone.LockscreenGestureLogger;
 import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
 import com.android.systemui.statusbar.phone.UserAvatarView;
+import com.android.systemui.user.data.source.UserRecord;
 import com.android.systemui.util.ViewController;
 
 import javax.inject.Inject;
@@ -79,7 +80,7 @@
     @VisibleForTesting
     UserAvatarView mUserAvatarView;
     private View mUserAvatarViewWithBackground;
-    UserSwitcherController.UserRecord mCurrentUser;
+    UserRecord mCurrentUser;
     private boolean mIsKeyguardShowing;
 
     // State info for the user switch and keyguard
@@ -269,10 +270,10 @@
      * @return true if the current user has changed
      */
     private boolean updateCurrentUser() {
-        UserSwitcherController.UserRecord previousUser = mCurrentUser;
+        UserRecord previousUser = mCurrentUser;
         mCurrentUser = null;
         for (int i = 0; i < mAdapter.getCount(); i++) {
-            UserSwitcherController.UserRecord r = mAdapter.getItem(i);
+            UserRecord r = mAdapter.getItem(i);
             if (r.isCurrent) {
                 mCurrentUser = r;
                 return !mCurrentUser.equals(previousUser);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java
index 03ab888..e2f5734 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java
@@ -52,6 +52,7 @@
 import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
 import com.android.systemui.statusbar.phone.DozeParameters;
 import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
+import com.android.systemui.user.data.source.UserRecord;
 import com.android.systemui.util.ViewController;
 
 import java.util.ArrayList;
@@ -287,8 +288,8 @@
                 }
                 KeyguardUserDetailItemView newView = (KeyguardUserDetailItemView)
                         mAdapter.getView(i, oldView, mListView);
-                UserSwitcherController.UserRecord userTag =
-                        (UserSwitcherController.UserRecord) newView.getTag();
+                UserRecord userTag =
+                        (UserRecord) newView.getTag();
                 if (userTag.isCurrent) {
                     if (i != 0) {
                         Log.w(TAG, "Current user is not the first view in the list");
@@ -443,7 +444,7 @@
         private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
         private View mCurrentUserView;
         // List of users where the first entry is always the current user
-        private ArrayList<UserSwitcherController.UserRecord> mUsersOrdered = new ArrayList<>();
+        private ArrayList<UserRecord> mUsersOrdered = new ArrayList<>();
 
         KeyguardUserAdapter(Context context, Resources resources, LayoutInflater layoutInflater,
                 UserSwitcherController controller,
@@ -464,10 +465,10 @@
         }
 
         void refreshUserOrder() {
-            ArrayList<UserSwitcherController.UserRecord> users = super.getUsers();
+            ArrayList<UserRecord> users = super.getUsers();
             mUsersOrdered = new ArrayList<>(users.size());
             for (int i = 0; i < users.size(); i++) {
-                UserSwitcherController.UserRecord record = users.get(i);
+                UserRecord record = users.get(i);
                 if (record.isCurrent) {
                     mUsersOrdered.add(0, record);
                 } else {
@@ -477,19 +478,19 @@
         }
 
         @Override
-        protected ArrayList<UserSwitcherController.UserRecord> getUsers() {
+        protected ArrayList<UserRecord> getUsers() {
             return mUsersOrdered;
         }
 
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
-            UserSwitcherController.UserRecord item = getItem(position);
+            UserRecord item = getItem(position);
             return createUserDetailItemView(convertView, parent, item);
         }
 
         KeyguardUserDetailItemView convertOrInflate(View convertView, ViewGroup parent) {
             if (!(convertView instanceof KeyguardUserDetailItemView)
-                    || !(convertView.getTag() instanceof UserSwitcherController.UserRecord)) {
+                    || !(convertView.getTag() instanceof UserRecord)) {
                 convertView = mLayoutInflater.inflate(
                         R.layout.keyguard_user_switcher_item, parent, false);
             }
@@ -497,7 +498,7 @@
         }
 
         KeyguardUserDetailItemView createUserDetailItemView(View convertView, ViewGroup parent,
-                UserSwitcherController.UserRecord item) {
+                UserRecord item) {
             KeyguardUserDetailItemView v = convertOrInflate(convertView, parent);
             v.setOnClickListener(this);
 
@@ -513,7 +514,7 @@
                 v.bind(name, drawable, item.info.id);
             }
             v.setActivated(item.isCurrent);
-            v.setDisabledByAdmin(item.isDisabledByAdmin);
+            v.setDisabledByAdmin(mController.isDisabledByAdmin(item));
             v.setEnabled(item.isSwitchToEnabled);
             v.setAlpha(v.isEnabled() ? USER_SWITCH_ENABLED_ALPHA : USER_SWITCH_DISABLED_ALPHA);
 
@@ -524,7 +525,7 @@
             return v;
         }
 
-        private Drawable getDrawable(UserSwitcherController.UserRecord item) {
+        private Drawable getDrawable(UserRecord item) {
             Drawable drawable;
             if (item.isCurrent && item.isGuest) {
                 drawable = mContext.getDrawable(R.drawable.ic_avatar_guest_user);
@@ -547,7 +548,7 @@
 
         @Override
         public void onClick(View v) {
-            UserSwitcherController.UserRecord user = (UserSwitcherController.UserRecord) v.getTag();
+            UserRecord user = (UserRecord) v.getTag();
 
             if (mKeyguardUserSwitcherController.isListAnimating()) {
                 return;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index a00cd5e..a5bcb53 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -45,6 +45,7 @@
 import android.provider.Settings;
 import android.telephony.TelephonyCallback;
 import android.text.TextUtils;
+import android.util.ArraySet;
 import android.util.Log;
 import android.util.SparseArray;
 import android.util.SparseBooleanArray;
@@ -54,6 +55,7 @@
 import android.widget.Toast;
 
 import androidx.annotation.Nullable;
+import androidx.collection.SimpleArrayMap;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.jank.InteractionJankMonitor;
@@ -83,6 +85,7 @@
 import com.android.systemui.statusbar.phone.SystemUIDialog;
 import com.android.systemui.telephony.TelephonyListenerManager;
 import com.android.systemui.user.CreateUserActivity;
+import com.android.systemui.user.data.source.UserRecord;
 import com.android.systemui.util.settings.GlobalSettings;
 import com.android.systemui.util.settings.SecureSettings;
 
@@ -138,6 +141,9 @@
     private final InteractionJankMonitor mInteractionJankMonitor;
     private final LatencyTracker mLatencyTracker;
     private final DialogLaunchAnimator mDialogLaunchAnimator;
+    private final SimpleArrayMap<UserRecord, EnforcedAdmin> mEnforcedAdminByUserRecord =
+            new SimpleArrayMap<>();
+    private final ArraySet<UserRecord> mDisabledByAdmin = new ArraySet<>();
 
     private ArrayList<UserRecord> mUsers = new ArrayList<>();
     @VisibleForTesting
@@ -975,6 +981,21 @@
         return mKeyguardStateController;
     }
 
+    /**
+     * Returns the {@link EnforcedAdmin} for the given record, or {@code null} if there isn't one.
+     */
+    @Nullable
+    public EnforcedAdmin getEnforcedAdmin(UserRecord record) {
+        return mEnforcedAdminByUserRecord.get(record);
+    }
+
+    /**
+     * Returns {@code true} if the given record is disabled by the admin; {@code false} otherwise.
+     */
+    public boolean isDisabledByAdmin(UserRecord record) {
+        return mDisabledByAdmin.contains(record);
+    }
+
     public static abstract class BaseUserAdapter extends BaseAdapter {
 
         final UserSwitcherController mController;
@@ -1106,11 +1127,11 @@
                 UserManager.DISALLOW_ADD_USER, mUserTracker.getUserId());
         if (admin != null && !RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext,
                 UserManager.DISALLOW_ADD_USER, mUserTracker.getUserId())) {
-            record.isDisabledByAdmin = true;
-            record.enforcedAdmin = admin;
+            mDisabledByAdmin.add(record);
+            mEnforcedAdminByUserRecord.put(record, admin);
         } else {
-            record.isDisabledByAdmin = false;
-            record.enforcedAdmin = null;
+            mDisabledByAdmin.remove(record);
+            mEnforcedAdminByUserRecord.put(record, null);
         }
     }
 
@@ -1152,74 +1173,6 @@
         }
     }
 
-    public static final class UserRecord {
-        public final UserInfo info;
-        public final Bitmap picture;
-        public final boolean isGuest;
-        public final boolean isCurrent;
-        public final boolean isAddUser;
-        public final boolean isAddSupervisedUser;
-        /** If true, the record is only visible to the owner and only when unlocked. */
-        public final boolean isRestricted;
-        public boolean isDisabledByAdmin;
-        public EnforcedAdmin enforcedAdmin;
-        public boolean isSwitchToEnabled;
-
-        public UserRecord(UserInfo info, Bitmap picture, boolean isGuest, boolean isCurrent,
-                boolean isAddUser, boolean isRestricted, boolean isSwitchToEnabled,
-                boolean isAddSupervisedUser) {
-            this.info = info;
-            this.picture = picture;
-            this.isGuest = isGuest;
-            this.isCurrent = isCurrent;
-            this.isAddUser = isAddUser;
-            this.isRestricted = isRestricted;
-            this.isSwitchToEnabled = isSwitchToEnabled;
-            this.isAddSupervisedUser = isAddSupervisedUser;
-        }
-
-        public UserRecord copyWithIsCurrent(boolean _isCurrent) {
-            return new UserRecord(info, picture, isGuest, _isCurrent, isAddUser, isRestricted,
-                    isSwitchToEnabled, isAddSupervisedUser);
-        }
-
-        public int resolveId() {
-            if (isGuest || info == null) {
-                return UserHandle.USER_NULL;
-            }
-            return info.id;
-        }
-
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append("UserRecord(");
-            if (info != null) {
-                sb.append("name=\"").append(info.name).append("\" id=").append(info.id);
-            } else {
-                if (isGuest) {
-                    sb.append("<add guest placeholder>");
-                } else if (isAddUser) {
-                    sb.append("<add user placeholder>");
-                }
-            }
-            if (isGuest) sb.append(" <isGuest>");
-            if (isAddUser) sb.append(" <isAddUser>");
-            if (isAddSupervisedUser) sb.append(" <isAddSupervisedUser>");
-            if (isCurrent) sb.append(" <isCurrent>");
-            if (picture != null) sb.append(" <hasPicture>");
-            if (isRestricted) sb.append(" <isRestricted>");
-            if (isDisabledByAdmin) {
-                sb.append(" <isDisabledByAdmin>");
-                sb.append(" enforcedAdmin=").append(enforcedAdmin);
-            }
-            if (isSwitchToEnabled) {
-                sb.append(" <isSwitchToEnabled>");
-            }
-            sb.append(')');
-            return sb.toString();
-        }
-    }
-
     private final KeyguardStateController.Callback mCallback =
             new KeyguardStateController.Callback() {
                 @Override
diff --git a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
index 80c55c0..ff0f0d4 100644
--- a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
@@ -51,7 +51,7 @@
 import com.android.systemui.statusbar.policy.UserSwitcherController.BaseUserAdapter
 import com.android.systemui.statusbar.policy.UserSwitcherController.USER_SWITCH_DISABLED_ALPHA
 import com.android.systemui.statusbar.policy.UserSwitcherController.USER_SWITCH_ENABLED_ALPHA
-import com.android.systemui.statusbar.policy.UserSwitcherController.UserRecord
+import com.android.systemui.user.data.source.UserRecord
 import javax.inject.Inject
 import kotlin.math.ceil
 
@@ -81,16 +81,17 @@
         }
     }
     // When the add users options become available, insert another option to manage users
-    private val manageUserRecord = UserRecord(
-        null /* info */,
-        null /* picture */,
-        false /* isGuest */,
-        false /* isCurrent */,
-        false /* isAddUser */,
-        false /* isRestricted */,
-        false /* isSwitchToEnabled */,
-        false /* isAddSupervisedUser */
-    )
+    private val manageUserRecord =
+        UserRecord(
+            null /* info */,
+            null /* picture */,
+            false /* isGuest */,
+            false /* isCurrent */,
+            false /* isAddUser */,
+            false /* isRestricted */,
+            false /* isSwitchToEnabled */,
+            false /* isAddSupervisedUser */
+        )
 
     private val adapter = object : BaseUserAdapter(userSwitcherController) {
         override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
diff --git a/packages/SystemUI/src/com/android/systemui/user/data/source/UserRecord.kt b/packages/SystemUI/src/com/android/systemui/user/data/source/UserRecord.kt
new file mode 100644
index 0000000..6ab6d7d
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/user/data/source/UserRecord.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.android.systemui.user.data.source
+
+import android.content.pm.UserInfo
+import android.graphics.Bitmap
+import android.os.UserHandle
+
+/**
+ * Encapsulates raw data for a user or an option item related to managing users on the device.
+ */
+data class UserRecord(
+    /** Relevant user information. If `null`, this record is not a user but an option item. */
+    @JvmField
+    val info: UserInfo?,
+    /** An image representing the user. */
+    @JvmField
+    val picture: Bitmap?,
+    /** Whether this record represents an option to switch to a guest user. */
+    @JvmField
+    val isGuest: Boolean,
+    /** Whether this record represents the currently-selected user. */
+    @JvmField
+    val isCurrent: Boolean,
+    /** Whether this record represents an option to add another user to the device. */
+    @JvmField
+    val isAddUser: Boolean,
+    /** If true, the record is only visible to the owner and only when unlocked.  */
+    @JvmField
+    val isRestricted: Boolean,
+    /** Whether it is possible to switch to this user. */
+    @JvmField
+    val isSwitchToEnabled: Boolean,
+    /** Whether this record represents an option to add another supervised user to the device. */
+    @JvmField
+    val isAddSupervisedUser: Boolean,
+) {
+    /**
+     * Returns a new instance of [UserRecord] with its [isCurrent] set to the given value.
+     */
+    fun copyWithIsCurrent(isCurrent: Boolean): UserRecord {
+        return copy(isCurrent = isCurrent)
+    }
+
+    /**
+     * Returns the user ID for the user represented by this instance or [UserHandle.USER_NULL] if
+     * this instance if a guest or does not represent a user (represents an option item).
+     */
+    fun resolveId(): Int {
+        return if (isGuest || info == null) {
+            UserHandle.USER_NULL
+        } else {
+            info.id
+        }
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java
index f2ac0c7..28e99da 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java
@@ -57,7 +57,7 @@
 import com.android.systemui.plugins.FalsingManager;
 import com.android.systemui.statusbar.policy.KeyguardStateController;
 import com.android.systemui.statusbar.policy.UserSwitcherController;
-import com.android.systemui.statusbar.policy.UserSwitcherController.UserRecord;
+import com.android.systemui.user.data.source.UserRecord;
 import com.android.systemui.util.settings.GlobalSettings;
 
 import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
index 9b0142d..5db3b9c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
@@ -31,6 +31,7 @@
 import com.android.systemui.classifier.FalsingManagerFake
 import com.android.systemui.qs.QSUserSwitcherEvent
 import com.android.systemui.statusbar.policy.UserSwitcherController
+import com.android.systemui.user.data.source.UserRecord
 import org.junit.Assert.assertEquals
 import org.junit.Before
 import org.junit.Test
@@ -39,8 +40,8 @@
 import org.mockito.ArgumentMatchers.anyBoolean
 import org.mockito.ArgumentMatchers.anyInt
 import org.mockito.Mock
-import org.mockito.Mockito.`when`
 import org.mockito.Mockito.verify
+import org.mockito.Mockito.`when`
 import org.mockito.MockitoAnnotations
 
 @RunWith(AndroidTestingRunner::class)
@@ -140,13 +141,14 @@
     }
 
     private fun createUserRecord(current: Boolean, guest: Boolean) =
-            UserSwitcherController.UserRecord(
-                    mUserInfo,
-                    mPicture,
-                    guest,
-                    current,
-                    false /* isAddUser */,
-                    false /* isRestricted */,
-                    true /* isSwitchToEnabled */,
-                    false /* isAddSupervisedUser */)
+        UserRecord(
+            mUserInfo,
+            mPicture,
+            guest,
+            current,
+            false /* isAddUser */,
+            false /* isRestricted */,
+            true /* isSwitchToEnabled */,
+            false /* isAddSupervisedUser */
+        )
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherAdapterTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherAdapterTest.kt
index 0dd6cbb7..c3805ad 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherAdapterTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherAdapterTest.kt
@@ -28,6 +28,7 @@
 import com.android.systemui.R
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.qs.tiles.UserDetailItemView
+import com.android.systemui.user.data.source.UserRecord
 import org.junit.Assert.assertFalse
 import org.junit.Assert.assertNotNull
 import org.junit.Assert.assertTrue
@@ -38,8 +39,8 @@
 import org.mockito.ArgumentMatchers.anyBoolean
 import org.mockito.ArgumentMatchers.anyInt
 import org.mockito.Mock
-import org.mockito.Mockito.`when`
 import org.mockito.Mockito.verify
+import org.mockito.Mockito.`when`
 import org.mockito.MockitoAnnotations
 
 @RunWith(AndroidTestingRunner::class)
@@ -186,13 +187,14 @@
     }
 
     private fun createUserRecord(isCurrentUser: Boolean, isGuestUser: Boolean) =
-            UserSwitcherController.UserRecord(
-                    userInfo,
-                    picture,
-                    isGuestUser,
-                    isCurrentUser,
-                    false /* isAddUser */,
-                    false /* isRestricted */,
-                    true /* isSwitchToEnabled */,
-                    false /* isAddSupervisedUser */)
+        UserRecord(
+            userInfo,
+            picture,
+            isGuestUser,
+            isCurrentUser,
+            false /* isAddUser */,
+            false /* isRestricted */,
+            true /* isSwitchToEnabled */,
+            false /* isAddSupervisedUser */
+        )
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt
index 359a780..8dcd4bb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt
@@ -56,6 +56,7 @@
 import com.android.systemui.settings.UserTracker
 import com.android.systemui.shade.NotificationShadeWindowView
 import com.android.systemui.telephony.TelephonyListenerManager
+import com.android.systemui.user.data.source.UserRecord
 import com.android.systemui.util.concurrency.FakeExecutor
 import com.android.systemui.util.mockito.any
 import com.android.systemui.util.mockito.argumentCaptor
@@ -235,15 +236,16 @@
 
     @Test
     fun testSwitchUser_parentDialogDismissed() {
-        val otherUserRecord = UserSwitcherController.UserRecord(
-                secondaryUser,
-                picture,
-                false /* guest */,
-                false /* current */,
-                false /* isAddUser */,
-                false /* isRestricted */,
-                true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+        val otherUserRecord = UserRecord(
+            secondaryUser,
+            picture,
+            false /* guest */,
+            false /* current */,
+            false /* isAddUser */,
+            false /* isRestricted */,
+            true /* isSwitchToEnabled */,
+            false /* isAddSupervisedUser */
+        )
         `when`(userTracker.userId).thenReturn(ownerId)
         `when`(userTracker.userInfo).thenReturn(ownerInfo)
 
@@ -255,7 +257,8 @@
 
     @Test
     fun testAddGuest_okButtonPressed() {
-        val emptyGuestUserRecord = UserSwitcherController.UserRecord(
+        val emptyGuestUserRecord =
+            UserRecord(
                 null,
                 null,
                 true /* guest */,
@@ -263,7 +266,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(ownerId)
         `when`(userTracker.userInfo).thenReturn(ownerInfo)
 
@@ -282,7 +286,8 @@
 
     @Test
     fun testAddGuest_parentDialogDismissed() {
-        val emptyGuestUserRecord = UserSwitcherController.UserRecord(
+        val emptyGuestUserRecord =
+            UserRecord(
                 null,
                 null,
                 true /* guest */,
@@ -290,7 +295,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(ownerId)
         `when`(userTracker.userInfo).thenReturn(ownerInfo)
 
@@ -305,7 +311,8 @@
 
     @Test
     fun testRemoveGuest_removeButtonPressed_isLogged() {
-        val currentGuestUserRecord = UserSwitcherController.UserRecord(
+        val currentGuestUserRecord =
+            UserRecord(
                 guestInfo,
                 picture,
                 true /* guest */,
@@ -313,7 +320,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(guestInfo.id)
         `when`(userTracker.userInfo).thenReturn(guestInfo)
 
@@ -331,7 +339,8 @@
 
     @Test
     fun testRemoveGuest_removeButtonPressed_dialogDismissed() {
-        val currentGuestUserRecord = UserSwitcherController.UserRecord(
+        val currentGuestUserRecord =
+            UserRecord(
                 guestInfo,
                 picture,
                 true /* guest */,
@@ -339,7 +348,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(guestInfo.id)
         `when`(userTracker.userInfo).thenReturn(guestInfo)
 
@@ -353,7 +363,8 @@
 
     @Test
     fun testRemoveGuest_dialogShowerUsed() {
-        val currentGuestUserRecord = UserSwitcherController.UserRecord(
+        val currentGuestUserRecord =
+            UserRecord(
                 guestInfo,
                 picture,
                 true /* guest */,
@@ -361,7 +372,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(guestInfo.id)
         `when`(userTracker.userInfo).thenReturn(guestInfo)
 
@@ -376,7 +388,8 @@
 
     @Test
     fun testRemoveGuest_cancelButtonPressed_isNotLogged() {
-        val currentGuestUserRecord = UserSwitcherController.UserRecord(
+        val currentGuestUserRecord =
+            UserRecord(
                 guestInfo,
                 picture,
                 true /* guest */,
@@ -384,7 +397,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(guestId)
         `when`(userTracker.userInfo).thenReturn(guestInfo)
 
@@ -398,7 +412,8 @@
 
     @Test
     fun testWipeGuest_startOverButtonPressed_isLogged() {
-        val currentGuestUserRecord = UserSwitcherController.UserRecord(
+        val currentGuestUserRecord =
+            UserRecord(
                 guestInfo,
                 picture,
                 true /* guest */,
@@ -406,7 +421,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(guestId)
         `when`(userTracker.userInfo).thenReturn(guestInfo)
 
@@ -433,7 +449,8 @@
 
     @Test
     fun testWipeGuest_continueButtonPressed_isLogged() {
-        val currentGuestUserRecord = UserSwitcherController.UserRecord(
+        val currentGuestUserRecord =
+            UserRecord(
                 guestInfo,
                 picture,
                 true /* guest */,
@@ -441,7 +458,8 @@
                 false /* isAddUser */,
                 false /* isRestricted */,
                 true /* isSwitchToEnabled */,
-                false /* isAddSupervisedUser */)
+                false /* isAddSupervisedUser */
+            )
         `when`(userTracker.userId).thenReturn(guestId)
         `when`(userTracker.userInfo).thenReturn(guestInfo)
 
@@ -470,11 +488,13 @@
     @Test
     fun test_getCurrentUserName_shouldReturnNameOfTheCurrentUser() {
         fun addUser(id: Int, name: String, isCurrent: Boolean) {
-            userSwitcherController.users.add(UserSwitcherController.UserRecord(
+            userSwitcherController.users.add(
+                UserRecord(
                     UserInfo(id, name, 0),
                     null, false, isCurrent, false,
                     false, false, false
-            ))
+                )
+            )
         }
         val bgUserName = "background_user"
         val fgUserName = "foreground_user"
@@ -593,7 +613,7 @@
     @Test
     fun onUserItemClicked_guest_runsOnBgThread() {
         val dialogShower = mock(UserSwitchDialogController.DialogShower::class.java)
-        val guestUserRecord = UserSwitcherController.UserRecord(
+        val guestUserRecord = UserRecord(
             null,
             picture,
             true /* guest */,
@@ -601,7 +621,8 @@
             false /* isAddUser */,
             false /* isRestricted */,
             true /* isSwitchToEnabled */,
-            false /* isAddSupervisedUser */)
+            false /* isAddSupervisedUser */
+        )
 
         userSwitcherController.onUserListItemClicked(guestUserRecord, dialogShower)
         assertTrue(bgExecutor.numPending() > 0)