Bluetooth服务(以及蓝牙的A2DP服务)都是通过SystemServer启动(frameworks/base/services/java/com/android/server/SystemServer.java)
- Frameworks层(frameworks/base/core/java/android/server/BluetoothService.java,
function: enable())
- |
- | 给蓝牙状态机一个USER_TURN_ON的命令
- |
- jni层(frameworks/base/core/jni/android_server_BluetoothService.cpp,
function: enableNative())
- |
- HAL层(system/bluetooth/bluedroid/bluetooth.c,
function: set_bluetooth_power())
- |
- | write to rfkill
- |
- kernel层(net/rfkill/rfkill-gpio.c,或者vendor定制的rfkill driver,
function: rfkill_gpio_set_power())
rfkill_id在init.rc和bluetooth.c中已经把bluetooth写定为0,即:/sys/class/rfkill/rfkill0/state。匹配的机制是:
- /sys/class/rfkill/rfkill%d/type
- 读取内容,与bluetooth比较,如果相同,则返回id,并且给
- /sys/class/rfkill/rfkill%d/state写值(1或者0)以便开关电
这部分具体实现可以参看rfkill的driver代码
阅读(3788) | 评论(0) | 转发(0) |