Andriod 9: avc: denied error when we try to open Serial Port

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Andriod 9: avc: denied error when we try to open Serial Port

931 Views
kishorem
Contributor II

Hi Team,

We have successfully flashed Andriod 9 on imx6q based board from Technexion.

We have changed the permissions to serial port in order to access from Application layer.

<android_source>/device/fsl/imx6dq/edm1_imx6/ueventd.freescale.rc

 

 

/dev/ttymxc0 0777 system root

/dev/ttymxc1 0777 system root




When we try to access serial port we are getting below error :
Our andriod app is trying to access serial port and we have given following permission in

 

2022-10-21 15:43:43.720 1558-1558/? W/ServiceStartArg: type=1400 audit(0.0:6636): avc: denied { write } for name="ttymxc0" dev="tmpfs" ino=11426 scontext=u:r:untrusted_app:s0:c68,c256,c512,c768 tcontext=u:object_r:tty_device:s0 tclass=chr_file permissive=0

2022-10-21 15:43:43.735 1558-1590/? W/System.err: java.io.IOException: Cannot run program "/system/bin/su": error=2, No such file or directory

2022-10-21 15:43:43.736 1558-1590/? W/System.err: at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)

2022-10-21 15:43:43.736 1558-1590/? W/System.err: at java.lang.Runtime.exec(Runtime.java:695)

2022-10-21 15:43:43.736 1558-1590/? W/System.err: at java.lang.Runtime.exec(Runtime.java:525)

2022-10-21 15:43:43.736 1558-1590/? W/System.err: at java.lang.Runtime.exec(Runtime.java:422)

2022-10-21 15:43:43.737 1558-1590/? W/System.err: at android_serialport_api.SerialPort.<init>(SerialPort.java:210)

2022-10-21 15:43:43.737 1558-1590/? W/System.err: at tp.xmaihh.serialport.SerialHelper.open(SerialHelper.java:41)

2022-10-21 15:43:43.737 1558-1590/? W/System.err: at com.aczet.balanceapp.service.serial_comm_handler.SerialCommBase.initNative(SerialCommBase.java:37)

2022-10-21 15:43:43.737 1558-1590/? W/System.err: at com.aczet.balanceapp.service.serial_comm_handler.SerialCommHandler.startSerialComm(SerialCommHandler.java:104)

2022-10-21 15:43:43.738 1558-1590/? W/System.err: at com.aczet.balanceapp.service.core.BalanceService$ServiceHandler.handleMessage(BalanceService.java:86)

2022-10-21 15:43:43.738 1558-1590/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)

2022-10-21 15:43:43.738 1558-1590/? W/System.err: at android.os.Looper.loop(Looper.java:193)

2022-10-21 15:43:43.738 1558-1590/? W/System.err: at android.os.HandlerThread.run(HandlerThread.java:65)

2022-10-21 15:43:43.739 1558-1590/? W/System.err: Caused by: java.io.IOException: error=2, No such file or directory

2022-10-21 15:43:43.739 1558-1590/? W/System.err: at java.lang.UNIXProcess.forkAndExec(Native Method)

2022-10-21 15:43:43.740 1558-1590/? W/System.err: at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)

2022-10-21 15:43:43.740 1558-1590/? W/System.err: at java.lang.ProcessImpl.start(ProcessImpl.java:132)

2022-10-21 15:43:43.740 1558-1590/? W/System.err: at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

2022-10-21 15:43:43.741 1558-1590/? W/System.err: ... 11 more

2022-10-21 15:43:43.741 1558-1590/? W/System.err: java.lang.SecurityException

2022-10-21 15:43:43.742 1558-1590/? W/System.err: at android_serialport_api.SerialPort.<init>(SerialPort.java:220)

2022-10-21 15:43:43.742 1558-1590/? W/System.err: at tp.xmaihh.serialport.SerialHelper.open(SerialHelper.java:41)

2022-10-21 15:43:43.742 1558-1590/? W/System.err: at com.aczet.balanceapp.service.serial_comm_handler.SerialCommBase.initNative(SerialCommBase.java:37)

2022-10-21 15:43:43.743 1558-1590/? W/System.err: at com.aczet.balanceapp.service.serial_comm_handler.SerialCommHandler.startSerialComm(SerialCommHandler.java:104)

2022-10-21 15:43:43.743 1558-1590/? W/System.err: at com.aczet.balanceapp.service.core.BalanceService$ServiceHandler.handleMessage(BalanceService.java:86)

2022-10-21 15:43:43.743 1558-1590/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)

2022-10-21 15:43:43.743 1558-1590/? W/System.err: at android.os.Looper.loop(Looper.java:193)

2022-10-21 15:43:43.743 1558-1590/? W/System.err: at android.os.HandlerThread.run(HandlerThread.java:65)



--------- beginning of crash

2022-10-21 15:43:43.943 1558-1590/? E/AndroidRuntime: FATAL EXCEPTION: ServiceStartArguments

Process: com.aczet.balanceapp, PID: 1558

java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference

at tp.xmaihh.serialport.SerialHelper.send(SerialHelper.java:65)

at com.aczet.balanceapp.service.serial_comm_handler.SerialCommBase.sendData(SerialCommBase.java:49)

at com.aczet.balanceapp.service.serial_comm_handler.SerialCommHandler.sendBrightness(SerialCommHandler.java:341)

at com.aczet.balanceapp.service.core.BalanceService$ServiceHandler.handleMessage(BalanceService.java:154)

at android.os.Handler.dispatchMessage(Handler.java:106)

at android.os.Looper.loop(Looper.java:193)

at android.os.HandlerThread.run(HandlerThread.java:65)

Labels (2)
0 Kudos
Reply
1 Reply

897 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

The error is from the application itself has nothing to do with BSP;

Cannot run program "/system/bin/su": error=2, No such file or directory

Regards

0 Kudos
Reply