Rename related users to profiles.

Rename the related user concept as profiles.
When returning profiles of a user include the
user as a profile of itself.

Change-Id: Id5d4f29017b7ca6844632ce643f10331ad733e1d
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 5fb6405..e69c9a4 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -445,7 +445,7 @@
                 return;
             } else if (Intent.ACTION_USER_ADDED.equals(action)
                     || Intent.ACTION_USER_REMOVED.equals(action)) {
-                updateRelatedUserIds();
+                updateCurrentProfileIds();
                 return;
             } else {
                 Slog.w(TAG, "Unexpected intent " + intent);
@@ -689,7 +689,7 @@
         // mSettings should be created before buildInputMethodListLocked
         mSettings = new InputMethodSettings(
                 mRes, context.getContentResolver(), mMethodMap, mMethodList, userId);
-        updateRelatedUserIds();
+        updateCurrentProfileIds();
         mFileManager = new InputMethodFileManager(mMethodMap, userId);
         mSwitchingController = new InputMethodSubtypeSwitchingController(mSettings);
         mSwitchingController.resetCircularListLocked(context);
@@ -805,7 +805,7 @@
 
     private void switchUserLocked(int newUserId) {
         mSettings.setCurrentUserId(newUserId);
-        updateRelatedUserIds();
+        updateCurrentProfileIds();
         // InputMethodFileManager should be reset when the user is changed
         mFileManager = new InputMethodFileManager(mMethodMap, newUserId);
         final String defaultImiId = mSettings.getSelectedInputMethod();
@@ -826,14 +826,14 @@
         }
     }
 
-    void updateRelatedUserIds() {
-        List<UserInfo> relatedUsers =
-                UserManager.get(mContext).getRelatedUsers(mSettings.getCurrentUserId());
-        int[] relatedUserIds = new int[relatedUsers.size()]; // relatedUsers will not be null
-        for (int i = 0; i < relatedUserIds.length; i++) {
-            relatedUserIds[i] = relatedUsers.get(i).id;
+    void updateCurrentProfileIds() {
+        List<UserInfo> profiles =
+                UserManager.get(mContext).getProfiles(mSettings.getCurrentUserId());
+        int[] currentProfileIds = new int[profiles.size()]; // profiles will not be null
+        for (int i = 0; i < currentProfileIds.length; i++) {
+            currentProfileIds[i] = profiles.get(i).id;
         }
-        mSettings.setRelatedUserIds(relatedUserIds);
+        mSettings.setCurrentProfileIds(currentProfileIds);
     }
 
     @Override
@@ -931,7 +931,7 @@
                     + mSettings.getCurrentUserId() + ", calling pid = " + Binder.getCallingPid()
                     + InputMethodUtils.getApiCallStack());
         }
-        if (uid == Process.SYSTEM_UID || mSettings.isRelatedToOrCurrentUser(userId)) {
+        if (uid == Process.SYSTEM_UID || mSettings.isCurrentProfile(userId)) {
             return true;
         }
 
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 004d4fe..4824f30 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1020,7 +1020,7 @@
     final ActivityThread mSystemThread;
 
     int mCurrentUserId = 0;
-    int[] mRelatedUserIds = new int[0]; // Accessed by ActivityStack
+    int[] mCurrentProfileIds = new int[0]; // Accessed by ActivityStack
     private UserManagerService mUserManager;
 
     private final class AppDeathRecipient implements IBinder.DeathRecipient {
@@ -1079,7 +1079,7 @@
     static final int IMMERSIVE_MODE_LOCK_MSG = 37;
     static final int PERSIST_URI_GRANTS_MSG = 38;
     static final int REQUEST_ALL_PSS_MSG = 39;
-    static final int START_RELATED_USERS_MSG = 40;
+    static final int START_PROFILES_MSG = 40;
     static final int UPDATE_TIME = 41;
 
     static final int FIRST_ACTIVITY_STACK_MSG = 100;
@@ -1694,9 +1694,9 @@
                 requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
                 break;
             }
-            case START_RELATED_USERS_MSG: {
+            case START_PROFILES_MSG: {
                 synchronized (ActivityManagerService.this) {
-                    startRelatedUsersLocked();
+                    startProfilesLocked();
                 }
                 break;
             }
@@ -5209,7 +5209,7 @@
                                 userId);
                     }
                 }
-                scheduleStartRelatedUsersLocked();
+                scheduleStartProfilesLocked();
             }
         }
     }
@@ -6864,8 +6864,8 @@
                             maxNum < N ? maxNum : N);
 
             final Set<Integer> includedUsers;
-            if ((flags & ActivityManager.RECENT_INCLUDE_RELATED) != 0) {
-                includedUsers = getRelatedUsersLocked(userId);
+            if ((flags & ActivityManager.RECENT_INCLUDE_PROFILES) != 0) {
+                includedUsers = getProfileIdsLocked(userId);
             } else {
                 includedUsers = new HashSet<Integer>();
             }
@@ -16318,19 +16318,19 @@
      * user switch happens or when a new related user is started in the
      * background.
      */
-    private void updateRelatedUserIdsLocked() {
-        final List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(mCurrentUserId);
-        int[] relatedUserIds = new int[relatedUsers.size()]; // relatedUsers will not be null
-        for (int i = 0; i < relatedUserIds.length; i++) {
-            relatedUserIds[i] = relatedUsers.get(i).id;
+    private void updateCurrentProfileIdsLocked() {
+        final List<UserInfo> profiles = getUserManagerLocked().getProfiles(mCurrentUserId);
+        int[] currentProfileIds = new int[profiles.size()]; // profiles will not be null
+        for (int i = 0; i < currentProfileIds.length; i++) {
+            currentProfileIds[i] = profiles.get(i).id;
         }
-        mRelatedUserIds = relatedUserIds;
+        mCurrentProfileIds = currentProfileIds;
     }
 
-    private Set getRelatedUsersLocked(int userId) {
+    private Set getProfileIdsLocked(int userId) {
         Set userIds = new HashSet<Integer>();
-        final List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(userId);
-        for (UserInfo user : relatedUsers) {
+        final List<UserInfo> profiles = getUserManagerLocked().getProfiles(userId);
+        for (UserInfo user : profiles) {
             userIds.add(Integer.valueOf(user.id));
         }
         return userIds;
@@ -16391,15 +16391,15 @@
 
                 if (foreground) {
                     mCurrentUserId = userId;
-                    updateRelatedUserIdsLocked();
-                    mWindowManager.setCurrentUser(userId, mRelatedUserIds);
+                    updateCurrentProfileIdsLocked();
+                    mWindowManager.setCurrentUser(userId, mCurrentProfileIds);
                     // Once the internal notion of the active user has switched, we lock the device
                     // with the option to show the user switcher on the keyguard.
                     mWindowManager.lockNow(null);
                 } else {
                     final Integer currentUserIdInt = Integer.valueOf(mCurrentUserId);
-                    updateRelatedUserIdsLocked();
-                    mWindowManager.updateRelatedUserIds(mRelatedUserIds);
+                    updateCurrentProfileIdsLocked();
+                    mWindowManager.setCurrentProfileIds(mCurrentProfileIds);
                     mUserLru.remove(currentUserIdInt);
                     mUserLru.add(currentUserIdInt);
                 }
@@ -16619,20 +16619,21 @@
         }
     }
 
-    void scheduleStartRelatedUsersLocked() {
-        if (!mHandler.hasMessages(START_RELATED_USERS_MSG)) {
-            mHandler.sendMessageDelayed(mHandler.obtainMessage(START_RELATED_USERS_MSG),
+    void scheduleStartProfilesLocked() {
+        if (!mHandler.hasMessages(START_PROFILES_MSG)) {
+            mHandler.sendMessageDelayed(mHandler.obtainMessage(START_PROFILES_MSG),
                     DateUtils.SECOND_IN_MILLIS);
         }
     }
 
-    void startRelatedUsersLocked() {
-        if (DEBUG_MU) Slog.i(TAG_MU, "startRelatedUsersLocked");
-        List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(mCurrentUserId);
-        List<UserInfo> toStart = new ArrayList<UserInfo>(relatedUsers.size());
-        for (UserInfo relatedUser : relatedUsers) {
-            if ((relatedUser.flags & UserInfo.FLAG_INITIALIZED) == UserInfo.FLAG_INITIALIZED) {
-                toStart.add(relatedUser);
+    void startProfilesLocked() {
+        if (DEBUG_MU) Slog.i(TAG_MU, "startProfilesLocked");
+        List<UserInfo> profiles = getUserManagerLocked().getProfiles(mCurrentUserId);
+        List<UserInfo> toStart = new ArrayList<UserInfo>(profiles.size());
+        for (UserInfo user : profiles) {
+            if ((user.flags & UserInfo.FLAG_INITIALIZED) == UserInfo.FLAG_INITIALIZED
+                    && user.id != mCurrentUserId) {
+                toStart.add(user);
             }
         }
         final int n = toStart.size();
@@ -16641,7 +16642,7 @@
             startUserInBackground(toStart.get(i).id);
         }
         if (i < n) {
-            Slog.w(TAG_MU, "More related users than MAX_RUNNING_USERS");
+            Slog.w(TAG_MU, "More profiles than MAX_RUNNING_USERS");
         }
     }
 
@@ -16660,7 +16661,7 @@
                         true, false, MY_PID, Process.SYSTEM_UID, userId);
             }
 
-            startRelatedUsersLocked();
+            startProfilesLocked();
 
             int num = mUserLru.size();
             int i = 0;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 6ee3e07..d949ba0 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -341,18 +341,17 @@
     }
 
     /**
-     * Checks whether the userid is either the current user or a related user.
+     * Checks whether the userid is a profile of the current user.
      */
-    private boolean isRelatedToOrCurrentUserLocked(int userId) {
-        if (mCurrentUser == userId) return true;
-        for (int i = 0; i < mService.mRelatedUserIds.length; i++) {
-            if (mService.mRelatedUserIds[i] == userId) return true;
+    private boolean isCurrentProfileLocked(int userId) {
+        for (int i = 0; i < mService.mCurrentProfileIds.length; i++) {
+            if (mService.mCurrentProfileIds[i] == userId) return true;
         }
         return false;
     }
 
     boolean okToShowLocked(ActivityRecord r) {
-        return isRelatedToOrCurrentUserLocked(r.userId)
+        return isCurrentProfileLocked(r.userId)
                 || (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0;
     }
 
@@ -571,7 +570,7 @@
 
         for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
             TaskRecord task = mTaskHistory.get(taskNdx);
-            if (!isRelatedToOrCurrentUserLocked(task.userId)) {
+            if (!isCurrentProfileLocked(task.userId)) {
                 return null;
             }
             final ArrayList<ActivityRecord> activities = task.mActivities;
@@ -602,7 +601,7 @@
         int index = mTaskHistory.size();
         for (int i = 0; i < index; ) {
             TaskRecord task = mTaskHistory.get(i);
-            if (isRelatedToOrCurrentUserLocked(task.userId)) {
+            if (isCurrentProfileLocked(task.userId)) {
                 if (DEBUG_TASKS) Slog.d(TAG, "switchUserLocked: stack=" + getStackId() +
                         " moving " + task + " to top");
                 mTaskHistory.remove(i);
@@ -1766,10 +1765,10 @@
         mTaskHistory.remove(task);
         // Now put task at top.
         int stackNdx = mTaskHistory.size();
-        if (!isRelatedToOrCurrentUserLocked(task.userId)) {
+        if (!isCurrentProfileLocked(task.userId)) {
             // Put non-current user tasks below current user tasks.
             while (--stackNdx >= 0) {
-                if (!isRelatedToOrCurrentUserLocked(mTaskHistory.get(stackNdx).userId)) {
+                if (!isCurrentProfileLocked(mTaskHistory.get(stackNdx).userId)) {
                     break;
                 }
             }
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index b4f7ae6..3b6d288 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -219,8 +219,8 @@
             ));
     private static final String EXTRA_INTERCEPT = "android.intercept";
 
-    // Users related to the current user.
-    final protected SparseArray<UserInfo> mRelatedUsers = new SparseArray<UserInfo>();
+    // Profiles of the current user.
+    final protected SparseArray<UserInfo> mCurrentProfiles = new SparseArray<UserInfo>();
 
     private static final int MY_UID = Process.myUid();
     private static final int MY_PID = Process.myPid();
@@ -1120,9 +1120,9 @@
             } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
                 // reload per-user settings
                 mSettingsObserver.update(null);
-                updateRelatedUserCache(context);
+                updateCurrentProfilesCache(context);
             } else if (action.equals(Intent.ACTION_USER_ADDED)) {
-                updateRelatedUserCache(context);
+                updateCurrentProfilesCache(context);
             }
         }
     };
@@ -2458,12 +2458,12 @@
     /**
      * Determine whether the userId applies to the notification in question, either because
      * they match exactly, or one of them is USER_ALL (which is treated as a wildcard) or
-     * because it matches a related user.
+     * because it matches one of the users profiles.
      */
-    private boolean notificationMatchesUserIdOrRelated(NotificationRecord r, int userId) {
-        synchronized (mRelatedUsers) {
+    private boolean notificationMatchesCurrentProfiles(NotificationRecord r, int userId) {
+        synchronized (mCurrentProfiles) {
             return notificationMatchesUserId(r, userId)
-                    || mRelatedUsers.get(r.getUserId()) != null;
+                    || mCurrentProfiles.get(r.getUserId()) != null;
         }
     }
 
@@ -2561,7 +2561,7 @@
         final int N = mNotificationList.size();
         for (int i=N-1; i>=0; i--) {
             NotificationRecord r = mNotificationList.get(i);
-            if (!notificationMatchesUserIdOrRelated(r, userId)) {
+            if (!notificationMatchesCurrentProfiles(r, userId)) {
                 continue;
             }
 
@@ -2676,15 +2676,15 @@
                 exceptionPackages);
     }
 
-    private void updateRelatedUserCache(Context context) {
+    private void updateCurrentProfilesCache(Context context) {
         UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
         int currentUserId = ActivityManager.getCurrentUser();
         if (userManager != null) {
-            List<UserInfo> relatedUsers = userManager.getRelatedUsers(currentUserId);
-            synchronized (mRelatedUsers) {
-                mRelatedUsers.clear();
-                for (UserInfo related : relatedUsers) {
-                    mRelatedUsers.put(related.id, related);
+            List<UserInfo> profiles = userManager.getProfiles(currentUserId);
+            synchronized (mCurrentProfiles) {
+                mCurrentProfiles.clear();
+                for (UserInfo user : profiles) {
+                    mCurrentProfiles.put(user.id, user);
                 }
             }
         }
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 7f55464..a39e958 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -92,7 +92,7 @@
     private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber";
     private static final String ATTR_PARTIAL = "partial";
     private static final String ATTR_USER_VERSION = "version";
-    private static final String ATTR_RELATED_GROUP_ID = "relatedGroupId";
+    private static final String ATTR_PROFILE_GROUP_ID = "profileGroupId";
     private static final String TAG_USERS = "users";
     private static final String TAG_USER = "user";
     private static final String TAG_RESTRICTIONS = "restrictions";
@@ -257,26 +257,26 @@
     }
 
     @Override
-    public List<UserInfo> getRelatedUsers(int userId) {
+    public List<UserInfo> getProfiles(int userId) {
         checkManageUsersPermission("query users");
         synchronized (mPackagesLock) {
             UserInfo user = getUserInfoLocked(userId);
             ArrayList<UserInfo> users = new ArrayList<UserInfo>(mUsers.size());
             for (int i = 0; i < mUsers.size(); i++) {
-                UserInfo ui = mUsers.valueAt(i);
-                if (!areRelatedUsers(user, ui)) {
+                UserInfo profile = mUsers.valueAt(i);
+                if (!isProfileOf(user, profile)) {
                     continue;
                 }
-                users.add(ui);
+                users.add(profile);
             }
             return users;
         }
     }
 
-    private boolean areRelatedUsers(UserInfo user1, UserInfo user2) {
-        return user1.relatedGroupId != UserInfo.NO_RELATED_GROUP_ID &&
-                user1.relatedGroupId == user2.relatedGroupId &&
-                user1.id != user2.id;
+    private boolean isProfileOf(UserInfo user, UserInfo profile) {
+        return user.id == profile.id ||
+                (user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID
+                && user.profileGroupId == profile.profileGroupId);
     }
 
     @Override
@@ -684,9 +684,9 @@
             if (userInfo.partial) {
                 serializer.attribute(null, ATTR_PARTIAL, "true");
             }
-            if (userInfo.relatedGroupId != UserInfo.NO_RELATED_GROUP_ID) {
-                serializer.attribute(null, ATTR_RELATED_GROUP_ID,
-                        Integer.toString(userInfo.relatedGroupId));
+            if (userInfo.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID) {
+                serializer.attribute(null, ATTR_PROFILE_GROUP_ID,
+                        Integer.toString(userInfo.profileGroupId));
             }
 
             serializer.startTag(null, TAG_NAME);
@@ -771,7 +771,7 @@
         long salt = 0L;
         String pinHash = null;
         int failedAttempts = 0;
-        int relatedGroupId = UserInfo.NO_RELATED_GROUP_ID;
+        int profileGroupId = UserInfo.NO_PROFILE_GROUP_ID;
         long lastAttemptTime = 0L;
         boolean partial = false;
         Bundle restrictions = new Bundle();
@@ -809,8 +809,14 @@
                 pinHash = parser.getAttributeValue(null, ATTR_PIN_HASH);
                 failedAttempts = readIntAttribute(parser, ATTR_FAILED_ATTEMPTS, 0);
                 lastAttemptTime = readLongAttribute(parser, ATTR_LAST_RETRY_MS, 0L);
-                relatedGroupId = readIntAttribute(parser, ATTR_RELATED_GROUP_ID,
-                        UserInfo.NO_RELATED_GROUP_ID);
+                profileGroupId = readIntAttribute(parser, ATTR_PROFILE_GROUP_ID,
+                        UserInfo.NO_PROFILE_GROUP_ID);
+                if (profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) {
+                    // This attribute was added and renamed during development of L.
+                    // TODO Remove upgrade path by 1st May 2014
+                    profileGroupId = readIntAttribute(parser, "relatedGroupId",
+                            UserInfo.NO_PROFILE_GROUP_ID);
+                }
                 String valueString = parser.getAttributeValue(null, ATTR_PARTIAL);
                 if ("true".equals(valueString)) {
                     partial = true;
@@ -849,7 +855,7 @@
             userInfo.creationTime = creationTime;
             userInfo.lastLoggedInTime = lastLoggedInTime;
             userInfo.partial = partial;
-            userInfo.relatedGroupId = relatedGroupId;
+            userInfo.profileGroupId = profileGroupId;
             mUserRestrictions.append(id, restrictions);
             if (salt != 0L) {
                 RestrictionsPinState pinState = mRestrictionsPinStates.get(id);
@@ -964,25 +970,25 @@
         }
     }
 
-    private int getNextRelatedGroupIdLocked() {
-        int maxGroupId = UserInfo.NO_RELATED_GROUP_ID;
+    private int getNextProfileGroupIdLocked() {
+        int maxGroupId = UserInfo.NO_PROFILE_GROUP_ID;
         for (int i = 0; i < mUsers.size(); i++) {
             UserInfo ui = mUsers.valueAt(i);
-            if (maxGroupId < ui.relatedGroupId) {
-                maxGroupId = ui.relatedGroupId;
+            if (maxGroupId < ui.profileGroupId) {
+                maxGroupId = ui.profileGroupId;
             }
         }
         return maxGroupId + 1;
     }
 
     @Override
-    public UserInfo createRelatedUser(String name, int flags, int relatedUserId) {
+    public UserInfo createProfileForUser(String name, int flags, int userId) {
         checkManageUsersPermission("Only the system can create users");
-        if (relatedUserId != UserHandle.USER_OWNER) {
-            Slog.w(LOG_TAG, "Only user owner can have related users");
+        if (userId != UserHandle.USER_OWNER) {
+            Slog.w(LOG_TAG, "Only user owner can have profiles");
             return null;
         }
-        return createUserInternal(name, flags, relatedUserId);
+        return createUserInternal(name, flags, userId);
     }
 
     @Override
@@ -991,16 +997,16 @@
         return createUserInternal(name, flags, UserHandle.USER_NULL);
     }
 
-    private UserInfo createUserInternal(String name, int flags, int relatedUserId) {
+    private UserInfo createUserInternal(String name, int flags, int profileId) {
         final long ident = Binder.clearCallingIdentity();
         UserInfo userInfo = null;
         try {
             synchronized (mInstallLock) {
                 synchronized (mPackagesLock) {
-                    UserInfo relatedUser = null;
-                    if (relatedUserId != UserHandle.USER_NULL) {
-                        relatedUser = getUserInfoLocked(relatedUserId);
-                        if (relatedUser == null) return null;
+                    UserInfo profile = null;
+                    if (profileId != UserHandle.USER_NULL) {
+                        profile = getUserInfoLocked(profileId);
+                        if (profile == null) return null;
                     }
                     if (isUserLimitReachedLocked()) return null;
                     int userId = getNextAvailableIdLocked();
@@ -1013,12 +1019,12 @@
                     Environment.getUserSystemDirectory(userInfo.id).mkdirs();
                     mUsers.put(userId, userInfo);
                     writeUserListLocked();
-                    if (relatedUser != null) {
-                        if (relatedUser.relatedGroupId == UserInfo.NO_RELATED_GROUP_ID) {
-                            relatedUser.relatedGroupId = getNextRelatedGroupIdLocked();
+                    if (profile != null) {
+                        if (profile.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) {
+                            profile.profileGroupId = getNextProfileGroupIdLocked();
+                            writeUserLocked(profile);
                         }
-                        userInfo.relatedGroupId = relatedUser.relatedGroupId;
-                        writeUserLocked(relatedUser);
+                        userInfo.profileGroupId = profile.profileGroupId;
                     }
                     writeUserLocked(userInfo);
                     mPm.createNewUserLILPw(userId, userPath);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index dcf5880..d4670fb 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -302,14 +302,14 @@
 
     /**
      * Current user when multi-user is enabled. Don't show windows of
-     * non-current user. Also see mRelatedUserIds.
+     * non-current user. Also see mCurrentProfileIds.
      */
     int mCurrentUserId;
     /**
-     * Users related to the current user. These are also allowed to show windows
+     * Users that are profiles of the current user. These are also allowed to show windows
      * on the current user.
      */
-    int[] mRelatedUserIds = new int[0];
+    int[] mCurrentProfileIds = new int[0];
 
     final Context mContext;
 
@@ -5225,16 +5225,16 @@
         ShutdownThread.rebootSafeMode(mContext, confirm);
     }
 
-    public void updateRelatedUserIds(final int[] relatedUserIds) {
+    public void setCurrentProfileIds(final int[] currentProfileIds) {
         synchronized (mWindowMap) {
-            mRelatedUserIds = relatedUserIds;
+            mCurrentProfileIds = currentProfileIds;
         }
     }
 
-    public void setCurrentUser(final int newUserId, final int[] relatedUserIds) {
+    public void setCurrentUser(final int newUserId, final int[] currentProfileIds) {
         synchronized (mWindowMap) {
             mCurrentUserId = newUserId;
-            mRelatedUserIds = relatedUserIds;
+            mCurrentProfileIds = currentProfileIds;
             mAppTransition.setCurrentUser(newUserId);
             mPolicy.setCurrentUserLw(newUserId);
 
@@ -5250,10 +5250,9 @@
     }
 
     /* Called by WindowState */
-    boolean isRelatedToOrCurrentUserLocked(int userId) {
-        if (userId == mCurrentUserId) return true;
-        for (int i = 0; i < mRelatedUserIds.length; i++) {
-            if (mRelatedUserIds[i] == userId) return true;
+    boolean isCurrentProfileLocked(int userId) {
+        for (int i = 0; i < mCurrentProfileIds.length; i++) {
+            if (mCurrentProfileIds[i] == userId) return true;
         }
         return false;
     }
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 2c0e99e..dff75ef 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1249,7 +1249,7 @@
         }
 
         return win.mShowToOwnerOnly
-                && !mService.isRelatedToOrCurrentUserLocked(UserHandle.getUserId(win.mOwnerUid));
+                && !mService.isCurrentProfileLocked(UserHandle.getUserId(win.mOwnerUid));
     }
 
     private static void applyInsets(Region outRegion, Rect frame, Rect inset) {