Testing Android Accessibility Services
See original GitHub issueI’m trying to find a way to test Accessibility Services on Android (4.4) but I don’t get it working.
As a proof-of-concept I’m trying to test a simple accessiblity service that logs notifications.
I have been able to narrow down the issue to the UiAutomator. Everything works fine as long as I’m not using the UiAutomator, but as soon as the UiAutomator is involved the Accessibility Services are destroyed (see dumpsys and uiautomator outputs below). The Service are not disabled but simply destroyed i.e. they are still “on” according to the “Settings / Accessibility” i.e. to re-enable them I need to disable them first and then enable them.
The same happens if I’m starting an App via Appium, except that the dumpsys accessiblity
fails when executed when the Appium Session is open.
Is this something that could/should be managed by the Appium Bootstrap i.e. keep the accessibility services enabled (or re-enable them)?
outputs with appium before opening the session
> adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false} services:{Service[label=Toaster, feedbackType[FEEDBACK_GENERIC], capabilities=0, eventTypes=TYPE_NOTIFICATION_STATE_CHANGED, notificationTimeout=0]}] [14.04.2015 16:09:29 C:\\]
during open session
> adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false, Exception occurred while dumping: java.lang.NullPointerException at com.android.server.accessibility.AccessibilityManagerService$Service.dump(AccessibilityManagerService.java:2216) at com.android.server.accessibility.AccessibilityManagerService.dump(AccessibilityManagerService.java:1510) at android.os.Binder.dump(Binder.java:300) at android.os.Binder.onTransact(Binder.java:266) at android.view.accessibility.IAccessibilityManager$Stub.onTransact(IAccessibilityManager.java:178) at android.os.Binder.execTransact(Binder.java:404) at dalvik.system.NativeStart.run(Native Method) [14.04.2015 16:09:47 C:\\]
after closing the session
> adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false} services:{}] [14.04.2015 16:10:00 C:\\]
outputs without appium
[14.04.2015 15:52:15 C:\\] > adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false} services:{Service[label=Toaster, feedbackType[FEEDBACK_GENERIC], capabilities=0, eventTypes=TYPE_NOTIFICATION_STATE_CHANGED, notificationTimeout=0]}] [14.04.2015 15:53:11 C:\\] > adb shell uiautomator dump --compressed UI hierchary dumped to: /storage/emulated/0/window_dump.xml [14.04.2015 15:53:35 C:\\] > adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false} services:{}] [14.04.2015 15:53:37 C:\\] > adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false} services:{Service[label=Toaster, feedbackType[FEEDBACK_GENERIC], capabilities=0, eventTypes=TYPE_NOTIFICATION_STATE_CHANGED, notificationTimeout=0]}] [14.04.2015 15:54:17 C:\\] > adb shell uiautomator dump UI hierchary dumped to: /storage/emulated/0/window_dump.xml [14.04.2015 15:54:27 C:\\] > adb shell dumpsys accessibility ACCESSIBILITY MANAGER (dumpsys accessibility) User state[attributes:{id=0, currentUser=true, accessibilityEnabled=true, touchExplorationEnabled=false, displayMagnificationEnabled=false} services:{}] [14.04.2015 15:54:31 C:\\]
If this a Android Platform thing (= UiAutomator bug or “feature”) any other ideas how this could be done?
PS. The same issue seems to be on Android 4.3 (no workarounds in these threads either) https://groups.google.com/forum/#!msg/adt-dev/-9cyoNlRTh4/vzN0QyUwTVoJ http://stackoverflow.com/questions/20341440/accessibilityservice-is-destroyed-when-uiautomator-is-run
Issue Analytics
- State:
- Created 8 years ago
- Comments:32 (11 by maintainers)
Top GitHub Comments
@sravanmedarapu Could you please provide a little bit more details about the held resources in terms of code? I am confused. We can run simultaneously several
AccessibilityService
s but running just oneUiAutomation
in the system causes allAccessibilityService
s to suspend.By the way, I found out that you can run
UiAutomation
along withAccessibilityService
s if you uses a special flag:If you obtain
UiAutomation
in this way, you’ll be able to run your tests without suspendingAccessibilityServices
.@imurchie