I'm developing an application that is not intended to be released as a standard app. It'll be run on a single rooted device.
I require the ability to write to a file in the /sys/ directory. The file in question is owned by root and has -rw-rw-rw- permissions.
I am aware that there may be restrictions on the VM my code runs within that prohibit writing to this area of the file system, but I have observed another application apparently do this.
Is this possible? How might it be achieved? It doesn't matter if the phone needs to be rooted (the dev one I'm using is).
I've looked into simply using a FileWriter to write to the file, causing the following error on .flush()
:
java.io.IOException: Invalid argument
at org.apache.harmony.luni.platform.OSFileSystem.writeImpl(Native Method)
I've also tried executing a shell command from Java, both with and without "su". Which returned "request rejected" and "Permission Denied" respectively.
Process process = Runtime.getRuntime().exec("echo 'hello' > /sys/file");
Lastly I've tried using the NDK and JNI in case C some how magically managed to write to this file. When attempting to fflush
to this file I receive an EOF (meaning an error has occured).
All suggestions greatly welcome!