Android启动之bluetooth

         前一段时间我们分析了kernelbluetooth的初始化操作,从这一章起,晓东将会和大家一起正式进入到Androidbluetooth的分析。毫无疑问,我们依然需要知道在Android启动的时候,蓝牙究竟有做些什么。

         首先我们来回顾一下Android启动的一般流程,有人把它归结为4个步骤,分别为1init进程启动;2Native服务启动;3System serverAndroid服务启动;4Home启动。那么,我们来一个个看在这几个步骤中,都有哪些是和蓝牙有关的。

1init中的bluetooth

 

#首先是创建了两个文件夹和bluetooth相关
    mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
mkdir /data/misc/bluetooth 0770 system system
#新建了一个dbus的service,dbus是用于bluez和jni层交互的
#细心的同学已经发了,他是没有disabled的,所以,会直接启动哦
#不过dbus只是一个通路而已,我们暂时并不准备去详细地分析
service dbus /system/bin/dbus-daemon --system --nofork
    class main
    socket dbus stream 660 bluetooth bluetooth
    user bluetooth
    group bluetooth net_bt_admin
#新建了bluetoothd的service,这个就是bluez了
service bluetoothd /system/bin/bluetoothd -n
    class main
    socket bluetooth stream 660 bluetooth bluetooth
    socket dbus_bluetooth stream 660 bluetooth bluetooth
    # init.rc does not yet support applying capabilities, so run as root and
    # let bluetoothd drop uid to bluetooth with the right linux capabilities
    group bluetooth net_bt_admin misc
    disabled
#这里就是各个文件的权限配置了
    chmod 666 /dev/ttyS0
    chmod 666 /proc/bluetooth/sleep/proto
    chmod 666 /sys/class/rfkill/rfkill0/state
    chmod 666 /sys/class/rfkill/rfkill0/type
    chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
    chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
#一个hciattach的service,hciattach是bluetooth的一个工具,这里可以用来启动蓝牙
#涉及到一些vendor的信息后面就写成***了
service hciattach /system/bin/logwrapper /system/bin/hciattach -n /dev/ttyS0 ***
    class main
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot</
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值