1

I have an AccessibilityService (AS) running to programatically get information about what's currently displayed on the screen.

Now I want to set some UiAutomator test cases. However, if I have the AS running the UiAutomator gives the following error:

INSTRUMENTATION_RESULT: shortMsg=java.lang.SecurityException

INSTRUMENTATION_RESULT: longMsg=Permission Denial: getIntentSender() from pid=9700, uid=2000, (need uid=1000) is not allowed to send as package android

I've searched the web and I've found that lots of people have encountered this problem but no solution for it.

So is this a lack of compatibility issue or is there a way to solve it (or at least a work-around)?

Note: If you have other thoughts in how to read/access the contents of the screen without the AS I'm all ears (more eyes in this case...) but I've looked a lot for other solutions and this is the only one I got.

Thanks in advance.

If you need more information please tell me.

Inês
  • 882
  • 3
  • 13
  • 28

3 Answers3

2

I had some success with this:

    val flags = UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES
    Configurator.getInstance().uiAutomationFlags = flags

    mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())

There are some more details on Configurator here:

https://developer.android.com/reference/androidx/test/uiautomator/Configurator.html

The following GitHub issue helped me find this:

https://github.com/appium/appium/issues/4910

dazza5000
  • 7,075
  • 9
  • 44
  • 89
1

dazza500's solution works in Kotlin.

As in my case, I modified mine here as I am writing in Java:

 int flags = UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES;
 Configurator.getInstance().setUiAutomationFlags(flags);

 mDevice = UiDevice.getInstance(getInstrumentation());
0

This is an old question but I've figured I'd answer myself saying that they are indeed incompatible.

Inês
  • 882
  • 3
  • 13
  • 28