Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 { Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 { Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -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 Loading