Revert^3 "Fix for a11yManagerService broadcastReceiver ANR"

This reverts commit 552f6eab4214b0a8ca09ca0d5dee5bb06d97c400.

Reason for revert: Likely culprit for b/338952107  - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I2eb76c951e3395417c75a55e537f1eeb54e48047
diff --git a/services/accessibility/accessibility.aconfig b/services/accessibility/accessibility.aconfig
index 69efdf6..a754ba5 100644
--- a/services/accessibility/accessibility.aconfig
+++ b/services/accessibility/accessibility.aconfig
@@ -83,16 +83,6 @@
 }
 
 flag {
-    name: "manager_avoid_receiver_timeout"
-    namespace: "accessibility"
-    description: "Avoid broadcast receiver timeout by offloading potentially slow operations to the background thread."
-    bug: "333890389"
-    metadata {
-        purpose: PURPOSE_BUGFIX
-    }
-}
-
-flag {
     name: "pinch_zoom_zero_min_span"
     namespace: "accessibility"
     description: "Whether to set min span of ScaleGestureDetector to zero."
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index ab55eb7a..cbb66dc 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -1028,10 +1028,37 @@
                             "context=" + context + ";intent=" + intent);
                 }
 
-                if (com.android.server.accessibility.Flags.managerAvoidReceiverTimeout()) {
-                    BackgroundThread.getHandler().post(() -> processBroadcast(intent));
-                } else {
-                    processBroadcast(intent);
+                String action = intent.getAction();
+                if (Intent.ACTION_USER_SWITCHED.equals(action)) {
+                    switchUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
+                } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
+                    unlockUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
+                } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
+                    removeUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
+                } else if (Intent.ACTION_SETTING_RESTORED.equals(action)) {
+                    final String which = intent.getStringExtra(Intent.EXTRA_SETTING_NAME);
+                    if (Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES.equals(which)) {
+                        synchronized (mLock) {
+                            restoreEnabledAccessibilityServicesLocked(
+                                    intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE),
+                                    intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE),
+                                    intent.getIntExtra(Intent.EXTRA_SETTING_RESTORED_FROM_SDK_INT,
+                                            0));
+                        }
+                    } else if (ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(which)) {
+                        synchronized (mLock) {
+                            restoreLegacyDisplayMagnificationNavBarIfNeededLocked(
+                                    intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE),
+                                    intent.getIntExtra(Intent.EXTRA_SETTING_RESTORED_FROM_SDK_INT,
+                                            0));
+                        }
+                    } else if (Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS.equals(which)) {
+                        synchronized (mLock) {
+                            restoreAccessibilityButtonTargetsLocked(
+                                    intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE),
+                                    intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE));
+                        }
+                    }
                 }
             }
         }, UserHandle.ALL, intentFilter, null, null);
@@ -1954,19 +1981,6 @@
         mA11yWindowManager.onTouchInteractionEnd();
     }
 
-    private void processBroadcast(Intent intent) {
-        String action = intent.getAction();
-        if (Intent.ACTION_USER_SWITCHED.equals(action)) {
-            switchUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
-        } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
-            unlockUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
-        } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
-            removeUser(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
-        } else if (Intent.ACTION_SETTING_RESTORED.equals(action)) {
-            restoreSetting(intent);
-        }
-    }
-
     @VisibleForTesting
     void switchUser(int userId) {
         mMagnificationController.updateUserIdIfNeeded(userId);
@@ -2065,38 +2079,6 @@
         getMagnificationController().onUserRemoved(userId);
     }
 
-    private void restoreSetting(Intent intent) {
-        final String which = intent.getStringExtra(Intent.EXTRA_SETTING_NAME);
-        if (Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES.equals(which)) {
-            synchronized (mLock) {
-                restoreEnabledAccessibilityServicesLocked(
-                        intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE),
-                        intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE),
-                        intent.getIntExtra(Intent.EXTRA_SETTING_RESTORED_FROM_SDK_INT,
-                                0));
-            }
-        } else if (ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(which)) {
-            synchronized (mLock) {
-                restoreLegacyDisplayMagnificationNavBarIfNeededLocked(
-                        intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE),
-                        intent.getIntExtra(Intent.EXTRA_SETTING_RESTORED_FROM_SDK_INT,
-                                0));
-            }
-        } else if (Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS.equals(which)) {
-            synchronized (mLock) {
-                restoreAccessibilityButtonTargetsLocked(
-                        intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE),
-                        intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE));
-            }
-        } else if (Settings.Secure.ACCESSIBILITY_QS_TARGETS.equals(which)) {
-            if (!android.view.accessibility.Flags.a11yQsShortcut()) {
-                return;
-            }
-            restoreAccessibilityQsTargets(
-                    intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE));
-        }
-    }
-
     // Called only during settings restore; currently supports only the owner user
     // TODO: http://b/22388012
     void restoreEnabledAccessibilityServicesLocked(String oldSetting, String newSetting,