summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java11
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java36
2 files changed, 31 insertions, 16 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 92da2be60d1e..8845d2ee5369 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -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;
@@ -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,
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
index 0d814947527c..70cb2ef016ec 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
@@ -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<>();
@@ -1992,12 +1992,30 @@ public class CachedBluetoothDeviceTest {
sourceList.add(mLeBroadcastReceiveState);
when(mAssistant.getAllSources(any())).thenReturn(sourceList);
- when(mCachedDevice.getGroupId())
- .thenReturn(
- Settings.Secure.getInt(
- mContext.getContentResolver(),
- "bluetooth_le_broadcast_fallback_active_group_id",
- BluetoothCsipSetCoordinator.GROUP_ID_INVALID));
+ 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(),
+ 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));
@@ -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<>();