Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +4 −7 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.os.Looper; import android.os.Message; import android.os.ParcelUuid; import android.os.SystemClock; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; Loading Loading @@ -1291,12 +1290,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> if (BluetoothUtils.hasConnectedBroadcastSource(this, mBluetoothManager)) { // Gets summary for the buds which are in the audio sharing. int groupId = BluetoothUtils.getGroupId(this); if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID && groupId == Settings.Secure.getInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothCsipSetCoordinator.GROUP_ID_INVALID)) { int primaryGroupId = BluetoothUtils.getPrimaryGroupIdForBroadcast( mContext.getContentResolver()); if ((primaryGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) ? (groupId == primaryGroupId) : isActiveDevice(BluetoothProfile.LE_AUDIO)) { // The buds are primary buds return getSummaryWithBatteryInfo( R.string.bluetooth_active_battery_level_untethered, Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +27 −9 Original line number Diff line number Diff line Loading @@ -1977,12 +1977,12 @@ public class CachedBluetoothDeviceTest { } @Test public void getConnectionSummary_isBroadcastPrimary_returnActive() { public void getConnectionSummary_isBroadcastPrimary_fallbackDevice_returnActive() { when(mBroadcast.isEnabled(any())).thenReturn(true); when(mCachedDevice.getDevice()).thenReturn(mDevice); Settings.Secure.putInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothUtils.getPrimaryGroupIdUriForBroadcast(), 1); List<Long> bisSyncState = new ArrayList<>(); Loading @@ -1992,12 +1992,30 @@ public class CachedBluetoothDeviceTest { sourceList.add(mLeBroadcastReceiveState); when(mAssistant.getAllSources(any())).thenReturn(sourceList); when(mCachedDevice.getGroupId()) .thenReturn( Settings.Secure.getInt( when(mCachedDevice.getGroupId()).thenReturn(1); assertThat(mCachedDevice.getConnectionSummary(false)) .isEqualTo(mContext.getString(R.string.bluetooth_active_no_battery_level)); } @Test public void getConnectionSummary_isBroadcastPrimary_activeDevice_returnActive() { when(mBroadcast.isEnabled(any())).thenReturn(true); when(mCachedDevice.getDevice()).thenReturn(mDevice); Settings.Secure.putInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothCsipSetCoordinator.GROUP_ID_INVALID)); BluetoothUtils.getPrimaryGroupIdUriForBroadcast(), BluetoothCsipSetCoordinator.GROUP_ID_INVALID); List<Long> bisSyncState = new ArrayList<>(); bisSyncState.add(1L); when(mLeBroadcastReceiveState.getBisSyncState()).thenReturn(bisSyncState); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); sourceList.add(mLeBroadcastReceiveState); when(mAssistant.getAllSources(any())).thenReturn(sourceList); when(mCachedDevice.getGroupId()).thenReturn(1); when(mCachedDevice.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(true); assertThat(mCachedDevice.getConnectionSummary(false)) .isEqualTo(mContext.getString(R.string.bluetooth_active_no_battery_level)); Loading @@ -2009,7 +2027,7 @@ public class CachedBluetoothDeviceTest { when(mCachedDevice.getDevice()).thenReturn(mDevice); Settings.Secure.putInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothUtils.getPrimaryGroupIdUriForBroadcast(), 1); List<Long> bisSyncState = new ArrayList<>(); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +4 −7 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.os.Looper; import android.os.Message; import android.os.ParcelUuid; import android.os.SystemClock; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; Loading Loading @@ -1291,12 +1290,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> if (BluetoothUtils.hasConnectedBroadcastSource(this, mBluetoothManager)) { // Gets summary for the buds which are in the audio sharing. int groupId = BluetoothUtils.getGroupId(this); if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID && groupId == Settings.Secure.getInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothCsipSetCoordinator.GROUP_ID_INVALID)) { int primaryGroupId = BluetoothUtils.getPrimaryGroupIdForBroadcast( mContext.getContentResolver()); if ((primaryGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) ? (groupId == primaryGroupId) : isActiveDevice(BluetoothProfile.LE_AUDIO)) { // The buds are primary buds return getSummaryWithBatteryInfo( R.string.bluetooth_active_battery_level_untethered, Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +27 −9 Original line number Diff line number Diff line Loading @@ -1977,12 +1977,12 @@ public class CachedBluetoothDeviceTest { } @Test public void getConnectionSummary_isBroadcastPrimary_returnActive() { public void getConnectionSummary_isBroadcastPrimary_fallbackDevice_returnActive() { when(mBroadcast.isEnabled(any())).thenReturn(true); when(mCachedDevice.getDevice()).thenReturn(mDevice); Settings.Secure.putInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothUtils.getPrimaryGroupIdUriForBroadcast(), 1); List<Long> bisSyncState = new ArrayList<>(); Loading @@ -1992,12 +1992,30 @@ public class CachedBluetoothDeviceTest { sourceList.add(mLeBroadcastReceiveState); when(mAssistant.getAllSources(any())).thenReturn(sourceList); when(mCachedDevice.getGroupId()) .thenReturn( Settings.Secure.getInt( when(mCachedDevice.getGroupId()).thenReturn(1); assertThat(mCachedDevice.getConnectionSummary(false)) .isEqualTo(mContext.getString(R.string.bluetooth_active_no_battery_level)); } @Test public void getConnectionSummary_isBroadcastPrimary_activeDevice_returnActive() { when(mBroadcast.isEnabled(any())).thenReturn(true); when(mCachedDevice.getDevice()).thenReturn(mDevice); Settings.Secure.putInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothCsipSetCoordinator.GROUP_ID_INVALID)); BluetoothUtils.getPrimaryGroupIdUriForBroadcast(), BluetoothCsipSetCoordinator.GROUP_ID_INVALID); List<Long> bisSyncState = new ArrayList<>(); bisSyncState.add(1L); when(mLeBroadcastReceiveState.getBisSyncState()).thenReturn(bisSyncState); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); sourceList.add(mLeBroadcastReceiveState); when(mAssistant.getAllSources(any())).thenReturn(sourceList); when(mCachedDevice.getGroupId()).thenReturn(1); when(mCachedDevice.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(true); assertThat(mCachedDevice.getConnectionSummary(false)) .isEqualTo(mContext.getString(R.string.bluetooth_active_no_battery_level)); Loading @@ -2009,7 +2027,7 @@ public class CachedBluetoothDeviceTest { when(mCachedDevice.getDevice()).thenReturn(mDevice); Settings.Secure.putInt( mContext.getContentResolver(), "bluetooth_le_broadcast_fallback_active_group_id", BluetoothUtils.getPrimaryGroupIdUriForBroadcast(), 1); List<Long> bisSyncState = new ArrayList<>(); Loading