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

Commit 2827105d authored by Priyanka Advani's avatar Priyanka Advani Committed by Android (Google) Code Review
Browse files

Merge "Revert "Fix for a11yManagerService broadcastReceiver ANR"" into 24D1-dev

parents c713bed2 4efa452d
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -82,16 +82,6 @@ flag {
    }
}

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"
+31 −49
Original line number Diff line number Diff line
@@ -1028,10 +1028,37 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                            "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 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        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 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        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,