Change permissions and ownership of tty port in Android software

I need to change the resolution of the / dev / tty * file as I am writing data on this port. I can change the resolution from the Windows command line by entering the adb shell as root.

But when I reboot the device, permissions are not saved. Instead, they are set to default values.

So, every time I need to run my application after reboot, I need to change permissions.

I tried to run adb commands from the application using the method Runtime.exec(), but this does not change anything, because the application does not have permission to change file permissions.

This is how I executed the command from the application (I tested it in the emulator in this case):

Process process =   Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chown root:root /dev/ttyS0 \n");
os.writeBytes("chmod 777 /dev/ttyS0 \n");
os.writeBytes("exit\n");
os.flush();
os.close();
process.waitFor();

su, su: uid 10044 not allowed to su - chown chmod Unable to chmod Operation Not permitted

, ?

!

!

+5
1

( Google) su UID . root shell su. su , su, UID.

, adb root, :

setprop service.adb.root 1
stop adbd
start adbd

, . , su .

, , tty:

Runtime.getRuntime().exec("su root chmod 777 /dev/ttyS0");

android . chown :. :

su root chown root.root /dev/ttyS0
+1

All Articles