dimanche 24 juillet 2016

Android sysfs write permission denied

I would like to export some gpio pins using native code in my application. Trying to open() /sys/class/gpio/export with O_WRONLY was giving me permission denied. Using ls -l, I found:

--w------- root     root         4096 2000-01-01 01:18 export

Using chmod 202 in adb shell I made the file writeable from the app. How can I achieve this permanently ensuring the app can run every time?

Ideally, I would like to avoid any solutions outside the app as I would like the app to be installed and run successfully without any special user input changing permissions before.

Edit: I have tried using file.setWritable(true, false); from Java but it always returns false. I have also tried using system("su chmod 202 path/to/file"); which didn't work either.

Aucun commentaire:

Enregistrer un commentaire