Disables warning dialog when hardware shortcut enabled on purpose

If AccessibilityManager is called to enable a hardware shortcut,
it will turn off the first-time warning dialog for using the shortcut

(This change also replaces instances of RequresFlagsEnabled/Disabled
with Enable/DisableFlags in AccessibilityManagerServiceTest)

Test: atest AccessibilityManagerServiceTest
Flag: aconfig enable_hardware_shortcut_disables_warning
Bug: 287065325
Change-Id: Ic60bf3c73c6be1f6c6477430349fb9d4a8d74358
diff --git a/services/accessibility/accessibility.aconfig b/services/accessibility/accessibility.aconfig
index bfa1c7b..8ab2e0f 100644
--- a/services/accessibility/accessibility.aconfig
+++ b/services/accessibility/accessibility.aconfig
@@ -56,6 +56,13 @@
 }
 
 flag {
+  name: "enable_hardware_shortcut_disables_warning"
+  namespace: "accessibility"
+  description: "When the user purposely enables the hardware shortcut, preemptively disables the first-time warning message."
+  bug: "287065325"
+}
+
+flag {
     name: "enable_magnification_joystick"
     namespace: "accessibility"
     description: "Whether to enable joystick controls for magnification"
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index e64e500..ccf9a90 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -4273,6 +4273,13 @@
         }
         if (shortcutType == UserShortcutType.HARDWARE) {
             skipVolumeShortcutDialogTimeoutRestriction(userId);
+            if (com.android.server.accessibility.Flags.enableHardwareShortcutDisablesWarning()) {
+                persistIntToSetting(
+                        userId,
+                        Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
+                        AccessibilityShortcutController.DialogStatus.SHOWN
+                );
+            }
         } else if (shortcutType == UserShortcutType.SOFTWARE) {
             // Update the A11y FAB size to large when the Magnification shortcut is
             // enabled and the user hasn't changed the floating button size