Android BluetoothProfile之A2dp

来源:互联网 发布:python 3.6中文教程 编辑:程序博客网 时间:2024/04/30 11:13

BluetoothA2dp(Advanced AudioDistribution Profile ): 

(一).BluetoothA2dp的生成。

(以下根据android4.0原生代码分析):

基本关系:

 

 

       SystemServer中将BluetoothA2dpService new出来,并将其如到ServiceManager中。之后调用bluetooth.initAfterA2dpRegistration();----àmEventLoop.getProfileProxy();------à

mAdapter.getProfileProxy(mContext,mProfileServiceListener, BluetoothProfile.A2DP);

mAdapter.getProfileProxy(mContext,mProfileServiceListener,BluetoothProfile.INPUT_DEVICE);(这里顺便也将InputDevice的代理得到,但是InputDevice的服务在哪里加的呢?

BluetoothAdaptergetProfileProxy

可以看到这个方法中会得到一些代理的客户端,在原生代码中包含了下的:

BluetoothHeadsetBluetoothA2dpBluetoothInputDeviceBluetoothPanBluetoothHealth

 

BluetoothA2dp a2dp = newBluetoothA2dp(context, listener); (listener是从BluetoothEventLoop传进来的,主要是用于监听客户端与服务端建立连接和断开连接,如果断开连接会将BluetoothEventLoop中的mA2dp置为null)-------à

BluetoothA2dp:

在构造函数里面会得到加入到ServiceManager中的BluetoothA2dpService服务。后面的很多操作应该就是通过BluetoothA2dp找到BluetoothA2dpService操作。