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

Commit 9c8c89f7 authored by Weng Su's avatar Weng Su Committed by Android (Google) Code Review
Browse files

Merge "Fix incorrect summary text for hearing aid during call."

parents 1a5e9f0d e4361810
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