添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Tries to run the "/ data / local / tmp / iperf" program from the android application. unfortunately the program returns a "no permissions" error.

  Java.Lang.Process processa = Java.Lang.Runtime.GetRuntime().Exec("/data/local/tmp/iperf -v");
                Java.IO.BufferedReader inas = new Java.IO.BufferedReader(new Java.IO.InputStreamReader(processa.InputStream));
                using (var outputStreamReader = new StreamReader(processa.InputStream))
                    textMessage.Text = await outputStreamReader.ReadToEndAsync();

****Error: Java.IO.IOException: 'Cannot run program "/data/local/tmp/iperf": error=13, Permission denied'****

Running from adb shell works

adb shell /data/local/tmp/iperf -v
iperf version 2.0.5 (08 Jul 2010) pthreads

How to run such an Android application correctly?

I find solution, API29+ have more "feature": Removed execute permission for app home directory

The workaround is to rename the executable from "iperf" to "libiperf.so", and create "lib" directory, make "arm64-v8a" subdirectory and put "libiperf.so" there.

Then you can execute iperf

Java.Lang.Process processIperf = Java.Lang.Runtime.GetRuntime().Exec(ApplicationInfo.NativeLibraryDir + "/libiperf.so -v");  
Java.IO.BufferedReader bufferedReader = new Java.IO.BufferedReader(new Java.IO.InputStreamReader(processIperf.InputStream));  

For more details and discussions, please go to the internet. No decent solution, there are only more workarounds;)