Loading packages/SettingsLib/src/com/android/settingslib/Utils.java +12 −3 Original line number Diff line number Diff line Loading @@ -699,8 +699,10 @@ public class Utils { return networkRegWwan.isInService(); } /** Get the corresponding adaptive icon drawable. */ public static Drawable getBadgedIcon(Context context, Drawable icon, UserHandle user) { /** Get the UserIconInfo required to badge an icon by looking up the UserInfo. */ @NonNull public static UserIconInfo fetchUserIconInfo(@NonNull Context context, @NonNull UserHandle user) { int userType = UserIconInfo.TYPE_MAIN; try { UserInfo ui = Loading @@ -717,10 +719,17 @@ public class Utils { } catch (Exception e) { // Ignore } return new UserIconInfo(user, userType); } /** Get the corresponding adaptive icon drawable. */ @NonNull public static Drawable getBadgedIcon(@NonNull Context context, @NonNull Drawable icon, @NonNull UserHandle user) { try (IconFactory iconFactory = IconFactory.obtain(context)) { return iconFactory .createBadgedIconBitmap( icon, new IconOptions().setUser(new UserIconInfo(user, userType))) icon, new IconOptions().setUser(fetchUserIconInfo(context, user))) .newIcon(context); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/AppIconProvider.kt +10 −16 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.os.UserHandle import android.os.UserManager import android.util.Log import com.android.internal.R import com.android.launcher3.icons.BaseIconFactory Loading @@ -34,6 +33,7 @@ import com.android.launcher3.icons.BaseIconFactory.IconOptions import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.mono.MonoIconThemeController import com.android.launcher3.util.UserIconInfo import com.android.settingslib.Utils import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager Loading Loading @@ -217,7 +217,7 @@ constructor( private fun iconOptions(userHandle: UserHandle, allowProfileBadge: Boolean): IconOptions { return IconOptions().apply { setUser(userIconInfo(userHandle, allowProfileBadge)) setUser(userIconInfo(userHandle, allowProfileBadge = allowProfileBadge)) setBitmapGenerationMode(BaseIconFactory.MODE_HARDWARE) // This color will not be used, but we're just setting it so that the icon factory // doesn't try to extract colors from our bitmap (since it won't work, given it's a Loading @@ -226,19 +226,13 @@ constructor( } } private fun userIconInfo(userHandle: UserHandle, allowProfileBadge: Boolean): UserIconInfo { // TODO(b/423033161): use the correct badge for the type of managed profile val withWorkProfileBadge = private fun userIconInfo(userHandle: UserHandle, allowProfileBadge: Boolean): UserIconInfo = if (allowProfileBadge) { val userManager = sysuiContext.getSystemService(UserManager::class.java) userManager?.isManagedProfile(userHandle.identifier) == true // Look up the user to determine if it is a profile, and if so which badge to use Utils.fetchUserIconInfo(sysuiContext, userHandle) } else { false } return UserIconInfo( userHandle, if (withWorkProfileBadge) UserIconInfo.TYPE_WORK else UserIconInfo.TYPE_MAIN, ) // For a main user the IconFactory does not add a badge UserIconInfo(/* user= */ userHandle, /* type= */ UserIconInfo.TYPE_MAIN) } override fun purgeCache(wantedPackages: Collection<String>) { Loading Loading
packages/SettingsLib/src/com/android/settingslib/Utils.java +12 −3 Original line number Diff line number Diff line Loading @@ -699,8 +699,10 @@ public class Utils { return networkRegWwan.isInService(); } /** Get the corresponding adaptive icon drawable. */ public static Drawable getBadgedIcon(Context context, Drawable icon, UserHandle user) { /** Get the UserIconInfo required to badge an icon by looking up the UserInfo. */ @NonNull public static UserIconInfo fetchUserIconInfo(@NonNull Context context, @NonNull UserHandle user) { int userType = UserIconInfo.TYPE_MAIN; try { UserInfo ui = Loading @@ -717,10 +719,17 @@ public class Utils { } catch (Exception e) { // Ignore } return new UserIconInfo(user, userType); } /** Get the corresponding adaptive icon drawable. */ @NonNull public static Drawable getBadgedIcon(@NonNull Context context, @NonNull Drawable icon, @NonNull UserHandle user) { try (IconFactory iconFactory = IconFactory.obtain(context)) { return iconFactory .createBadgedIconBitmap( icon, new IconOptions().setUser(new UserIconInfo(user, userType))) icon, new IconOptions().setUser(fetchUserIconInfo(context, user))) .newIcon(context); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/AppIconProvider.kt +10 −16 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.os.UserHandle import android.os.UserManager import android.util.Log import com.android.internal.R import com.android.launcher3.icons.BaseIconFactory Loading @@ -34,6 +33,7 @@ import com.android.launcher3.icons.BaseIconFactory.IconOptions import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.mono.MonoIconThemeController import com.android.launcher3.util.UserIconInfo import com.android.settingslib.Utils import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager Loading Loading @@ -217,7 +217,7 @@ constructor( private fun iconOptions(userHandle: UserHandle, allowProfileBadge: Boolean): IconOptions { return IconOptions().apply { setUser(userIconInfo(userHandle, allowProfileBadge)) setUser(userIconInfo(userHandle, allowProfileBadge = allowProfileBadge)) setBitmapGenerationMode(BaseIconFactory.MODE_HARDWARE) // This color will not be used, but we're just setting it so that the icon factory // doesn't try to extract colors from our bitmap (since it won't work, given it's a Loading @@ -226,19 +226,13 @@ constructor( } } private fun userIconInfo(userHandle: UserHandle, allowProfileBadge: Boolean): UserIconInfo { // TODO(b/423033161): use the correct badge for the type of managed profile val withWorkProfileBadge = private fun userIconInfo(userHandle: UserHandle, allowProfileBadge: Boolean): UserIconInfo = if (allowProfileBadge) { val userManager = sysuiContext.getSystemService(UserManager::class.java) userManager?.isManagedProfile(userHandle.identifier) == true // Look up the user to determine if it is a profile, and if so which badge to use Utils.fetchUserIconInfo(sysuiContext, userHandle) } else { false } return UserIconInfo( userHandle, if (withWorkProfileBadge) UserIconInfo.TYPE_WORK else UserIconInfo.TYPE_MAIN, ) // For a main user the IconFactory does not add a badge UserIconInfo(/* user= */ userHandle, /* type= */ UserIconInfo.TYPE_MAIN) } override fun purgeCache(wantedPackages: Collection<String>) { Loading