Loading core/java/android/app/ApplicationPackageManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -2462,7 +2462,8 @@ public class ApplicationPackageManager extends PackageManager { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); return UserIcons.getDefaultUserIcon( mContext.getResources(), itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Loading core/java/com/android/internal/util/UserIcons.java +5 −3 Original line number Diff line number Diff line Loading @@ -61,17 +61,19 @@ public class UserIcons { * Returns a default user icon for the given user. * * Note that for guest users, you should pass in {@code UserHandle.USER_NULL}. * * @param resources resources object to fetch user icon / color. * @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon * @param light whether we want a light icon (suitable for a dark background) */ public static Drawable getDefaultUserIcon(int userId, boolean light) { public static Drawable getDefaultUserIcon(Resources resources, int userId, boolean light) { int colorResId = light ? R.color.user_icon_default_white : R.color.user_icon_default_gray; if (userId != UserHandle.USER_NULL) { // Return colored icon instead colorResId = USER_ICON_COLORS[userId % USER_ICON_COLORS.length]; } Drawable icon = Resources.getSystem().getDrawable(R.drawable.ic_account_circle, null).mutate(); icon.setColorFilter(Resources.getSystem().getColor(colorResId, null), Mode.SRC_IN); Drawable icon = resources.getDrawable(R.drawable.ic_account_circle, null).mutate(); icon.setColorFilter(resources.getColor(colorResId, null), Mode.SRC_IN); icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); return icon; } Loading packages/SettingsLib/src/com/android/settingslib/Utils.java +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ public class Utils { } } return new UserIconDrawable(iconSize).setIconDrawable( UserIcons.getDefaultUserIcon(user.id, /* light= */ false)).bake(); UserIcons.getDefaultUserIcon(context.getResources(), user.id, /* light= */ false)) .bake(); } /** Formats a double from 0.0..100.0 with an option to round **/ Loading packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ public class UserAdapter implements SpinnerAdapter, ListAdapter { if (um.getUserIcon(userId) != null) { icon = new BitmapDrawable(context.getResources(), um.getUserIcon(userId)); } else { icon = UserIcons.getDefaultUserIcon(userId, /* light= */ false); icon = UserIcons.getDefaultUserIcon( context.getResources(), userId, /* light= */ false); } } this.mIcon = encircle(context, icon); Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoControllerImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,9 @@ public class UserInfoControllerImpl implements UserInfoController { avatar = new UserIconDrawable(avatarSize) .setIcon(rawAvatar).setBadgeIfManagedUser(mContext, userId).bake(); } else { avatar = UserIcons.getDefaultUserIcon(isGuest? UserHandle.USER_NULL : userId, avatar = UserIcons.getDefaultUserIcon( context.getResources(), isGuest? UserHandle.USER_NULL : userId, lightIcon); } Loading Loading
core/java/android/app/ApplicationPackageManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -2462,7 +2462,8 @@ public class ApplicationPackageManager extends PackageManager { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); return UserIcons.getDefaultUserIcon( mContext.getResources(), itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Loading
core/java/com/android/internal/util/UserIcons.java +5 −3 Original line number Diff line number Diff line Loading @@ -61,17 +61,19 @@ public class UserIcons { * Returns a default user icon for the given user. * * Note that for guest users, you should pass in {@code UserHandle.USER_NULL}. * * @param resources resources object to fetch user icon / color. * @param userId the user id or {@code UserHandle.USER_NULL} for a non-user specific icon * @param light whether we want a light icon (suitable for a dark background) */ public static Drawable getDefaultUserIcon(int userId, boolean light) { public static Drawable getDefaultUserIcon(Resources resources, int userId, boolean light) { int colorResId = light ? R.color.user_icon_default_white : R.color.user_icon_default_gray; if (userId != UserHandle.USER_NULL) { // Return colored icon instead colorResId = USER_ICON_COLORS[userId % USER_ICON_COLORS.length]; } Drawable icon = Resources.getSystem().getDrawable(R.drawable.ic_account_circle, null).mutate(); icon.setColorFilter(Resources.getSystem().getColor(colorResId, null), Mode.SRC_IN); Drawable icon = resources.getDrawable(R.drawable.ic_account_circle, null).mutate(); icon.setColorFilter(resources.getColor(colorResId, null), Mode.SRC_IN); icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); return icon; } Loading
packages/SettingsLib/src/com/android/settingslib/Utils.java +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ public class Utils { } } return new UserIconDrawable(iconSize).setIconDrawable( UserIcons.getDefaultUserIcon(user.id, /* light= */ false)).bake(); UserIcons.getDefaultUserIcon(context.getResources(), user.id, /* light= */ false)) .bake(); } /** Formats a double from 0.0..100.0 with an option to round **/ Loading
packages/SettingsLib/src/com/android/settingslib/drawer/UserAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ public class UserAdapter implements SpinnerAdapter, ListAdapter { if (um.getUserIcon(userId) != null) { icon = new BitmapDrawable(context.getResources(), um.getUserIcon(userId)); } else { icon = UserIcons.getDefaultUserIcon(userId, /* light= */ false); icon = UserIcons.getDefaultUserIcon( context.getResources(), userId, /* light= */ false); } } this.mIcon = encircle(context, icon); Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/UserInfoControllerImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,9 @@ public class UserInfoControllerImpl implements UserInfoController { avatar = new UserIconDrawable(avatarSize) .setIcon(rawAvatar).setBadgeIfManagedUser(mContext, userId).bake(); } else { avatar = UserIcons.getDefaultUserIcon(isGuest? UserHandle.USER_NULL : userId, avatar = UserIcons.getDefaultUserIcon( context.getResources(), isGuest? UserHandle.USER_NULL : userId, lightIcon); } Loading