Merge "QS uses nickname for multiuser and profile name for singleuser." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
20329dcb37
@@ -202,21 +202,18 @@ class QuickSettings {
|
|||||||
Log.e(TAG, "Couldn't get user info", e);
|
Log.e(TAG, "Couldn't get user info", e);
|
||||||
}
|
}
|
||||||
final int userId = userInfo.id;
|
final int userId = userInfo.id;
|
||||||
|
final String userName = userInfo.name;
|
||||||
|
|
||||||
final Context context = currentUserContext;
|
final Context context = currentUserContext;
|
||||||
mUserInfoTask = new AsyncTask<Void, Void, Pair<String, Drawable>>() {
|
mUserInfoTask = new AsyncTask<Void, Void, Pair<String, Drawable>>() {
|
||||||
@Override
|
@Override
|
||||||
protected Pair<String, Drawable> doInBackground(Void... params) {
|
protected Pair<String, Drawable> doInBackground(Void... params) {
|
||||||
final Cursor cursor = context.getContentResolver().query(
|
|
||||||
Profile.CONTENT_URI, new String[] {Phone._ID, Phone.DISPLAY_NAME},
|
|
||||||
null, null, null);
|
|
||||||
final UserManager um =
|
final UserManager um =
|
||||||
(UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
(UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||||
|
|
||||||
// Fall back to the UserManager nickname if we can't read the name from the local
|
// Fall back to the UserManager nickname if we can't read the name from the local
|
||||||
// profile below.
|
// profile below.
|
||||||
String nickName = um.getUserName();
|
String name = userName;
|
||||||
String name = nickName;
|
|
||||||
Drawable avatar = null;
|
Drawable avatar = null;
|
||||||
Bitmap rawAvatar = um.getUserIcon(userId);
|
Bitmap rawAvatar = um.getUserIcon(userId);
|
||||||
if (rawAvatar != null) {
|
if (rawAvatar != null) {
|
||||||
@@ -225,17 +222,23 @@ class QuickSettings {
|
|||||||
avatar = mContext.getResources().getDrawable(R.drawable.ic_qs_default_user);
|
avatar = mContext.getResources().getDrawable(R.drawable.ic_qs_default_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try and read the display name from the local profile
|
// If it's a single-user device, get the profile name, since the nickname is not
|
||||||
if (cursor != null) {
|
// usually valid
|
||||||
try {
|
if (um.getUsers().size() <= 1) {
|
||||||
if (cursor.moveToFirst()) {
|
// Try and read the display name from the local profile
|
||||||
name = cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME));
|
final Cursor cursor = context.getContentResolver().query(
|
||||||
|
Profile.CONTENT_URI, new String[] {Phone._ID, Phone.DISPLAY_NAME},
|
||||||
|
null, null, null);
|
||||||
|
if (cursor != null) {
|
||||||
|
try {
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
name = cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
cursor.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pair<String, Drawable>(name, avatar);
|
return new Pair<String, Drawable>(name, avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user