笔记之Android Bluetooth Input 连接流程小记

1.      当用户在setting的bluetooth device list中选择了input设备后会触发起所有profile的connect操作,input设备在Setting中叫做HidProfile.java.

值得我们注意的是AndroidBluetoothInputDevice是通过getProfileProxy的方法取得的,这点并不同于HFPHSP.

2.      HidProfile通过调用BluetoothInputDevice的connect,如果是有效的设备则BluetoothInputDevice会直接调用bluetoothservice的connectInputDevice函式。

3.      其中bluetoothservice也就是简单的调用了BluetoothInputProfileHandler的connectInputDevice函式。connectInputDevice会向BluetoothDeviceProfileState发送CONNECT_HID_OUTGOING消息。

   Framework中包含了很多profilehandler, 这些Handler有个共同的特点是都包含了一个此profile的设备列表。

4.      BluetoothDeviceProfileState会切至OutgoingHidstate.此时OutgoingHid将deferMessageCONNECT_HID_OUTGOING消息并且交由BluetoothDeviceProfileState类的processCommand处理,在些它调用了BluetoothService的connectInputDeviceInternal.

5.      在些BluetoothService又去调用了mBluetoothInputProfileHandler的connectInputDeviceInternal,在其中其调用了jni方法BluetoothService的connectInputDeviceNative方法。此时的DBUS调用为异步调用。

6.      当Bluez在Input接口上连接成功后,会调用之前注册的onInputDeviceConnectionResult函数,(onInputDeviceConnectionResult是EventLoop中的函数)。

7.      onInputDeviceConnectionResult将解析bluez返回的path,其格式中包含了address,所以androide有替换”_”到”:”. 后呼叫了BluetoothService的handleInputDevicePropertyChange去通过mBluetoothInputProfileHandler更新其中设备的连接状态。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值