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

Commit 1f24f521 authored by timhypeng's avatar timhypeng Committed by Hansong Zhang
Browse files

Add isConnectedHearingAidDevice function to check if it supports Hearing Aid profile

Bug: 116317072
Bug: 116044083
Bug: 79553082
Test: make -j50 RunSettingsLibRoboTests
Change-Id: I2950f63c4a95d692b77cfffeacc9d1d319243e0d
Merged-In: I2950f63c4a95d692b77cfffeacc9d1d319243e0d
(cherry picked from commit c509a655)
parent df0cefab
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1200,4 +1200,12 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
        return mProfileManager.getHeadsetProfile().getConnectionStatus(mDevice) ==
                BluetoothProfile.STATE_CONNECTED;
    }

    /**
     * @return {@code true} if {@code cachedBluetoothDevice} is Hearing Aid device
     */
    public boolean isConnectedHearingAidDevice() {
        return mProfileManager.getHearingAidProfile().getConnectionStatus(mDevice) ==
                BluetoothProfile.STATE_CONNECTED;
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -572,4 +572,22 @@ public class CachedBluetoothDeviceTest {

        assertThat(mCachedDevice.isHfpDevice()).isFalse();
    }

    @Test
    public void isConnectedHearingAidDevice_connected_returnTrue() {
        when(mProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
        when(mHearingAidProfile.getConnectionStatus(mDevice)).
                thenReturn(BluetoothProfile.STATE_CONNECTED);

        assertThat(mCachedDevice.isConnectedHearingAidDevice()).isTrue();
    }

    @Test
    public void isConnectedHearingAidDevice_disconnected_returnFalse() {
        when(mProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
        when(mHearingAidProfile.getConnectionStatus(mDevice)).
                thenReturn(BluetoothProfile.STATE_DISCONNECTED);

        assertThat(mCachedDevice.isConnectedHearingAidDevice()).isFalse();
    }
}