Disable the Accessibility Shortcut dialog on TV.
When the user presses the accessibility shortcut (e.g. to enable the screen-reader), some dialog would show up that asked if the user really wanted to do that. This behaviour is confusing to users. Instead, on TV we want to directly trigger the shortcut action whenever the shortcut is performed.
Bug: b/238744704
Test: Locally tested on adt4-userdebug
Change-Id: I85567c4db7632ee51e8e29ce753ed7bda386f4e2
diff --git a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
index 43be031..e0b0110 100644
--- a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
+++ b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
@@ -226,9 +226,7 @@
Slog.d(TAG, "Accessibility shortcut activated");
final ContentResolver cr = mContext.getContentResolver();
final int userId = ActivityManager.getCurrentUser();
- final int dialogAlreadyShown = Settings.Secure.getIntForUser(
- cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, DialogStatus.NOT_SHOWN,
- userId);
+
// Play a notification vibration
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
if ((vibrator != null) && vibrator.hasVibrator()) {
@@ -239,7 +237,7 @@
vibrator.vibrate(vibePattern, -1, VIBRATION_ATTRIBUTES);
}
- if (dialogAlreadyShown == DialogStatus.NOT_SHOWN) {
+ if (shouldShowDialog()) {
// The first time, we show a warning rather than toggle the service to give the user a
// chance to turn off this feature before stuff gets enabled.
mAlertDialog = createShortcutWarningDialog(userId);
@@ -269,6 +267,20 @@
}
}
+ /** Whether the warning dialog should be shown instead of performing the shortcut. */
+ private boolean shouldShowDialog() {
+ if (hasFeatureLeanback()) {
+ // Never show the dialog on TV, instead always perform the shortcut directly.
+ return false;
+ }
+ final ContentResolver cr = mContext.getContentResolver();
+ final int userId = ActivityManager.getCurrentUser();
+ final int dialogAlreadyShown = Settings.Secure.getIntForUser(cr,
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, DialogStatus.NOT_SHOWN,
+ userId);
+ return dialogAlreadyShown == DialogStatus.NOT_SHOWN;
+ }
+
/**
* Show toast to alert the user that the accessibility shortcut turned on or off an
* accessibility service.