蓝牙耳机Priority设置流程
来源:互联网 发布:sql update where 编辑:程序博客网 时间:2024/05/02 06:45
当蓝牙耳机配对成功后,会发送一个BONDING_STATE_CHANGE的消息,在BondStateMachine状态机里会对这个消息进行处理,调用setProfilePriorty(dev)函数对当前的耳机进行优先级的设置,
把以前的设置优先级顺序Hid、A2DP、Headset改为Headset、A2DP、Hid,请看这个函数修改后的具体code:
private void setProfilePriorty(BluetoothDevice device){
HidService hidService = HidService.getHidService();
A2dpService a2dpService = A2dpService.getA2dpService();
HeadsetService headsetService = HeadsetService.getHeadsetService();
if ((headsetService != null) &&
(headsetService.getPriority(device)== BluetoothProfile.PRIORITY_UNDEFINED)){
headsetService.setPriority(device,BluetoothProfile.PRIORITY_ON);
}
if ((a2dpService != null) &&
(a2dpService.getPriority(device) ==BluetoothProfile.PRIORITY_UNDEFINED)){
a2dpService.setPriority(device,BluetoothProfile.PRIORITY_ON);
}
if((hidService != null) &&
(hidService.getPriority(device) ==BluetoothProfile.PRIORITY_UNDEFINED)){
hidService.setPriority(device,BluetoothProfile.PRIORITY_ON);
}
}
会把当前耳机的Headset Profile 和A2DP Profile的优先级设置为PRIORITY_ON。
当蓝牙耳机连接成功时,processProfileStateChanged函数会调用 setProfileAutoConnectionPriority(device,profileId)函数设置优先级,看修改后这个函数的具体code:
void setProfileAutoConnectionPriority(BluetoothDevice device, int profileId){
HeadsetService hsService = HeadsetService.getHeadsetService();
A2dpService a2dpService =A2dpService.getA2dpService();
if ((hsService != null) &&
(BluetoothProfile.PRIORITY_AUTO_CONNECT !=hsService.getPriority(device))){
adjustOtherHeadsetPriorities(hsService,device);
hsService.setPriority(device,BluetoothProfile.PRIORITY_AUTO_CONNECT);
}
if ((a2dpService != null)&&
(BluetoothProfile.PRIORITY_AUTO_CONNECT != a2dpService.getPriority(device))){
adjustOtherSinkPriorities(a2dpService, device);
a2dpService.setPriority(device,BluetoothProfile.PRIORITY_AUTO_CONNECT);
}
}
会把当前耳机的Headset和A2DP的Profile优先级都设置为PRIORITY_AUTO_CONNECT,同时会把其他的耳机设备的优先级设为PRIORITY_ON,保证耳机自动连接优先级的设备只有一个。
蓝牙耳机自动连接过程:
当蓝牙打开时,如果有配对的蓝牙耳机存在,就会根据它的优先级,判断是否进行自动连接。如果优先级为PRIORITY_AUTO_CONNECT,该耳机就会自动进行连接。
- 蓝牙耳机Priority设置流程
- 蓝牙耳机简单的流程分析
- 蓝牙耳机
- 蓝牙耳机
- 蓝牙耳机
- 蓝牙耳机
- Android4.4蓝牙耳机HFP流程分析-1
- Android4.4蓝牙耳机HFP流程分析-2
- Android4.4蓝牙耳机HFP流程分析-3
- 蓝牙耳机按键在Android侧的处理流程
- Android4.4蓝牙耳机HFP流程分析-3
- 音频输入在有线耳机和蓝牙耳机直接切换时候mediaplayer的时间戳流程
- 使用蓝牙耳机
- 蓝牙耳机复位
- 连接蓝牙耳机过程
- 蓝牙耳机录音
- windows10连接蓝牙耳机
- iOS 蓝牙耳机切换
- android图片选择
- 几天不见来报到
- Flash的网页MP3录音控件
- Access denied for user ‘root’@’127.0.0.1’(using password:YES)
- mysq 条件分组统计_分组统计每个人的bug权值
- 蓝牙耳机Priority设置流程
- touchslide在android混合开发中的兼容问题
- TypeScript 优秀开源项目大合集
- 算法-斐波那契和变种的学习
- 【网络开发】winsock组播
- Go 函数式编程(闭包)
- javaScript扩展map方法
- 调用相机,相册。显示
- Jquery 选择器