Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba208927 authored by Jesse Dai's avatar Jesse Dai
Browse files

Add lock screen content description in coroutine

Re-land ag/33259309 with fix for open/close lock screen
notification shade issue found in b/414696157.

Adding lock screen content description in ag/32709985 is causing
performance regression seen in b/408731118 and b/408634675. Setting
the view's contentDescription in `setSnapshotBinding` is delaying the
UI frame. Reverted ag/32858690 and this change re-adds the
contentDescription inside of coroutine to avoid blocking `setSnapshotBinding`.

This is a temporary solution to resolve regressions until we find a
better solution.

Bug: 408050048
Bug: 413403813
Flag: EXEMPT bug fix
Test: manual - verify Talkback lock screen label in lock screen
and no label with quick setting shade open

Change-Id: If938ad5ff11d9be1285dbaabbb30cade34c0aeef
parent c741bdba
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.accessibility.AccessibilityNodeInfo
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.common.ui.view.TouchHandlingView
import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel
import com.android.systemui.lifecycle.WindowLifecycleState
@@ -31,6 +32,7 @@ import com.android.systemui.lifecycle.viewModel
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.res.R
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.MutableStateFlow

object KeyguardTouchViewBinder {
    /**
@@ -56,7 +58,20 @@ object KeyguardTouchViewBinder {
            )

        view.repeatWhenAttached {
            val isLongPressHandlingEnabled = MutableStateFlow(false)

            repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch("$TAG#viewModel.isLongPressHandlingEnabled") {
                    isLongPressHandlingEnabled.collect { isEnabled ->
                        view.contentDescription =
                            if (isEnabled) {
                                view.resources.getString(R.string.accessibility_desc_lock_screen)
                            } else {
                                null
                            }
                    }
                }

                view.viewModel(
                    traceName = "KeyguardTouchViewBinderViewModel",
                    minWindowLifecycleState = WindowLifecycleState.ATTACHED,
@@ -65,6 +80,8 @@ object KeyguardTouchViewBinder {
                    view.setSnapshotBinding {
                        view.setLongPressHandlingEnabled(viewModel.isLongPressHandlingEnabled)
                        view.setDoublePressHandlingEnabled(viewModel.isDoubleTapHandlingEnabled)

                        isLongPressHandlingEnabled.value = viewModel.isLongPressHandlingEnabled
                    }

                    view.listener =