The Android read the dev device file

Recent projects need to use the handle of the game in general mobile phone, so the need to write a driver, but don't know how to read from the dev device file.
Now the problem is not read data.
Process process = Runtime.getRuntime().exec("su");
After doing this can get a mobile phone on the root permissions, but still can not read dev file.
Also try to use NDK, but NDK don't know how to elevate permissions, and great advice, to the point of thinking.
Also in the shell USB folder of the Chmod 777, but is not. . . .

Started by Carina at February 04, 2016 - 7:21 PM

I write this:
            //Get root permission
String command = "chmod -R 777 /dev";
try {
Process process = Runtime.getRuntime().exec(new String[] {"su", "-c", command});
} catch(IOException e) {
} catch (InterruptedException e) {

In fact, as long as the entry into the -R, the /dev of the abnormal change permissions, added more rigorous, I used in the project, to ensure that no problem, however, it must be emphasized that, this change is a one-time, for example you plug in the U disk, execute the code, change the permissions, but and then pull the plug, again, this time under the dev/bus/usb file no root permission, please note

Posted by Harley at February 16, 2016 - 7:42 PM

It is able to read equipment, new problems arose, I read by reading the file mode equipment:
String fileName = "/dev/usb/input1-1.2";
String res="";
FileInputStream fin;
fin = new FileInputStream(fileName);
int length = fin.available();
byte[] buffer = new byte[length];;
But IOException has always been. How should solve..?

Posted by Carina at February 24, 2016 - 8:20 PM

I don't know, you have a look the log, if the exception is I gave the portions of your code by words, that our method has a problem, but I use a lot of times, I was engaged in USB, never over

Posted by Harley at December 16, 2016 - 4:01 PM

Yes, I tried this process, there should be no problem!! Try to get ROOT permission.!!

Posted by Sharon at December 24, 2016 - 4:17 PM

I want to read device is a rocker, tried JNI read data, and Java direct reading documents, mobile phone is root, the dev permissions are set to 777, no root to cat data in ADB, but is not read out the data..... Must be crazy. . .

Posted by Carina at December 25, 2016 - 4:40 PM

Now I inserted rocker, dev/input and dev/usb can read device, which one should be read?

Posted by Carina at January 05, 2017 - 5:13 PM

I use eclipse DDMS have a look rocker file your exactly in which directory, that can be displayed

Posted by Harley at January 11, 2017 - 6:11 PM

How to solve your IOException problem? Can share?

Posted by Isaac at January 13, 2017 - 7:09 PM