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

Commit 0f756c61 authored by Angela Wang's avatar Angela Wang
Browse files

Fix ASHA devices in the same pair name not sync issue

The name of ASHA devices in the same pair is not sync while changing the name from Settings. We should make sure the modification is applied to both devices to avoid UI inconsistencies when main device of the pair is switched.

Bug: 336821241
Test: atest CachedBluetoothDeviceTest#setName_memberDeviceNameIsSet CachedBluetoothDeviceTest#setName_subDeviceNameIsSet HearingAidDeviceManagerTest#setSubDeviceIfNeeded_sameHiSyncId_setSubDevice
Change-Id: Ic016563935d1d180cf70f614e1edf469265366da
parent a189b7b3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -649,6 +649,9 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        for (CachedBluetoothDevice cbd : mMemberDevices) {
            cbd.setName(name);
        }
        if (mSubDevice != null) {
            mSubDevice.setName(name);
        }
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public class HearingAidDeviceManager {
            // device.
            if (hearingAidDevice != null) {
                hearingAidDevice.setSubDevice(newDevice);
                newDevice.setName(hearingAidDevice.getName());
                return true;
            }
        }
+24 −0
Original line number Diff line number Diff line
@@ -1702,6 +1702,30 @@ public class CachedBluetoothDeviceTest {
        verify(mDevice, never()).setAlias(any());
    }

    @Test
    public void setName_memberDeviceNameIsSet() {
        when(mDevice.getAlias()).thenReturn(DEVICE_NAME);
        when(mSubDevice.getAlias()).thenReturn(DEVICE_NAME);

        mCachedDevice.addMemberDevice(mSubCachedDevice);
        mCachedDevice.setName(DEVICE_ALIAS);

        verify(mDevice).setAlias(DEVICE_ALIAS);
        verify(mSubDevice).setAlias(DEVICE_ALIAS);
    }

    @Test
    public void setName_subDeviceNameIsSet() {
        when(mDevice.getAlias()).thenReturn(DEVICE_NAME);
        when(mSubDevice.getAlias()).thenReturn(DEVICE_NAME);

        mCachedDevice.setSubDevice(mSubCachedDevice);
        mCachedDevice.setName(DEVICE_ALIAS);

        verify(mDevice).setAlias(DEVICE_ALIAS);
        verify(mSubDevice).setAlias(DEVICE_ALIAS);
    }

    @Test
    public void getProfileConnectionState_nullProfile_returnDisconnected() {
        assertThat(mCachedDevice.getProfileConnectionState(null)).isEqualTo(
+1 −0
Original line number Diff line number Diff line
@@ -295,6 +295,7 @@ public class HearingAidDeviceManagerTest {
        mHearingAidDeviceManager.setSubDeviceIfNeeded(mCachedDevice2);

        assertThat(mCachedDevice1.getSubDevice()).isEqualTo(mCachedDevice2);
        verify(mDevice2).setAlias(DEVICE_ALIAS_1);
    }

    /**