I'm working on a rooted Android 2.3. In my application, using jni mechanism I call a native (c/c++) function that needs root permissions to operate, thats why it always fails (even though my phone is rooted - because the specific process/app need to grant the root permission) .
I want to move that function to an external executable that will run on the linux by the command "sudo exec_name" that I will run from java ( Runtime.getRuntime().exec("sudo ...")
;)
So
1) How can I compile a native executable? (not a library as usual [.so])
2) After I have a stand alone executable, where in the system I have to put it and with what permissions?
To compile a native executable use include $(BUILD_EXECUTABLE)
instead of include $(BUILD_SHARED_LIBRARY)
. There is an example in NDK
called test-libstdc++
which show how to build the simplest native executable.
Then you need to put it in executable location like /data/local
and call chmod 777
in order to make it executable. After that you can run it via shell.
I want to move that function to an external executable that will run on the linux by the command "sudo exec_name" that I will run from java (Runtime.getRuntime().exec("sudo ...");)
In this case your workflow will look like this:
/system/bin
chmod 777
The first three points should be done only once.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.