Merge "Starting long-press effect coroutines on CREATED" into main
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
index 1705909..f4998a7 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
@@ -18,10 +18,10 @@
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
+import com.android.app.tracing.coroutines.launch
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.qs.tileimpl.QSTileViewImpl
import kotlinx.coroutines.DisposableHandle
-import kotlinx.coroutines.launch
class QSLongPressEffectViewBinder {
@@ -31,16 +31,18 @@
fun bind(
tile: QSTileViewImpl,
+ tileSpec: String?,
effect: QSLongPressEffect?,
) {
if (effect == null) return
handle =
tile.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
+ repeatOnLifecycle(Lifecycle.State.CREATED) {
effect.scope = this
+ val tag = "${tileSpec ?: "unknownTileSpec"}#LongPressEffect"
- launch {
+ launch("$tag#progress") {
effect.effectProgress.collect { progress ->
progress?.let {
if (it == 0f) {
@@ -51,7 +53,7 @@
}
}
- launch {
+ launch("$tag#action") {
effect.actionType.collect { action ->
action?.let {
when (it) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
index 2360f27..3004485 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -620,7 +620,7 @@
showRippleEffect = false
setOnTouchListener(longPressEffect)
if (!longPressEffectViewBinder.isBound) {
- longPressEffectViewBinder.bind(this, longPressEffect)
+ longPressEffectViewBinder.bind(this, state.spec, longPressEffect)
}
} else {
// Long-press effects might have been enabled before but the new state does not