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

Commit 9a17ac85 authored by Jesse Dai's avatar Jesse Dai
Browse files

Add lock screen content description in coroutine

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: I1358e5f00ecb748baa91b78b253337e10faf9b0e
parent e1f6b0a2
Loading
Loading
Loading
Loading
+52 −35
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.accessibility.AccessibilityNodeInfo
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
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.common.ui.view.TouchHandlingView
import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel
import com.android.systemui.lifecycle.WindowLifecycleState
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.plugins.FalsingManager
import com.android.systemui.res.R
import com.android.systemui.res.R
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.MutableStateFlow


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


        view.repeatWhenAttached {
        view.repeatWhenAttached {
            val isLongPressHandlingEnabled = MutableStateFlow(false)

            repeatOnLifecycle(Lifecycle.State.STARTED) {
            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(
            view.viewModel(
                traceName = "KeyguardTouchViewBinderViewModel",
                traceName = "KeyguardTouchViewBinderViewModel",
                minWindowLifecycleState = WindowLifecycleState.ATTACHED,
                minWindowLifecycleState = WindowLifecycleState.ATTACHED,
@@ -65,6 +81,8 @@ object KeyguardTouchViewBinder {
                view.setSnapshotBinding {
                view.setSnapshotBinding {
                    view.setLongPressHandlingEnabled(viewModel.isLongPressHandlingEnabled)
                    view.setLongPressHandlingEnabled(viewModel.isLongPressHandlingEnabled)
                    view.setDoublePressHandlingEnabled(viewModel.isDoubleTapHandlingEnabled)
                    view.setDoublePressHandlingEnabled(viewModel.isDoubleTapHandlingEnabled)

                    isLongPressHandlingEnabled.value = viewModel.isLongPressHandlingEnabled
                }
                }


                view.listener =
                view.listener =
@@ -105,7 +123,6 @@ object KeyguardTouchViewBinder {
            }
            }
        }
        }
    }
    }
    }


    private const val TAG = "KeyguardTouchViewBinder"
    private const val TAG = "KeyguardTouchViewBinder"
}
}