Merge "Fix NPE in UserManager.getUserName(). Unlike all other calls to getUserInfo(), getUserName() was the only one that did not check for null. This has led to NPEs like in b/37589362. Test: none. :( Not sure how to force the race where getUserInfo() returns null. Verified manually that getUserName() still works."

This commit is contained in:
William Harmon
2017-05-25 19:21:37 +00:00
committed by Android (Google) Code Review

View File

@@ -899,11 +899,8 @@ public class UserManager {
* @return the user name
*/
public String getUserName() {
try {
return mService.getUserInfo(getUserHandle()).name;
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
UserInfo user = getUserInfo(getUserHandle());
return user == null ? "" : user.name;
}
/**