2

I'm using the Video For Linux 2 API from my Android app's native library to talk to the Qualcomm FM radio chipset in my rooted Xperia E C1504, and I need to run my native library's code with root privileges in order to access /dev/radio0 with write permission before I can begin issuing (successful) ioctl.h commands. Specifically, I'm fairly sure I need the fcntl.h function call:

int device_fd = open("/dev/radio0", O_RDWR);

to not throw a 'permission denied' error. I know how to issue shell commands as SU, but how can I obtain root privileges for the entire scope of my native library's execution? This post suggests that installing my app in the /system/app directory should grant the permissions I need, but I tried it and still receive errno 13 (permission denied) when I try to open the target device in read/write mode.

Community
  • 1
  • 1
CCJ
  • 1,619
  • 26
  • 41
  • I've found two possible solutions so far: one is to use RootTools (https://github.com/Stericson/RootTools) to execute Java code with root privs (https://github.com/Stericson/RootTools/wiki/Java-as-root) and rework my app such that it issues all native calls through Java. The second would be to compile my native code into an Android native executable (http://stackoverflow.com/questions/9460251/how-do-i-build-a-native-command-line-executable-to-run-on-android) instead of the usual shared library and have my app launch it via an SU shell. I'll update when I've had a chance to try these ideas – CCJ Jan 29 '14 at 19:25
  • 2
    I implemented the Android executable option from my comment above and, after statically linking in stlport and copying the executable to /data/local/tmp of my rooted Xperia E, I was able to launch it using libsuperuser's Shell.SU.run() function. Can't quite tell if I have the necessary privs yet as I am getting errno 16 (file not found) for /dev/radio0 which I think can mean the character device is locked for use by another process... I'll update later with more – CCJ Feb 20 '14 at 00:05
  • Would be nice to get an update on this! – Fabian Knapp May 31 '16 at 20:57

0 Answers0