Android Bluetooth Introduction
Agenda
● Android Bluetooth architecture
● Related source code
● Init Bluetooth
● Connect with other BT devices (dbus)
● RFCOMM
● OBEX (socket)
Android architecture
The diagram above offers a library-oriented
view of the Bluetooth stack.
Related source code
● Bluez 3.36 (user space and kernel)
/
mydroid/externel/bluez
/
mydroid/kernel/drivers/bluetooth
/
mydroid/kernel/net/bluetooth
● Android app framework (java & c++)
/
mydroid/frameworks/base/core/jni/android_bluetooth_*.cpp
/
mydroid/frameworks/base/core/java/android/bluetooth/*.java
/
mydroid/frameworks/base/services/java/com/android/server/ (SystemServer)
● Android UI application
/
mydroid/packages/apps/Phone/src/com/android/phone/ (Phone App)
/
mydroid/packages/apps/Settings/src/com/android/settings/bluetooth/ (Settings App)
Init Bluetooth
● /root/init.rc
mkdir /data/misc/hcid (store device info)
service dbus /system/bin/dbusdaemon
service hcid /system/bin/hcid (disabled)
service hfag /system/bin/sdptool add channel=
10 HFAG (handsfree, disabled, one shot)
service hsag /system/bin/sdptool add channel=
11 HSAG (headset, disabled, one shot)
● /root/init.trout.rc
service hciattach (disabled)
● system server
decice BT power On or Off from settings value
start related services
ddms: dalvik debug monitor I.
ddms: dalvik debug monitor II.