diff options
author | Amith Yamasani <yamasani@google.com> | 2012-10-30 14:32:45 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-10-30 14:32:45 -0700 |
commit | aac4d9fe55f0baabc5a90c6ffc18dd0502ee7799 (patch) | |
tree | c91851e4e5a1f870d19f69ebbf9d63d461e4d200 /packages | |
parent | 44251a70edba3e950aab1f706e1ff34e2fa4dfae (diff) | |
download | frameworks_base-aac4d9fe55f0baabc5a90c6ffc18dd0502ee7799.zip frameworks_base-aac4d9fe55f0baabc5a90c6ffc18dd0502ee7799.tar.gz frameworks_base-aac4d9fe55f0baabc5a90c6ffc18dd0502ee7799.tar.bz2 |
QS uses nickname for multiuser and profile name for singleuser.
Bug: 7400662
Change-Id: I3299ee70acaa7341ec11b4774426e22182ffd170
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java index 599b7e2..cc9c601 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -202,21 +202,18 @@ class QuickSettings { Log.e(TAG, "Couldn't get user info", e); } final int userId = userInfo.id; + final String userName = userInfo.name; final Context context = currentUserContext; mUserInfoTask = new AsyncTask<Void, Void, Pair<String, Drawable>>() { @Override 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 = (UserManager) mContext.getSystemService(Context.USER_SERVICE); // Fall back to the UserManager nickname if we can't read the name from the local // profile below. - String nickName = um.getUserName(); - String name = nickName; + String name = userName; Drawable avatar = null; Bitmap rawAvatar = um.getUserIcon(userId); if (rawAvatar != null) { @@ -225,17 +222,23 @@ class QuickSettings { avatar = mContext.getResources().getDrawable(R.drawable.ic_qs_default_user); } - // Try and read the display name from the local profile - if (cursor != null) { - try { - if (cursor.moveToFirst()) { - name = cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME)); + // If it's a single-user device, get the profile name, since the nickname is not + // usually valid + if (um.getUsers().size() <= 1) { + // Try and read the display name from the local profile + 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); } |