Loading core/api/test-current.txt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -919,7 +919,7 @@ package android.content.pm { field public int id; field public int id; field public String lastLoggedInFingerprint; field public String lastLoggedInFingerprint; field public long lastLoggedInTime; field public long lastLoggedInTime; field public String name; field @Nullable public String name; field public boolean partial; field public boolean partial; field public boolean preCreated; field public boolean preCreated; field public int profileBadge; field public int profileBadge; Loading core/java/android/content/pm/UserInfo.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.content.pm; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.annotation.TestApi; import android.annotation.UserIdInt; import android.annotation.UserIdInt; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; Loading Loading @@ -187,7 +188,7 @@ public class UserInfo implements Parcelable { @UnsupportedAppUsage @UnsupportedAppUsage public int serialNumber; public int serialNumber; @UnsupportedAppUsage @UnsupportedAppUsage public String name; public @Nullable String name; @UnsupportedAppUsage @UnsupportedAppUsage public String iconPath; public String iconPath; @UnsupportedAppUsage @UnsupportedAppUsage Loading core/java/android/os/UserManager.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -2188,7 +2188,10 @@ public class UserManager { } } } else { } else { UserInfo userInfo = getUserInfo(mUserId); UserInfo userInfo = getUserInfo(mUserId); return userInfo == null ? "" : userInfo.name; if (userInfo != null && userInfo.name != null) { return userInfo.name; } return ""; } } } } Loading services/core/java/com/android/server/pm/UserManagerService.java +8 −3 Original line number Original line Diff line number Diff line Loading @@ -1430,6 +1430,8 @@ public class UserManagerService extends IUserManager.Stub { /** /** * Returns a UserInfo object with the name filled in, for Owner and Guest, or the original * Returns a UserInfo object with the name filled in, for Owner and Guest, or the original * if the name is already set. * if the name is already set. * * Note: Currently, the resulting name can be null if a user was truly created with a null name. */ */ private UserInfo userWithName(UserInfo orig) { private UserInfo userWithName(UserInfo orig) { if (orig != null && orig.name == null) { if (orig != null && orig.name == null) { Loading Loading @@ -1638,7 +1640,7 @@ public class UserManagerService extends IUserManager.Stub { } } @Override @Override public String getUserName() { public @NonNull String getUserName() { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); if (!hasQueryOrCreateUsersPermission() if (!hasQueryOrCreateUsersPermission() && !hasPermissionGranted( && !hasPermissionGranted( Loading @@ -1649,7 +1651,10 @@ public class UserManagerService extends IUserManager.Stub { final int userId = UserHandle.getUserId(callingUid); final int userId = UserHandle.getUserId(callingUid); synchronized (mUsersLock) { synchronized (mUsersLock) { UserInfo userInfo = userWithName(getUserInfoLU(userId)); UserInfo userInfo = userWithName(getUserInfoLU(userId)); return userInfo == null ? "" : userInfo.name; if (userInfo != null && userInfo.name != null) { return userInfo.name; } return ""; } } } } Loading Loading @@ -4207,7 +4212,7 @@ public class UserManagerService extends IUserManager.Stub { * @return the converted user, or {@code null} if no pre-created user could be converted. * @return the converted user, or {@code null} if no pre-created user could be converted. */ */ private @Nullable UserInfo convertPreCreatedUserIfPossible(String userType, private @Nullable UserInfo convertPreCreatedUserIfPossible(String userType, @UserInfoFlag int flags, String name, @Nullable Object token) { @UserInfoFlag int flags, @Nullable String name, @Nullable Object token) { final UserData preCreatedUserData; final UserData preCreatedUserData; synchronized (mUsersLock) { synchronized (mUsersLock) { preCreatedUserData = getPreCreatedUserLU(userType); preCreatedUserData = getPreCreatedUserLU(userType); Loading Loading
core/api/test-current.txt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -919,7 +919,7 @@ package android.content.pm { field public int id; field public int id; field public String lastLoggedInFingerprint; field public String lastLoggedInFingerprint; field public long lastLoggedInTime; field public long lastLoggedInTime; field public String name; field @Nullable public String name; field public boolean partial; field public boolean partial; field public boolean preCreated; field public boolean preCreated; field public int profileBadge; field public int profileBadge; Loading
core/java/android/content/pm/UserInfo.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.content.pm; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.annotation.TestApi; import android.annotation.UserIdInt; import android.annotation.UserIdInt; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; Loading Loading @@ -187,7 +188,7 @@ public class UserInfo implements Parcelable { @UnsupportedAppUsage @UnsupportedAppUsage public int serialNumber; public int serialNumber; @UnsupportedAppUsage @UnsupportedAppUsage public String name; public @Nullable String name; @UnsupportedAppUsage @UnsupportedAppUsage public String iconPath; public String iconPath; @UnsupportedAppUsage @UnsupportedAppUsage Loading
core/java/android/os/UserManager.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -2188,7 +2188,10 @@ public class UserManager { } } } else { } else { UserInfo userInfo = getUserInfo(mUserId); UserInfo userInfo = getUserInfo(mUserId); return userInfo == null ? "" : userInfo.name; if (userInfo != null && userInfo.name != null) { return userInfo.name; } return ""; } } } } Loading
services/core/java/com/android/server/pm/UserManagerService.java +8 −3 Original line number Original line Diff line number Diff line Loading @@ -1430,6 +1430,8 @@ public class UserManagerService extends IUserManager.Stub { /** /** * Returns a UserInfo object with the name filled in, for Owner and Guest, or the original * Returns a UserInfo object with the name filled in, for Owner and Guest, or the original * if the name is already set. * if the name is already set. * * Note: Currently, the resulting name can be null if a user was truly created with a null name. */ */ private UserInfo userWithName(UserInfo orig) { private UserInfo userWithName(UserInfo orig) { if (orig != null && orig.name == null) { if (orig != null && orig.name == null) { Loading Loading @@ -1638,7 +1640,7 @@ public class UserManagerService extends IUserManager.Stub { } } @Override @Override public String getUserName() { public @NonNull String getUserName() { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); if (!hasQueryOrCreateUsersPermission() if (!hasQueryOrCreateUsersPermission() && !hasPermissionGranted( && !hasPermissionGranted( Loading @@ -1649,7 +1651,10 @@ public class UserManagerService extends IUserManager.Stub { final int userId = UserHandle.getUserId(callingUid); final int userId = UserHandle.getUserId(callingUid); synchronized (mUsersLock) { synchronized (mUsersLock) { UserInfo userInfo = userWithName(getUserInfoLU(userId)); UserInfo userInfo = userWithName(getUserInfoLU(userId)); return userInfo == null ? "" : userInfo.name; if (userInfo != null && userInfo.name != null) { return userInfo.name; } return ""; } } } } Loading Loading @@ -4207,7 +4212,7 @@ public class UserManagerService extends IUserManager.Stub { * @return the converted user, or {@code null} if no pre-created user could be converted. * @return the converted user, or {@code null} if no pre-created user could be converted. */ */ private @Nullable UserInfo convertPreCreatedUserIfPossible(String userType, private @Nullable UserInfo convertPreCreatedUserIfPossible(String userType, @UserInfoFlag int flags, String name, @Nullable Object token) { @UserInfoFlag int flags, @Nullable String name, @Nullable Object token) { final UserData preCreatedUserData; final UserData preCreatedUserData; synchronized (mUsersLock) { synchronized (mUsersLock) { preCreatedUserData = getPreCreatedUserLU(userType); preCreatedUserData = getPreCreatedUserLU(userType); Loading