I am trying to package and execute native ARM binaries from within a Java Android App for Version 4.0 (API Level 15).
The packaging works just fine, adding the shell scripts and binaries to the assets folder of the project (using Android Studio), they will be deployed with the APK.
I then follow these solutions to copy the assets to the filesystem. Here is the first problem, i seem to only be able to write to getFilesDir()
but not e.g. to /data/local/tmp/. Very well, so i copy the files to the application data dir (resolves to something like /data/data/com.myapp/files/. Along this process, i also set the mode of the files to be executable.
Then i try to execute the binaries via Runtime.getRuntime().exec()
which seems to work for shellscripts but not binaries. I can use this to copy the binaries to my prefered destination via
cat /data/data/com.myapp/files/binary > /data/local/tmp/binary
Note: cp wont work, Permission denied. Chmod 777 works again. Execution does not work, Permission denied. I assume it is related to how the paths are mounted.
The whole process works when performing it via adb. I can see the app has a different user id than adb, so it might be related to kernel limitations? I am requesting WRITE_EXTERNAL_STORAGE.
Reading this also implies that /data/local/tmp/ should be the prefered destination.
The question now is: (how) can i elevate the rights of my application to perform the same operations as done via adb.
The phone is not rooted.