来自不受信任 UID 的调用

10

当我在Android Studio中运行UIAutomator时,有时会出现崩溃。

 W/ActivityManager: Crash of app com.example.testsample running instrumentation ComponentInfo{com.example.testsample.test/android.support.test.runner.AndroidJUnitRunner}
07-16 19:19:34.191 7834-7850/? W/Binder: Binder call failed.
java.lang.SecurityException: Calling from not trusted UID!
    at android.app.UiAutomationConnection.throwIfCalledByNotTrustedUidLocked(UiAutomationConnection.java:427)
    at android.app.UiAutomationConnection.shutdown(UiAutomationConnection.java:324)
    at android.app.IUiAutomationConnection$Stub.onTransact(IUiAutomationConnection.java:209)
    at android.os.Binder.execTransact(Binder.java:570)

但它并不总是显示。当它没有显示的时候,我可以成功运行程序。 有人能帮我吗? 谢谢。


我已经在另一台设备(华为Mate9)上尝试了相同的代码,并且它能够正常工作,从未出现过这个错误。因此,这可能只是特定设备(对我来说是MeiTu T8)导致的问题。 - Oscar Zhang
运行时出现此错误。测试未能成功运行。原因:'由于进程崩溃,导致仪器运行失败。'。请检查设备logcat以获取详细信息。 测试运行失败:由于进程崩溃,导致仪器运行失败。 - Oscar Zhang
相关 [SecurityException: 从不受信任的UID调用] (https://stackoverflow.com/questions/47498262/securityexception-calling-from-not-trusted-uid) - Richard Le Mesurier
1个回答

0
private void throwIfCalledByNotTrustedUidLocked() {
    final int callingUid = Binder.getCallingUid();
    if (callingUid != mOwningUid && mOwningUid != Process.SYSTEM_UID
            && callingUid != 0 /*root*/) {
        throw new SecurityException("Calling from not trusted UID!");
    }
}

这是导致错误的方法。也许uid与进程uid不同,或者该设备上的uid不是root。也许你可以在你的应用程序中添加一些打印语句来找出原因。


2
我在每个UIAutomator函数调用之前和之后添加日志。这个崩溃是随机出现的,没有特定的地方。 - Oscar Zhang

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接