来自不受信任的 UID 的呼叫

Osc*_*ang 10 java testing android android-uiautomator

当我在 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)
Run Code Online (Sandbox Code Playgroud)

但并不是每次都显示。当没有显示时我可以成功运行。谁能帮我?谢谢。

Joh*_*Doe 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!");
    }
}
Run Code Online (Sandbox Code Playgroud)

这是抛出错误的方法。也许uid与该过程不同uid或者uid该设备上的不同root。也许您可以在应用程序中添加一些打印来找出答案。

  • 我在每个 UIAutomator 函数调用之前和之后添加日志。而且这个崩溃是随机显示的。不是在特定的地方。 (2认同)