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

Commit e4361810 authored by wengsu's avatar wengsu Committed by Weng Su
Browse files

Fix incorrect summary text for hearing aid during call.

Bug: 118206879
Test: make -j56 RunSettingsLibRoboTests
Change-Id: I333fe7d978f7dbb34d7b7c5bdd49c1eb6b0ee850
parent c96b8345
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -892,7 +892,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
                if (batteryLevelPercentageString != null) {
                    //device is in phone call
                    if (com.android.settingslib.Utils.isAudioModeOngoingCall(mContext)) {
                        if (mIsActiveDeviceHeadset) {
                        if (mIsActiveDeviceHearingAid || mIsActiveDeviceHeadset) {
                            stringRes = R.string.bluetooth_active_battery_level;
                        } else {
                            stringRes = R.string.bluetooth_battery_level;
@@ -908,7 +908,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
                } else {
                    //no battery information
                    if (com.android.settingslib.Utils.isAudioModeOngoingCall(mContext)) {
                        if (mIsActiveDeviceHeadset) {
                        if (mIsActiveDeviceHearingAid || mIsActiveDeviceHeadset) {
                            stringRes = R.string.bluetooth_active_no_battery_level;
                        }
                    } else {
+31 −0
Original line number Diff line number Diff line
@@ -233,6 +233,37 @@ public class CachedBluetoothDeviceTest {
        assertThat(mCachedDevice.getConnectionSummary()).isNull();
    }

    @Test
    public void getConnectionSummary_testHearingAidInCall_active() {
        // Arrange:
        //   1. Profile:       {HEARING_AID, Connected, Active}
        //   2. Audio Manager: In Call
        //   3. Battery Level: Unknown
        updateProfileStatus(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
        mCachedDevice.onActiveDeviceChanged(true, BluetoothProfile.HEARING_AID);
        mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);

        // Act & Assert:
        //   Get "Active" result without Battery Level.
        assertThat(mCachedDevice.getConnectionSummary()).isEqualTo("Active");
    }

    @Test
    public void getConnectionSummary_testHearingAidInCall_activeBattery10() {
        // Arrange:
        //   1. Profile:       {HEARING_AID, Connected, Active}
        //   2. Audio Manager: In Call
        //   3. Battery Level: 10
        updateProfileStatus(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
        mCachedDevice.onActiveDeviceChanged(true, BluetoothProfile.HEARING_AID);
        mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
        mBatteryLevel = 10;

        // Act & Assert:
        //   Get "Active, 10% battery" result with Battery Level 10.
        assertThat(mCachedDevice.getConnectionSummary()).isEqualTo("Active, 10% battery");
    }

    @Test
    public void getConnectionSummary_testMultipleProfilesActiveDevice() {
        // Test without battery level