Hello Loic
I have read this complete discussion and it helped me understand the complete Architecture. Thank you.
My question is : I am working on the USB based BT, do I need any extra vendor layer for communication ? Currently my BT service is crashing as soon as bluetooth-1-0 hal service trigger. It denies the access to hal_bluetooth_default (I added all the possible permissions to the hal_bluetooth_default domain)
[ 17.828358] type=1400 audit(12.169:11): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1 duplicate messages suppressed
[ 17.858695] type=1400 audit(17.819:12): avc: denied { read } for pid=330 comm=5573625365727669636520686F7374 name=“001” dev=“tmpfs” ino=8756 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=dir permissive=1
[ 17.880094] type=1400 audit(17.819:12): avc: denied { read } for pid=330 comm=5573625365727669636520686F7374 name=“001” dev=“tmpfs” ino=8756 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=dir permissive=1
[ 17.902092] type=1400 audit(17.819:13): avc: denied { open } for pid=330 comm=5573625365727669636520686F7374 path="/dev/bus/usb/001" dev=“tmpfs” ino=8756 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=dir permissive=1
[ 17.926354] type=1400 audit(17.819:13): avc: denied { open } for pid=330 comm=5573625365727669636520686F7374 path="/dev/bus/usb/001" dev=“tmpfs” ino=8756 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=dir permissive=1
[ 17.949527] type=1400 audit(17.819:14): avc: denied { read write } for pid=330 comm=5573625365727669636520686F7374 name=“002” dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 17.971937] type=1400 audit(17.819:14): avc: denied { read write } for pid=330 comm=5573625365727669636520686F7374 name=“002” dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 17.994302] type=1400 audit(17.819:15): avc: denied { open } for pid=330 comm=5573625365727669636520686F7374 path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 18.017544] type=1400 audit(17.819:15): avc: denied { open } for pid=330 comm=5573625365727669636520686F7374 path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 18.040821] type=1400 audit(17.819:16): avc: denied { ioctl } for pid=330 comm=5573625365727669636520686F7374 path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 ioctlcmd=5500 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permi1
[ 18.267920] init: computing context for service ‘webview_zygote32’
[ 18.295454] type=1400 audit(17.819:16): avc: denied { ioctl } for pid=330 comm=5573625365727669636520686F7374 path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 ioctlcmd=5500 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permi1
[ 18.305307] init: starting service ‘webview_zygote32’…
[ 18.308262] init: Created socket ‘/dev/socket/webview_zygote’, mode 660, user 1053, group 1000
[ 18.347202] type=1400 audit(18.289:17): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 19.181288] omap-iommu 55082000.mmu: 55082000.mmu: version 2.1
[ 19.758868] type=1400 audit(18.289:17): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 19.798789] type=1400 audit(19.749:18): avc: denied { create } for pid=185 comm=“bluetooth@1.0-s” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.835290] type=1400 audit(19.749:18): avc: denied { create } for pid=185 comm=“bluetooth@1.0-s” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.856699] type=1400 audit(19.749:19): avc: denied { bind } for pid=185 comm=“bluetooth@1.0-s” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.878996] type=1400 audit(19.749:19): avc: denied { bind } for pid=185 comm=“bluetooth@1.0-s” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.898453] type=1400 audit(19.749:20): avc: denied { write } for pid=185 comm=“bluetooth@1.0-s” path=“socket:[12705]” dev=“sockfs” ino=12705 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.921568] type=1400 audit(19.749:20): avc: denied { write } for pid=185 comm=“bluetooth@1.0-s” path=“socket:[12705]” dev=“sockfs” ino=12705 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.944408] type=1400 audit(19.749:21): avc: denied { read } for pid=185 comm=“bluetooth@1.0-s” path=“socket:[12705]” dev=“sockfs” ino=12705 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.975880] type=1400 audit(19.749:21): avc: denied { read } for pid=185 comm=“bluetooth@1.0-s” path=“socket:[12705]” dev=“sockfs” ino=12705 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 19.998473] type=1400 audit(19.799:22): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 21.334854] init: Service ‘bootanim’ (pid 320) exited with status 0
[ 21.380276] init: processing action (sys.boot_completed=1)
[ 21.398255] init: processing action (sys.boot_completed=1 && sys.logbootcomplete=1)
[ 21.415937] init: computing context for service ‘exec 4 (/system/bin/bootstat)’
[ 21.427436] init: starting service ‘exec 4 (/system/bin/bootstat)’…
[ 21.465598] init: SVC_EXEC pid 782 (uid 0 gid 0+0 context default) started; waiting…
[ 21.493311] init: Command ‘exec - root root – /system/bin/bootstat --record_boot_complete’ action=sys.boot_completed=1 && sys.logbootcomplete=1 (/system/etc/init/bootstat.rc:36) returned 0 took 64.9585ms.
[ 21.539155] init: Service ‘exec 4 (/system/bin/bootstat)’ (pid 782) exited with status 0 waiting took 0.123367 seconds
[ 21.555047] init: computing context for service ‘exec 5 (/system/bin/bootstat)’
[ 21.563394] init: starting service ‘exec 5 (/system/bin/bootstat)’…
[ 21.571515] init: SVC_EXEC pid 783 (uid 0 gid 0+0 context default) started; waiting…
[ 21.598249] init: Service ‘exec 5 (/system/bin/bootstat)’ (pid 783) exited with status 0 waiting took 0.043200 seconds
[ 21.612159] init: computing context for service ‘exec 6 (/system/bin/bootstat)’
[ 21.620091] init: starting service ‘exec 6 (/system/bin/bootstat)’…
[ 21.629816] init: SVC_EXEC pid 784 (uid 0 gid 0+0 context default) started; waiting…
[ 21.683909] init: Service ‘exec 6 (/system/bin/bootstat)’ (pid 784) exited with status 0 waiting took 0.071727 seconds
[ 21.702755] init: computing context for service ‘exec 7 (/system/bin/bootstat)’
[ 21.724467] init: starting service ‘exec 7 (/system/bin/bootstat)’…
[ 21.738621] init: SVC_EXEC pid 809 (uid 0 gid 0+0 context default) started; waiting…
[ 21.771242] init: Command ‘exec - root root – /system/bin/bootstat -l’ action=sys.boot_completed=1 && sys.logbootcomplete=1 (/system/etc/init/bootstat.rc:45) returned 0 took 68.4866ms.
[ 21.790646] type=1400 audit(19.799:22): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 21.814040] type=1400 audit(21.779:23): avc: denied { write } for pid=185 comm=“HwBinder:185_1” path=“socket:[12703]” dev=“sockfs” ino=12703 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 21.839089] init: Service ‘exec 7 (/system/bin/bootstat)’ (pid 809) exited with status 0 waiting took 0.136379 seconds
[ 21.850985] init: processing action (sys.boot_completed=1 && sys.wifitracing.started=0)
[ 21.912670] init: Command ‘mkdir /sys/kernel/debug/tracing/instances/wifi 711’ action=sys.boot_completed=1 && sys.wifitracing.started=0 (/system/etc/init/wifi-events.rc:22) returned 0 took 52.1291ms.
[ 23.021776] type=1400 audit(21.779:23): avc: denied { write } for pid=185 comm=“HwBinder:185_1” path=“socket:[12703]” dev=“sockfs” ino=12703 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 23.090702] init: Command ‘restorecon_recursive /sys/kernel/debug/tracing/instances/wifi’ action=sys.boot_completed=1 && sys.wifitracing.started=0 (/system/etc/init/wifi-events.rc:23) returned 0 took 1158.61ms.
[ 23.388182] type=1400 audit(23.009:24): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 25.060978] init: Untracked pid 823 exited with status 0
[ 25.208194] binder: undelivered transaction 13330
[ 26.288335] type=1400 audit(25.569:25): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 26.401752] type=1400 audit(26.279:26): avc: denied { read write } for pid=330 comm=“Binder:330_7” name=“002” dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.447975] type=1400 audit(26.279:26): avc: denied { read write } for pid=330 comm=“Binder:330_7” name=“002” dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.502113] type=1400 audit(26.279:27): avc: denied { open } for pid=330 comm=“Binder:330_7” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.541841] type=1400 audit(26.279:27): avc: denied { open } for pid=330 comm=“Binder:330_7” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.563657] type=1400 audit(26.279:28): avc: denied { getattr } for pid=330 comm=“Binder:330_7” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.585977] type=1400 audit(26.279:28): avc: denied { getattr } for pid=330 comm=“Binder:330_7” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:system_server:s0 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.608828] type=1400 audit(26.279:29): avc: denied { read write } for pid=330 comm=“Binder:330_7” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.632880] type=1400 audit(26.279:29): avc: denied { read write } for pid=330 comm=“Binder:330_7” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissive=1
[ 26.658316] type=1400 audit(26.309:30): avc: denied { create } for pid=185 comm=“HwBinder:185_1” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 26.683823] type=1400 audit(26.309:30): avc: denied { create } for pid=185 comm=“HwBinder:185_1” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 26.702493] type=1400 audit(26.309:31): avc: denied { ioctl } for pid=1062 comm=“car.usb.handler” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 ioctlcmd=5500 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissi1
[ 26.728001] type=1400 audit(26.309:31): avc: denied { ioctl } for pid=1062 comm=“car.usb.handler” path="/dev/bus/usb/001/002" dev=“tmpfs” ino=8758 ioctlcmd=5500 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:bluetoothtbd_device:s0 tclass=chr_file permissi1
[ 26.752172] type=1400 audit(26.309:32): avc: denied { bind } for pid=185 comm=“HwBinder:185_1” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 26.771756] type=1400 audit(26.309:32): avc: denied { bind } for pid=185 comm=“HwBinder:185_1” scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 26.790057] type=1400 audit(26.309:33): avc: denied { write } for pid=185 comm=“HwBinder:185_1” path=“socket:[15131]” dev=“sockfs” ino=15131 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 26.812700] type=1400 audit(26.309:33): avc: denied { write } for pid=185 comm=“HwBinder:185_1” path=“socket:[15131]” dev=“sockfs” ino=15131 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 26.834437] type=1400 audit(26.309:34): avc: denied { read } for pid=185 comm=“HwBinder:185_1” path=“socket:[15131]” dev=“sockfs” ino=15131 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 27.404095] type=1400 audit(26.309:34): avc: denied { read } for pid=185 comm=“HwBinder:185_1” path=“socket:[15131]” dev=“sockfs” ino=15131 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:r:hal_bluetooth_default:s0 tclass=socket permissive=1
[ 27.428341] type=1400 audit(27.399:35): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 28.163307] selinux: avc: denied { set } for property=sys.usb.ffs.mtp.ready pid=872 uid=10012 gid=10012 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:ffs_prop:s0 tclass=property_service
[ 28.163307]
[ 28.166501] type=1400 audit(27.399:35): avc: denied { accept } for pid=184 comm=“android.hardwar” lport=33452 scontext=u:r:hal_vehicle_default:s0 tcontext=u:r:hal_vehicle_default:s0 tclass=tcp_socket permissive=1
[ 28.166515] type=1400 audit(28.159:36): avc: denied { write } for pid=872 comm=“d.process.media” name=“property_service” dev=“tmpfs” ino=6273 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=1
[ 28.166667] type=1400 audit(28.159:36): avc: denied { write } for pid=872 comm=“d.process.media” name=“property_service” dev=“tmpfs” ino=6273 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=1
[ 28.166679] type=1400 audit(28.159:37): avc: denied { connectto } for pid=872 comm=“d.process.media” path="/dev/socket/property_service" scontext=u:r:priv_app:s0:c512,c768 tcontext=u:r:init:s0 tclass=unix_stream_socket permissive=1
[ 30.092617] init: Untracked pid 1296 exited with status 0
And here are logcat
I bt_hci : event_finish_startup
01-01 00:04:04.968 3498 3516 I bt_core_module: module_start_up Started module “hci_module”
01-01 00:04:04.968 3498 3533 I bt_osi_thread: run_thread: thread id 3533, thread name bt_workqueue started
01-01 00:04:04.969 3498 3533 I bt_btu : btu_task pending for preload complete event
01-01 00:04:04.969 3498 3533 I bt_btu_task: Bluetooth chip preload is complete
01-01 00:04:04.969 3498 3533 I bt_btu : btu_task received preload complete event
01-01 00:04:04.969 3498 3533 E bt_att : gatt_profile_db_init: gatt_if=1
01-01 00:04:04.970 3498 3534 I bt_osi_thread: run_thread: thread id 3534, thread name module_wrapper started
01-01 00:04:04.970 3498 3534 I bt_core_module: module_start_up Starting module “controller_module”
01-01 00:04:04.970 189 189 I bt_vendor: bt_vendor_op op 7
01-01 00:04:04.970 189 189 I bt_vendor: bt_vendor_op op 7 retval 0
01-01 00:04:04.970 189 189 E android.hardware.bluetooth-hci-hci_protocol: WriteSafely error writing to UART (Invalid argument)
01-01 00:04:06.971 3498 3519 E bt_hci : command_timed_out: 1 commands pending response
01-01 00:04:06.971 3498 3519 E bt_hci : command_timed_out: Waited 2000 ms for a response to opcode: 0xc03 matches timer
01-01 00:04:06.971 3498 3519 E bt_hci : command_timed_out: Size 3 Hex 03 0c 00
01-01 00:04:06.971 3498 3519 E bt_hci : command_timed_out: requesting a firmware dump.
01-01 00:04:06.971 189 189 E android.hardware.bluetooth-hci-hci_protocol: WriteSafely error writing to UART (Invalid argument)
01-01 00:04:06.971 3498 3519 E bt_hci : command_timed_out restarting the Bluetooth process.
I’m using Android O, with the current kernel release . Let me know if you can assist in above case?