Loading core/java/android/app/Notification.java +32 −3 Original line number Diff line number Diff line Loading @@ -3089,6 +3089,25 @@ public class Notification implements Parcelable } } /** * @hide */ public int loadHeaderAppIconRes(Context context) { ApplicationInfo info = null; if (extras.containsKey(EXTRA_BUILDER_APPLICATION_INFO)) { info = extras.getParcelable( EXTRA_BUILDER_APPLICATION_INFO, ApplicationInfo.class); } if (info == null) { info = context.getApplicationInfo(); } if (info != null) { return info.icon; } return 0; } /** * Removes heavyweight parts of the Notification object for archival or for sending to * listeners when the full contents are not necessary. Loading Loading @@ -5963,13 +5982,22 @@ public class Notification implements Parcelable } private void bindSmallIcon(RemoteViews contentView, StandardTemplateParams p) { if (mN.mSmallIcon == null && mN.icon != 0) { if (Flags.notificationsUseAppIcon()) { // Override small icon with app icon mN.mSmallIcon = Icon.createWithResource(mContext, mN.loadHeaderAppIconRes(mContext)); } else if (mN.mSmallIcon == null && mN.icon != 0) { mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon); } contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon); contentView.setInt(R.id.icon, "setImageLevel", mN.iconLevel); // Don't change color if we're using the app icon. if (!Flags.notificationsUseAppIcon()) { processSmallIconColor(mN.mSmallIcon, contentView, p); } } /** * @return true if the built notification will show the time or the chronometer; false Loading Loading @@ -6804,7 +6832,8 @@ public class Notification implements Parcelable */ private void processSmallIconColor(Icon smallIcon, RemoteViews contentView, StandardTemplateParams p) { boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); int color = getSmallIconColor(p); contentView.setInt(R.id.icon, "setBackgroundColor", getBackgroundColor(p)); Loading core/java/android/app/notification.aconfig +11 −0 Original line number Diff line number Diff line package: "android.app" # Note: When adding a new flag here, consider including the word "notification(s)" in the flag name # when appropriate, as it's not currently part of the namespace so it may not be obvious what the # flag relates to. flag { name: "modes_api" is_exported: true Loading Loading @@ -40,6 +44,13 @@ flag { bug: "281044385" } flag { name: "notifications_use_app_icon" namespace: "systemui" description: "Experiment to replace the small icon in a notification with the app icon." bug: "335211019" } flag { name: "keyguard_private_notifications" namespace: "systemui" Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconManager.kt +5 −5 Original line number Diff line number Diff line Loading @@ -39,13 +39,13 @@ import com.android.systemui.statusbar.notification.InflationException import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener import java.util.concurrent.ConcurrentHashMap import javax.inject.Inject import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.concurrent.ConcurrentHashMap import javax.inject.Inject import kotlin.coroutines.CoroutineContext /** * Inflates and updates icons associated with notifications Loading Loading @@ -239,8 +239,8 @@ constructor( val sbi = icon.toStatusBarIcon(entry) // Cache if important conversation. if (isImportantConversation(entry)) { // Cache if important conversation or app icon. if (isImportantConversation(entry) || android.app.Flags.notificationsUseAppIcon()) { if (showPeopleAvatar) { entry.icons.peopleAvatarDescriptor = sbi } else { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt +16 −9 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.graphics.Rect import android.view.View import com.android.app.tracing.traceSection import com.android.internal.util.ContrastColorUtil import com.android.systemui.Flags import com.android.systemui.res.R import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.StatusBarIconView.NO_COLOR Loading @@ -34,11 +35,14 @@ object StatusBarIconViewBinder { // view-model (which, at the time of this writing, does not yet exist). suspend fun bindColor(view: StatusBarIconView, color: Flow<Int>) { // Don't change the icon color if an app icon experiment is enabled. if (!android.app.Flags.notificationsUseAppIcon()) { color.collectTracingEach("SBIV#bindColor") { color -> view.staticDrawableColor = color view.setDecorColor(color) } } } suspend fun bindTintAlpha(view: StatusBarIconView, tintAlpha: Flow<Float>) { tintAlpha.collectTracingEach("SBIV#bindTintAlpha") { amt -> view.setTintAlpha(amt) } Loading @@ -53,6 +57,8 @@ object StatusBarIconViewBinder { iconColors: Flow<NotificationIconColors>, contrastColorUtil: ContrastColorUtil, ) { // Don't change the icon color if an app icon experiment is enabled. if (!android.app.Flags.notificationsUseAppIcon()) { iconColors.collectTracingEach("SBIV#bindIconColors") { colors -> val isPreL = java.lang.Boolean.TRUE == view.getTag(R.id.icon_is_pre_L) val isColorized = !isPreL || NotificationUtils.isGrayscale(view, contrastColorUtil) Loading @@ -62,6 +68,7 @@ object StatusBarIconViewBinder { } } } } private val View.viewBounds: Rect get() { Loading Loading
core/java/android/app/Notification.java +32 −3 Original line number Diff line number Diff line Loading @@ -3089,6 +3089,25 @@ public class Notification implements Parcelable } } /** * @hide */ public int loadHeaderAppIconRes(Context context) { ApplicationInfo info = null; if (extras.containsKey(EXTRA_BUILDER_APPLICATION_INFO)) { info = extras.getParcelable( EXTRA_BUILDER_APPLICATION_INFO, ApplicationInfo.class); } if (info == null) { info = context.getApplicationInfo(); } if (info != null) { return info.icon; } return 0; } /** * Removes heavyweight parts of the Notification object for archival or for sending to * listeners when the full contents are not necessary. Loading Loading @@ -5963,13 +5982,22 @@ public class Notification implements Parcelable } private void bindSmallIcon(RemoteViews contentView, StandardTemplateParams p) { if (mN.mSmallIcon == null && mN.icon != 0) { if (Flags.notificationsUseAppIcon()) { // Override small icon with app icon mN.mSmallIcon = Icon.createWithResource(mContext, mN.loadHeaderAppIconRes(mContext)); } else if (mN.mSmallIcon == null && mN.icon != 0) { mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon); } contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon); contentView.setInt(R.id.icon, "setImageLevel", mN.iconLevel); // Don't change color if we're using the app icon. if (!Flags.notificationsUseAppIcon()) { processSmallIconColor(mN.mSmallIcon, contentView, p); } } /** * @return true if the built notification will show the time or the chronometer; false Loading Loading @@ -6804,7 +6832,8 @@ public class Notification implements Parcelable */ private void processSmallIconColor(Icon smallIcon, RemoteViews contentView, StandardTemplateParams p) { boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); int color = getSmallIconColor(p); contentView.setInt(R.id.icon, "setBackgroundColor", getBackgroundColor(p)); Loading
core/java/android/app/notification.aconfig +11 −0 Original line number Diff line number Diff line package: "android.app" # Note: When adding a new flag here, consider including the word "notification(s)" in the flag name # when appropriate, as it's not currently part of the namespace so it may not be obvious what the # flag relates to. flag { name: "modes_api" is_exported: true Loading Loading @@ -40,6 +44,13 @@ flag { bug: "281044385" } flag { name: "notifications_use_app_icon" namespace: "systemui" description: "Experiment to replace the small icon in a notification with the app icon." bug: "335211019" } flag { name: "keyguard_private_notifications" namespace: "systemui" Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconManager.kt +5 −5 Original line number Diff line number Diff line Loading @@ -39,13 +39,13 @@ import com.android.systemui.statusbar.notification.InflationException import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener import java.util.concurrent.ConcurrentHashMap import javax.inject.Inject import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.concurrent.ConcurrentHashMap import javax.inject.Inject import kotlin.coroutines.CoroutineContext /** * Inflates and updates icons associated with notifications Loading Loading @@ -239,8 +239,8 @@ constructor( val sbi = icon.toStatusBarIcon(entry) // Cache if important conversation. if (isImportantConversation(entry)) { // Cache if important conversation or app icon. if (isImportantConversation(entry) || android.app.Flags.notificationsUseAppIcon()) { if (showPeopleAvatar) { entry.icons.peopleAvatarDescriptor = sbi } else { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt +16 −9 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.graphics.Rect import android.view.View import com.android.app.tracing.traceSection import com.android.internal.util.ContrastColorUtil import com.android.systemui.Flags import com.android.systemui.res.R import com.android.systemui.statusbar.StatusBarIconView import com.android.systemui.statusbar.StatusBarIconView.NO_COLOR Loading @@ -34,11 +35,14 @@ object StatusBarIconViewBinder { // view-model (which, at the time of this writing, does not yet exist). suspend fun bindColor(view: StatusBarIconView, color: Flow<Int>) { // Don't change the icon color if an app icon experiment is enabled. if (!android.app.Flags.notificationsUseAppIcon()) { color.collectTracingEach("SBIV#bindColor") { color -> view.staticDrawableColor = color view.setDecorColor(color) } } } suspend fun bindTintAlpha(view: StatusBarIconView, tintAlpha: Flow<Float>) { tintAlpha.collectTracingEach("SBIV#bindTintAlpha") { amt -> view.setTintAlpha(amt) } Loading @@ -53,6 +57,8 @@ object StatusBarIconViewBinder { iconColors: Flow<NotificationIconColors>, contrastColorUtil: ContrastColorUtil, ) { // Don't change the icon color if an app icon experiment is enabled. if (!android.app.Flags.notificationsUseAppIcon()) { iconColors.collectTracingEach("SBIV#bindIconColors") { colors -> val isPreL = java.lang.Boolean.TRUE == view.getTag(R.id.icon_is_pre_L) val isColorized = !isPreL || NotificationUtils.isGrayscale(view, contrastColorUtil) Loading @@ -62,6 +68,7 @@ object StatusBarIconViewBinder { } } } } private val View.viewBounds: Rect get() { Loading