I using serialmanager to access serial port in android. below step:
1. add /dev/ttymxc1 0660 system system in fsl/wibo_8mq/ueventd.freescale.rc
2. add /dev/ttymxc1 u:object_r:serial_device:s0 in fsl/wibo_8mq/sepolicy/file_contexts
3. add allow system_app serial_device:chr_file { getattr open read write ioctl}; in fsl/wibo_8mq/sepolicy/system_app.te
4. move serialchat to package/apps dicectory.
5. add LOCAL_CERTIFICATE := platform in Android.mk of serialchat dicectory.
6. add android:sharedUserId="android.uid.system" in AndroidManifest.xml of serialchat directory.
But when i run serialchat than console show serialxxxjni can't not open /dev/ttymxc1. I guess not get permission. So i setenforce 0 in console than close and run the apk. The serialchat can access serialport. Have any one can suggestion ?
I guess the apk not get permission from selinux.
已解决! 转到解答。
Hii @chris4 ,
I am using the ttymxc3 for the serial port access but i found error like:
[ 442.754424] type=1400 audit(1708171167.858:60): avc: denied { write } for comm="m.example.ltswc" name="ttymxc3" dev="tmpfs" ino=10520 scontext=u:r:untrusted_app:s0:c129,c256,c512,cc
then i followed the steps like:
sudo chmod 777 /dev/ttymxc3
setenforce 0
But i want to give the selinux permission for the ttymxc3 so that no need to give the above commands every time.
so please help me how i can give the serial port permission in the android source code.
Thankyou in advance.