I need to make android application that run iperf3 library, so i have compiled "iperf3" using android-ndk-r20 with changes made in
iperf_api.c
char buf[] = "/tmp/iperf3.XXXXXX";
I've replaced with char buf[] = "/data/local/tmp/iperf3.XXXXXX";
, figured it out how to package it with my android application and run. But I don't know how to run it without "su" (root) permissions.
Well working code:
ArrayList<String> commandLine = new ArrayList<String>();
commandLine.add("su");
commandLine.add("-c");
commandLine.add(getApplicationContext().getApplicationInfo().nativeLibraryDir+"/libiperf3.so -c speedtest.hostkey.ru -t 10 -i 5 -P 3 -d");
Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0]));
It works well with "su", but I need to made it work without root. When I try same code but with "su" replaced by "sh" I get this error:
iperf3: error - unable to create a new stream: Permission denied
I don't know how to made it work, there is some applications that are using iperf3 in Google Play Store without root permissions, so it is possible. What I'm doing wrong?