Skip to content

Commit b5f1131

Browse files
fly602mhduiy
authored andcommitted
fix: prevent disconnecting same audio device during connection
Fix a bug where connecting a Bluetooth audio device could cause it to be disconnected immediately due to incorrect conflict detection. The code was comparing devices without checking if they were the same device, leading to self-disconnection. Added address comparison in both connectProperties() and doConnect() methods to ensure that when checking for conflicting connected audio devices, the system doesn't mistakenly identify the current device as a conflict and disconnect it. This prevents the undesirable behavior where users see a disconnect notification followed by a connect notification when first pairing audio devices. Log: Fixed Bluetooth audio device connection stability Influence: 1. Test connecting Bluetooth audio devices for the first time 2. Verify no disconnection notifications appear during initial connection 3. Test multiple audio device connections and switching between them 4. Check that legitimate conflicts (different devices) still trigger proper disconnection 5. Verify connection stability with various Bluetooth audio profiles fix: 修复连接过程中误断开同一音频设备的问题 修复了连接蓝牙音频设备时可能因冲突检测错误导致立即断开的问题。原代码在比 较设备时未检查是否为同一设备,导致设备自断开。 在 connectProperties() 和 doConnect() 方法中都添加了地址比较,确保在检查 冲突的已连接音频设备时,系统不会错误地将当前设备识别为冲突并断开连接。这 解决了用户首次配对音频设备时看到先断开后连接通知的不良体验。 Log: 修复蓝牙音频设备连接稳定性 PMS: BUG-354841 Influence: 1. 测试首次连接蓝牙音频设备 2. 验证初始连接过程中不会出现断开通知 3. 测试多个音频设备连接及切换 4. 检查合法的设备冲突(不同设备)仍能正确触发断开 5. 验证各种蓝牙音频配置文件的连接稳定性 Change-Id: I67ef86f1e4840c020310d716e7048768fb629b12
1 parent db953a7 commit b5f1131

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

system/bluetooth1/device.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,11 @@ func (d *device) connectProperties() {
306306
d.connected = connected
307307
if strings.Contains(d.Icon, "audio") {
308308
dev := _bt.getConflictingConnectedDevice(d.Icon)
309-
if dev != nil && dev.connected && d.connected && d.Paired {
309+
if dev != nil &&
310+
dev.connected &&
311+
d.connected &&
312+
d.Paired &&
313+
dev.Address != d.Address {
310314
dev.Disconnect()
311315
}
312316
}
@@ -603,7 +607,7 @@ func (d *device) doConnect(hasNotify bool) error {
603607
}
604608
if strings.Contains(d.Icon, "audio") {
605609
dev := _bt.getConflictingConnectedDevice(d.Icon)
606-
if dev != nil && dev.connected {
610+
if dev != nil && dev.connected && dev.Address != d.Address {
607611
dev.Disconnect()
608612
}
609613
}

0 commit comments

Comments
 (0)