Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5a03d91 authored by Angela Wang's avatar Angela Wang
Browse files

Ignore ASHA hisyncId grouping if the device supports CSIP

If a device is added as another device's sub device, it'll be removed
from the cached device list. This makes the device can't be correctly
grouped as a CSIP set when CSIP is connected.

We should ignore ASHA hisyncId grouping and leave it to be handled as a
member of CSIP set.

Bug: 288284097
Test: atest CachedBluetoothDeviceTest
Test: atest HearingAidDeviceManagerTest
Change-Id: Ibf10198521d3186186e87f96b13475185e51e856
(cherry picked from commit ec6e7c97)
parent 852e73de
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -1518,10 +1518,15 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
     *                      list.
     *                      list.
     */
     */
    public void switchMemberDeviceContent(CachedBluetoothDevice newMainDevice) {
    public void switchMemberDeviceContent(CachedBluetoothDevice newMainDevice) {
        // Backup from main device
        // Remove the sub device from mMemberDevices first to prevent hash mismatch problem due
        // to mDevice switch
        removeMemberDevice(newMainDevice);

        // Backup from current main device
        final BluetoothDevice tmpDevice = mDevice;
        final BluetoothDevice tmpDevice = mDevice;
        final short tmpRssi = mRssi;
        final short tmpRssi = mRssi;
        final boolean tmpJustDiscovered = mJustDiscovered;
        final boolean tmpJustDiscovered = mJustDiscovered;

        // Set main device from sub device
        // Set main device from sub device
        release();
        release();
        mDevice = newMainDevice.mDevice;
        mDevice = newMainDevice.mDevice;
@@ -1535,6 +1540,9 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        newMainDevice.mRssi = tmpRssi;
        newMainDevice.mRssi = tmpRssi;
        newMainDevice.mJustDiscovered = tmpJustDiscovered;
        newMainDevice.mJustDiscovered = tmpJustDiscovered;
        newMainDevice.fillData();
        newMainDevice.fillData();

        // Add the sub device back into mMemberDevices with correct hash
        addMemberDevice(newMainDevice);
    }
    }


    /**
    /**
+8 −0
Original line number Original line Diff line number Diff line
@@ -186,6 +186,14 @@ public class HearingAidDeviceManager {
            if (cachedDevice.getHiSyncId() != hiSyncId) {
            if (cachedDevice.getHiSyncId() != hiSyncId) {
                continue;
                continue;
            }
            }

            // The remote device supports CSIP, the other ear should be processed as a member
            // device. Ignore hiSyncId grouping from ASHA here.
            if (cachedDevice.getProfiles().stream().anyMatch(
                    profile -> profile instanceof CsipSetCoordinatorProfile)) {
                continue;
            }

            if (firstMatchedIndex == -1) {
            if (firstMatchedIndex == -1) {
                // Found the first one
                // Found the first one
                firstMatchedIndex = i;
                firstMatchedIndex = i;