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

Commit 6ff5f103 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

IOBE while diabling accessibility with some enabled accessibility services.

1. Added logic to update the current position in the list of services to be
   disabled in case of a successfully removed (unbound) such service.

Change-Id: I2ac7d3a53026a7c95b10b285fd4280419c903ec6
parent b3fbd7e0
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -532,7 +532,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub

        for (int i = 0, count = services.size(); i < count; i++) {
            Service service = services.get(i);
            service.unbind();
            if (service.unbind()) {
                i--;
                count--;
            }
        }
    }

@@ -575,7 +578,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            Set<ComponentName> enabledServices) {

        Map<ComponentName, Service> componentNameToServiceMap = mComponentNameToServiceMap;
        List<Service> services = mServices;
        boolean isEnabled = mIsEnabled;

        for (int i = 0, count = installedServices.size(); i < count; i++) {
@@ -665,23 +667,30 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub

        /**
         * Binds to the accessibility service.
         *
         * @return True if binding is successful.
         */
        public void bind() {
        public boolean bind() {
            if (mService == null) {
                mContext.bindService(mIntent, this, Context.BIND_AUTO_CREATE);
                return mContext.bindService(mIntent, this, Context.BIND_AUTO_CREATE);
            }
            return false;
        }

        /**
         * Unbinds form the accessibility service and removes it from the data
         * structures for service management.
         *
         * @return True if unbinding is successful.
         */
        public void unbind() {
        public boolean unbind() {
            if (mService != null) {
                mContext.unbindService(this);
                mComponentNameToServiceMap.remove(mComponentName);
                mServices.remove(this);
                return true;
            }
            return false;
        }

        /**