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

Commit 14ed6cf3 authored by Phil Weaver's avatar Phil Weaver
Browse files

Ignore feedbackType in AccessibilityEvent dispatch

Send AccessibilityEvents to all accessibility services
that request them. No longer refuse to send them to
services with the same feedback type.

Change-Id: I137905c24fc75c075ab938175ecb6ea5f39112cf
parent 2829e996
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -178,15 +178,8 @@ import java.util.Set;
 * </p>
 * <h3>Notification strategy</h3>
 * <p>
 * For each feedback type only one accessibility service is notified. Services are notified
 * in the order of registration. Hence, if two services are registered for the same
 * feedback type in the same package the first one wins. It is possible however, to
 * register a service as the default one for a given feedback type. In such a case this
 * service is invoked if no other service was interested in the event. In other words, default
 * services do not compete with other services and are notified last regardless of the
 * registration order. This enables "generic" accessibility services that work reasonably
 * well with most applications to coexist with "polished" ones that are targeted for
 * specific applications.
 * All accessibility services are notified of all events they have requested, regardless of their
 * feedback type.
 * </p>
 * <p class="note">
 * <strong>Note:</strong> The event notification timeout is useful to avoid propagating
+5 −24
Original line number Diff line number Diff line
@@ -433,7 +433,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                        AccessibilityEvent.obtain(event)).sendToTarget();
            }
            event.recycle();
            getUserStateLocked(resolvedUserId).mHandledFeedbackTypes = 0;
        }
        return (OWN_PROCESS_ID != Binder.getCallingPid());
    }
@@ -1051,9 +1050,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                Service service = state.mBoundServices.get(i);

                if (service.mIsDefault == isDefault) {
                    if (canDispatchEventToServiceLocked(service, event,
                            state.mHandledFeedbackTypes)) {
                        state.mHandledFeedbackTypes |= service.mFeedbackType;
                    if (canDispatchEventToServiceLocked(service, event)) {
                        service.notifyAccessibilityEvent(event);
                    }
                }
@@ -1088,19 +1085,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {

    /**
     * Determines if given event can be dispatched to a service based on the package of the
     * event source and already notified services for that event type. Specifically, a
     * service is notified if it is interested in events from the package and no other service
     * providing the same feedback type has been notified. Exception are services the
     * provide generic feedback (feedback type left as a safety net for unforeseen feedback
     * types) which are always notified.
     * event source. Specifically, a service is notified if it is interested in events from the
     * package.
     *
     * @param service The potential receiver.
     * @param event The event.
     * @param handledFeedbackTypes The feedback types for which services have been notified.
     * @return True if the listener should be notified, false otherwise.
     */
    private boolean canDispatchEventToServiceLocked(Service service, AccessibilityEvent event,
            int handledFeedbackTypes) {
    private boolean canDispatchEventToServiceLocked(Service service, AccessibilityEvent event) {

        if (!service.canReceiveEventsLocked()) {
            return false;
@@ -1121,15 +1113,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
        String packageName = (event.getPackageName() != null)
                ? event.getPackageName().toString() : null;

        if (packageNames.isEmpty() || packageNames.contains(packageName)) {
            int feedbackType = service.mFeedbackType;
            if ((handledFeedbackTypes & feedbackType) != feedbackType
                    || feedbackType == AccessibilityServiceInfo.FEEDBACK_GENERIC) {
                return true;
            }
        }

        return false;
        return (packageNames.isEmpty() || packageNames.contains(packageName));
    }

    private void unbindAllServicesLocked(UserState userState) {
@@ -3886,8 +3870,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
        public final Set<ComponentName> mTouchExplorationGrantedServices =
                new HashSet<>();

        public int mHandledFeedbackTypes = 0;

        public int mLastSentClientState = -1;

        public boolean mIsAccessibilityEnabled;
@@ -3950,7 +3932,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
            mBindingServices.clear();

            // Clear event management state.
            mHandledFeedbackTypes = 0;
            mLastSentClientState = -1;

            // Clear state persisted in settings.