summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steve Elliott <steell@google.com> 2024-01-19 20:59:35 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-01-19 20:59:35 +0000
commitff93fc4025578ba4b64b9b0d9d2f4c084c45cda4 (patch)
tree7532bb46844038301b8a1361f3e34f59344f1ebc
parent52ca11615da0f345b6afa857646562fb371f8488 (diff)
parent7767ba4663a755af1607400f0ce26846ed144ca4 (diff)
Merge "Add IconContainerRefactor tracing to flow collects" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt21
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt14
2 files changed, 23 insertions, 12 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt
index ae772880f148..0bc8e682c891 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt
@@ -142,7 +142,7 @@ object NotificationIconContainerViewBinder {
/** Binds to [NotificationIconContainer.setAnimationsEnabled] */
private suspend fun Flow<Boolean>.bindAnimationsEnabled(view: NotificationIconContainer) {
- collect(view::setAnimationsEnabled)
+ collectTracingEach("NIC#bindAnimationsEnabled", view::setAnimationsEnabled)
}
private suspend fun NotificationIconContainerStatusBarViewModel.bindIsolatedIcon(
@@ -151,12 +151,12 @@ object NotificationIconContainerViewBinder {
) {
coroutineScope {
launch {
- isolatedIconLocation.collect { location ->
+ isolatedIconLocation.collectTracingEach("NIC#isolatedIconLocation") { location ->
view.setIsolatedIconLocation(location, true)
}
}
launch {
- isolatedIcon.collect { iconInfo ->
+ isolatedIcon.collectTracingEach("NIC#showIconIsolated") { iconInfo ->
val iconView = iconInfo.value?.let { viewStore.iconView(it.notifKey) }
if (iconInfo.isAnimating) {
view.showIconIsolatedAnimated(iconView, iconInfo::stopAnimating)
@@ -214,7 +214,7 @@ object NotificationIconContainerViewBinder {
val failedBindings = mutableSetOf<String>()
val boundViewsByNotifKey = ArrayMap<String, Pair<StatusBarIconView, Job>>()
var prevIcons = NotificationIconsViewData()
- collectTracingEach("NotifIconContainer#bindIcons") { iconsData: NotificationIconsViewData ->
+ collectTracingEach("NIC#bindIcons") { iconsData: NotificationIconsViewData ->
val iconsDiff = NotificationIconsViewData.computeDifference(iconsData, prevIcons)
prevIcons = iconsData
@@ -265,7 +265,11 @@ object NotificationIconContainerViewBinder {
Pair(
sbiv,
launch {
- launch { layoutParams.collect { sbiv.layoutParams = it } }
+ launch {
+ layoutParams.collectTracingEach("SBIV#bindLayoutParams") {
+ sbiv.layoutParams = it
+ }
+ }
bindIcon(notifKey, sbiv)
},
)
@@ -369,6 +373,7 @@ private val View.viewBounds: Rect
)
}
-private suspend fun <T> Flow<T>.collectTracingEach(tag: String, collector: (T) -> Unit) {
- collect { traceSection(tag) { collector(it) } }
-}
+private suspend inline fun <T> Flow<T>.collectTracingEach(
+ tag: String,
+ crossinline collector: (T) -> Unit,
+) = collect { traceSection(tag) { collector(it) } }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt
index 03316548e979..bfeaced72162 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBinder.kt
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.icon.ui.viewbinder
import android.graphics.Rect
import android.view.View
+import com.android.app.tracing.traceSection
import com.android.internal.util.ContrastColorUtil
import com.android.systemui.res.R
import com.android.systemui.statusbar.StatusBarIconView
@@ -33,18 +34,18 @@ object StatusBarIconViewBinder {
// view-model (which, at the time of this writing, does not yet exist).
suspend fun bindColor(view: StatusBarIconView, color: Flow<Int>) {
- color.collect { color ->
+ color.collectTracingEach("SBIV#bindColor") { color ->
view.staticDrawableColor = color
view.setDecorColor(color)
}
}
suspend fun bindTintAlpha(view: StatusBarIconView, tintAlpha: Flow<Float>) {
- tintAlpha.collect { amt -> view.setTintAlpha(amt) }
+ tintAlpha.collectTracingEach("SBIV#bindTintAlpha") { amt -> view.setTintAlpha(amt) }
}
suspend fun bindAnimationsEnabled(view: StatusBarIconView, allowAnimation: Flow<Boolean>) {
- allowAnimation.collect(view::setAllowAnimation)
+ allowAnimation.collectTracingEach("SBIV#bindAnimationsEnabled", view::setAllowAnimation)
}
suspend fun bindIconColors(
@@ -52,7 +53,7 @@ object StatusBarIconViewBinder {
iconColors: Flow<NotificationIconColors>,
contrastColorUtil: ContrastColorUtil,
) {
- iconColors.collect { colors ->
+ 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)
view.staticDrawableColor =
@@ -73,3 +74,8 @@ private val View.viewBounds: Rect
/* bottom = */ top + height,
)
}
+
+private suspend inline fun <T> Flow<T>.collectTracingEach(
+ tag: String,
+ crossinline collector: (T) -> Unit,
+) = collect { traceSection(tag) { collector(it) } }