5

I have two Accessibility services in two different apps on a device. Each of them draws some view over other apps. I faced with the following problem: when 2 Accessibility services are enabled, only one draws view, another one doesn't get any events.

Configuration for events is following:

 @Override
 protected void onServiceConnected() {
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
    info.feedbackType = AccessibilityEvent.TYPES_ALL_MASK;
    info.notificationTimeout = TIMEOUT_IN_MS;
    setServiceInfo(info);
    super.onServiceConnected();
 }

I can reproduce it on pre-Lollipop Android version, also on Android M. Whilst on Android O and N, all services work fine.

Could somebody please explain to me how it can happen, maybe there are some improvements starting from Android N? If there is a way to make them work at the same time, could you please provide me an implementation of this?

Ruslan Leshchenko
  • 4,043
  • 4
  • 24
  • 36

1 Answers1

2

You actually simply can't run two accessibility services at a time Pre Android N. One will always crash, and create a stale/daemon service that runs in the background, preventing you from restarting the service that crashed. This independent of how the service functions and what it does. In fact, even the fake UIAutomation service that runs with Android Instrumentation tests will cause a running service to crash. There is no way around this limitation.

MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • But there are no any crashes. – Ruslan Leshchenko Nov 02 '17 at 11:47
  • It won't like ANR, it will just print out a warning stack Trace and go into daemon mode. – MobA11y Nov 02 '17 at 13:36
  • Thanks for the explanation. – Ruslan Leshchenko Nov 02 '17 at 13:39
  • Looks like a possibility of working more than one Accessibility service depends on a configuration of these services. In other words, two and more Accessibility services will work if their configurations are different. If there are 2 Accessibility services with the same configuration, the only service which was enabled first will work. Do you know something about it? – Ruslan Leshchenko Nov 03 '17 at 15:24
  • Feedback Type is the property you're looking for. Different feedback types are supported... I'm not sure when the support for that got added. L or M I believe. If was in before that, it was very bugged, because it never worked for me. – MobA11y Nov 03 '17 at 18:22