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

Commit 96cd9e7c authored by Svetoslav's avatar Svetoslav
Browse files

First accessibility device disabled if enableing a second one is canceled.

The value whether accessibility should stay enabled was incorrectly
computed and as a result accessibility was disaabled when the second
accessibility service enabling is canceled.

bug:7716830

Change-Id: Ic23c24b1ffa90811e21210aeeca158568ad37904
parent 8c94273c
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -726,25 +726,22 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements

            // Determine enabled services and accessibility state.
            ComponentName toggledService = ComponentName.unflattenFromString(preferenceKey);
            final boolean accessibilityEnabled;
            boolean accessibilityEnabled = false;
            if (enabled) {
                enabledServices.add(toggledService);
                // Enabling at least one service enables accessibility.
                accessibilityEnabled = true;
                enabledServices.add(toggledService);
            } else {
                enabledServices.remove(toggledService);
                // Check how many enabled and installed services are present.
                int enabledAndInstalledServiceCount = 0;
                Set<ComponentName> installedServices = sInstalledServices;
                for (ComponentName enabledService : enabledServices) {
                    if (installedServices.contains(enabledService)) {
                        enabledAndInstalledServiceCount++;
                        // Disabling the last service disables accessibility.
                        accessibilityEnabled = true;
                        break;
                    }
                }
                // Disabling the last service disables accessibility.
                accessibilityEnabled = enabledAndInstalledServiceCount > 1
                        || (enabledAndInstalledServiceCount == 1
                        && !installedServices.contains(toggledService));
                enabledServices.remove(toggledService);
            }

            // Update the enabled services setting.