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.

4

3 回答 3

1

我在这方面取得了一些成功:

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

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

这里有更多关于 Configurator 的详细信息:

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

以下 GitHub 问题帮助我找到了这个:

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

于 2019-04-11T16:08:20.787 回答
1

dazza500的解决方案适用于Kotlin.

就我而言,我在用 Java 编写时在这里修改了我的:

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

 mDevice = UiDevice.getInstance(getInstrumentation());
于 2019-08-07T04:25:04.620 回答
0

这是一个老问题,但我想我会回答自己说它们确实不兼容。

于 2015-09-17T13:45:45.497 回答