I am trying to run my own native executable. The code looks like this:
String[] command = {"/data/user/0/org.smowsoft.systeminformation.nativelib.test/files/smoproc"};
ProcessBuilder builder = new ProcessBuilder(command);
Process process = builder.start();
I am getting this error:
java.io.IOException: Cannot run program "/data/user/0/org.smowsoft.systeminformation.nativelib.test/files/smoproc": error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
at org.smowsoft.systeminformation.ExampleInstrumentedTest.testRun(ExampleInstrumentedTest.java:113)
... 29 trimmed
Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
at java.lang.ProcessImpl.start(ProcessImpl.java:141)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 31 more
I also tried to run the executable from native code like this:
char* lArgs[] = {0, 0};
lArgs[0] = new char[8];
strcpy(lArgs[0], "smoproc");
int result = execv("/data/user/0/org.smowsoft.systeminformation.nativelib.test/files/smoproc", lArgs);
But execv() returns -1 and errno is set to 13 (EACCESS).
The mode of the executable is set to 0777.
Wher I run dmesg from shell I can see that SELinux blocks the execution:
[15194.067480] type=1400 audit(1649841626.956:417509): avc: granted { execute } for comm="roidJUnitRunner" name="smoproc" dev="dm-5" ino=131258 scontext=u:r:untrusted_app:s0:c134,c256,c512,c768 tcontext=u:object_r:app_data_file:s0 tclass=file app=org.smowsoft.systeminformation.nativelib.test
[15194.070245] type=1400 audit(1649841626.956:417510): avc: denied { execute_no_trans } for comm="roidJUnitRunner" path="/data/data/org.smowsoft.systeminformation.nativelib.test/files/smoproc" dev="dm-5" ino=131258 scontext=u:r:untrusted_app:s0:c134,c256,c512,c768 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=0 app=org.smowsoft.systeminformation.nativelib.test
API level is 30. I tried it on multiple devices. Does this mean it is not possible to run native executables on API level 30 and higher?