diff options
author | Grace Cheng <graciecheng@google.com> | 2023-08-02 23:06:10 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-08-11 03:49:10 +0000 |
commit | 0196f8a09e26462cf0eb7085c2c149c131204afe (patch) | |
tree | e82972043b1ae4fb49b3724fcf78d254e4ccc727 | |
parent | ee02b78304245530836c27c7c1a386e6d4dbf528 (diff) | |
download | base-0196f8a09e26462cf0eb7085c2c149c131204afe.tar.gz |
Use announceForAccessibility to workaround Talkback rate-limitation
Talkback 14.0 has new rate-limitation design to reduce frequency of
TYPE_WINDOW_CONTENT_CHANGED events to once every 30 seconds. Since
showing error and help messages in BiometricPrompt requires sending
events exceeding this frequency, use View#announceForAccessibility as a
workaround (context: b/281765653#comment18)
Test: Manually verified all missing talkback announcements are fixed
Fixes: 289145585
Fixes: 289011350
Fixes: 289006313
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f58e41308b58b4f0131b2b3bfeee9528e0d1bf62)
Merged-In: I058be826cebe6f3f4ab3fcfd36389d97e44b2189
Change-Id: I058be826cebe6f3f4ab3fcfd36389d97e44b2189
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/Utils.kt | 7 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt | 29 |
2 files changed, 21 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/Utils.kt b/packages/SystemUI/src/com/android/systemui/biometrics/Utils.kt index b538085fa40d..1ca57e77034c 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/Utils.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/Utils.kt @@ -60,6 +60,13 @@ object Utils { return dp * (density / DisplayMetrics.DENSITY_DEFAULT) } + /** + * Note: Talkback 14.0 has new rate-limitation design to reduce frequency + * of TYPE_WINDOW_CONTENT_CHANGED events to once every 30 seconds. + * (context: b/281765653#comment18) + * Using {@link View#announceForAccessibility} instead as workaround when sending events + * exceeding this frequency is required. + */ @JvmStatic fun notifyAccessibilityContentChanged(am: AccessibilityManager, view: ViewGroup) { if (!am.isEnabled) { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt index 62475df0ac3f..f7625cd9b859 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt @@ -45,7 +45,6 @@ import com.android.systemui.biometrics.AuthBiometricView.Callback import com.android.systemui.biometrics.AuthBiometricViewAdapter import com.android.systemui.biometrics.AuthIconController import com.android.systemui.biometrics.AuthPanelController -import com.android.systemui.biometrics.Utils import com.android.systemui.biometrics.domain.model.BiometricModalities import com.android.systemui.biometrics.shared.model.BiometricModality import com.android.systemui.biometrics.shared.model.PromptKind @@ -80,9 +79,6 @@ object BiometricViewBinder { applicationScope: CoroutineScope, ): AuthBiometricViewAdapter { val accessibilityManager = view.context.getSystemService(AccessibilityManager::class.java)!! - fun notifyAccessibilityChanged() { - Utils.notifyAccessibilityContentChanged(accessibilityManager, view) - } val textColorError = view.resources.getColor(R.color.biometric_dialog_error, view.context.theme) @@ -326,21 +322,14 @@ object BiometricViewBinder { } } - // not sure why this is here, but the legacy code did it probably needed? - launch { - viewModel.isAuthenticating.collect { isAuthenticating -> - if (isAuthenticating) { - notifyAccessibilityChanged() - } - } - } - // dismiss prompt when authenticated and confirmed launch { viewModel.isAuthenticated.collect { authState -> // Disable background view for cancelling authentication once authenticated, // and remove from talkback if (authState.isAuthenticated) { + // Prevents Talkback from speaking subtitle after already authenticated + subtitleView.importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_NO backgroundView.setOnClickListener(null) backgroundView.importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_NO @@ -349,7 +338,6 @@ object BiometricViewBinder { view.announceForAccessibility( view.resources.getString(R.string.biometric_dialog_authenticated) ) - notifyAccessibilityChanged() launch { delay(authState.delay) @@ -381,7 +369,18 @@ object BiometricViewBinder { !accessibilityManager.isEnabled || !accessibilityManager.isTouchExplorationEnabled - notifyAccessibilityChanged() + /** + * Note: Talkback 14.0 has new rate-limitation design to reduce frequency of + * TYPE_WINDOW_CONTENT_CHANGED events to once every 30 seconds. (context: + * b/281765653#comment18) Using {@link View#announceForAccessibility} + * instead as workaround since sending events exceeding this frequency is + * required. + */ + indicatorMessageView?.text?.let { + if (it.isNotBlank()) { + view.announceForAccessibility(it) + } + } } } } |