Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Several apps which draw view over other apps with help Accessibility service doesn't work at the same time

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?

like image 240
Ruslan Leshchenko Avatar asked Oct 28 '22 23:10

Ruslan Leshchenko


1 Answers

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.

like image 133
ChrisCM Avatar answered Nov 05 '22 10:11

ChrisCM