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

Commit 73b1354b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "a11y-revert" into main

* changes:
  Revert "Replace UDFPS BiometricPrompt a11y announcements with live region"
  Revert "Clear UDFPS BiometricPrompt a11y messages after read by talkback"
parents ffaaca50 43a88d99
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -21,9 +21,6 @@
        style="@style/AuthCredentialPanelStyle"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:accessibilityLiveRegion="assertive"
        android:importantForAccessibility="auto"
        android:clickable="false"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/rightGuideline"
        app:layout_constraintStart_toStartOf="@id/leftGuideline"
+0 −3
Original line number Diff line number Diff line
@@ -22,9 +22,6 @@ android:layout_height="match_parent">
        style="@style/AuthCredentialPanelStyle"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:accessibilityLiveRegion="assertive"
        android:importantForAccessibility="auto"
        android:clickable="false"
        android:paddingHorizontal="16dp"
        android:paddingVertical="16dp"
        android:visibility="visible"
+22 −38
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO
import android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES
import android.view.accessibility.AccessibilityManager
import android.widget.Button
import android.widget.ImageView
@@ -44,6 +43,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieCompositionFactory
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.biometrics.Utils.ellipsize
import com.android.systemui.biometrics.shared.model.BiometricModalities
import com.android.systemui.biometrics.shared.model.BiometricModality
@@ -63,7 +63,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch

private const val TAG = "BiometricViewBinder"

@@ -124,19 +123,6 @@ object BiometricViewBinder {
        val confirmationButton = view.requireViewById<Button>(R.id.button_confirm)
        val retryButton = view.requireViewById<Button>(R.id.button_try_again)

        // TODO(b/330788871): temporary workaround for the unsafe callbacks & legacy controllers
        val adapter =
            Spaghetti(
                view = view,
                viewModel = viewModel,
                applicationContext = view.context.applicationContext,
                applicationScope = applicationScope,
            )

        // bind to prompt
        var boundSize = false

        view.repeatWhenAttached {
        // Handles custom "Cancel Authentication" talkback action
        val cancelDelegate: AccessibilityDelegateCompat =
            object : AccessibilityDelegateCompat() {
@@ -145,18 +131,10 @@ object BiometricViewBinder {
                    info: AccessibilityNodeInfoCompat,
                ) {
                    super.onInitializeAccessibilityNodeInfo(host, info)
                        lifecycleScope.launch {
                            // Clears UDFPS guidance hint after focus moves to cancel view
                            viewModel.onClearUdfpsGuidanceHint(
                                accessibilityManager.isTouchExplorationEnabled
                            )
                        }
                    info.addAction(
                        AccessibilityActionCompat(
                            AccessibilityNodeInfoCompat.ACTION_CLICK,
                                view.context.getString(
                                    R.string.biometric_dialog_cancel_authentication
                                ),
                            view.context.getString(R.string.biometric_dialog_cancel_authentication),
                        )
                    )
                }
@@ -164,6 +142,19 @@ object BiometricViewBinder {
        ViewCompat.setAccessibilityDelegate(backgroundView, cancelDelegate)
        ViewCompat.setAccessibilityDelegate(cancelButton, cancelDelegate)

        // TODO(b/330788871): temporary workaround for the unsafe callbacks & legacy controllers
        val adapter =
            Spaghetti(
                view = view,
                viewModel = viewModel,
                applicationContext = view.context.applicationContext,
                applicationScope = applicationScope,
            )

        // bind to prompt
        var boundSize = false

        view.repeatWhenAttached {
            // these do not change and need to be set before any size transitions
            val modalities = viewModel.modalities.first()

@@ -406,23 +397,16 @@ object BiometricViewBinder {
                // Talkback directional guidance
                udfpsGuidanceView.setOnHoverListener { _, event ->
                    launch {
                        viewModel.onUpdateAccessibilityHint(
                        viewModel.onAnnounceAccessibilityHint(
                            event,
                            accessibilityManager.isTouchExplorationEnabled,
                        )
                    }
                    false
                }

                launch {
                    viewModel.accessibilityHint.collect { message ->
                        udfpsGuidanceView.importantForAccessibility =
                            if (message == null) {
                                IMPORTANT_FOR_ACCESSIBILITY_NO
                            } else {
                                IMPORTANT_FOR_ACCESSIBILITY_YES
                            }
                        udfpsGuidanceView.contentDescription = message
                        if (message.isNotBlank()) view.announceForAccessibility(message)
                    }
                }

+3 −16
Original line number Diff line number Diff line
@@ -187,10 +187,10 @@ constructor(
            }
        }

    private val _accessibilityHint = MutableSharedFlow<String?>()
    private val _accessibilityHint = MutableSharedFlow<String>()

    /** Hint for talkback directional guidance */
    val accessibilityHint: Flow<String?> = _accessibilityHint.asSharedFlow()
    val accessibilityHint: Flow<String> = _accessibilityHint.asSharedFlow()

    private val _isAuthenticating: MutableStateFlow<Boolean> = MutableStateFlow(false)

@@ -886,7 +886,7 @@ constructor(
    }

    /** Sets the message used for UDFPS directional guidance */
    suspend fun onUpdateAccessibilityHint(
    suspend fun onAnnounceAccessibilityHint(
        event: MotionEvent,
        touchExplorationEnabled: Boolean,
    ): Boolean {
@@ -923,19 +923,6 @@ constructor(
        return false
    }

    /** Clears the message used for UDFPS directional guidance */
    suspend fun onClearUdfpsGuidanceHint(touchExplorationEnabled: Boolean) {
        if (
            modalities.first().hasUdfps &&
                touchExplorationEnabled &&
                !isAuthenticated.first().isAuthenticated
        ) {
            // Add delay to make sure we read the guidance message before clearing it
            delay(1000)
            _accessibilityHint.emit(null)
        }
    }

    /**
     * Switch to the credential view.
     *
+2 −10
Original line number Diff line number Diff line
@@ -1472,7 +1472,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
        whenever(kosmos.udfpsUtils.onTouchOutsideOfSensorArea(any(), any(), any(), any(), any()))
            .thenReturn("Direction")

        kosmos.promptViewModel.onUpdateAccessibilityHint(
        kosmos.promptViewModel.onAnnounceAccessibilityHint(
            obtainMotionEvent(MotionEvent.ACTION_HOVER_ENTER),
            true,
        )
@@ -1482,14 +1482,6 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
        } else {
            assertThat(hint.isNullOrBlank()).isTrue()
        }

        kosmos.promptViewModel.onClearUdfpsGuidanceHint(true)

        if (testCase.modalities.hasUdfps) {
            assertThat(hint).isNull()
        } else {
            assertThat(hint.isNullOrBlank()).isTrue()
        }
    }

    @Test
@@ -1505,7 +1497,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
        whenever(kosmos.udfpsUtils.onTouchOutsideOfSensorArea(any(), any(), any(), any(), any()))
            .thenReturn("Direction")

        kosmos.promptViewModel.onUpdateAccessibilityHint(
        kosmos.promptViewModel.onAnnounceAccessibilityHint(
            obtainMotionEvent(MotionEvent.ACTION_HOVER_ENTER),
            true,
        )