9

When I was running UIAutomator in Android Studio, a crash shows sometimes.

 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)

But it didn't shows every time. I can run successfully when this not showed. Can Anyone help me? Thanks.

Oscar Zhang
  • 153
  • 2
  • 7
  • I've tried the same code in another device(HUAWEI Mate9) and it works well. Never shows this error. So it may be only cause in specific device(for me it's MeiTu T8). – Oscar Zhang Jul 17 '18 at 03:29
  • This error shows when running. Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. Check device logcat for details Test running failed: Instrumentation run failed due to 'Process crashed.' – Oscar Zhang Jul 17 '18 at 12:53
  • related [SecurityException: Calling from not trusted UID](https://stackoverflow.com/questions/47498262/securityexception-calling-from-not-trusted-uid) – Richard Le Mesurier Apr 03 '19 at 16:27

1 Answers1

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!");
    }
}

This is the method which throws your error. Perhaps the uid is different than the process uid or the uid on that device is not root. Maybe you can add some prints in your app to find out.

John Doe
  • 1,058
  • 8
  • 30
  • 2
    I add logs before and after in every UIAutomator function calls. And this crash shows randomly. Not in a specific place. – Oscar Zhang Jul 17 '18 at 12:52