Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +10 −5 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import android.bluetooth.BluetoothLeBroadcastReceiveState; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothStatusCodes; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; Loading Loading @@ -835,9 +836,9 @@ public class BluetoothUtils { /** Get primary device group id in broadcast. */ @WorkerThread public static int getPrimaryGroupIdForBroadcast(@NonNull Context context) { public static int getPrimaryGroupIdForBroadcast(@NonNull ContentResolver contentResolver) { return Settings.Secure.getInt( context.getContentResolver(), contentResolver, getPrimaryGroupIdUriForBroadcast(), BluetoothCsipSetCoordinator.GROUP_ID_INVALID); } Loading @@ -846,9 +847,13 @@ public class BluetoothUtils { @Nullable @WorkerThread public static CachedBluetoothDevice getSecondaryDeviceForBroadcast( @NonNull Context context, @Nullable LocalBluetoothManager localBtManager) { @NonNull ContentResolver contentResolver, @Nullable LocalBluetoothManager localBtManager) { if (localBtManager == null) return null; int primaryGroupId = getPrimaryGroupIdForBroadcast(context); LocalBluetoothLeBroadcast broadcast = localBtManager.getProfileManager().getLeAudioBroadcastProfile(); if (!broadcast.isEnabled(null)) return null; int primaryGroupId = getPrimaryGroupIdForBroadcast(contentResolver); if (primaryGroupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) return null; LocalBluetoothLeBroadcastAssistant assistant = localBtManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -589,7 +589,8 @@ public class BluetoothUtilsTest { @Test public void getSecondaryDeviceForBroadcast_errorState_returnNull() { assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext, mLocalBluetoothManager)) assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext.getContentResolver(), mLocalBluetoothManager)) .isNull(); } Loading @@ -608,7 +609,8 @@ public class BluetoothUtilsTest { when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(state)); when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mBluetoothDevice)); assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext, mLocalBluetoothManager)) assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext.getContentResolver(), mLocalBluetoothManager)) .isNull(); } Loading Loading @@ -637,7 +639,8 @@ public class BluetoothUtilsTest { when(mAssistant.getAllConnectedDevices()) .thenReturn(ImmutableList.of(mBluetoothDevice, bluetoothDevice)); assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext, mLocalBluetoothManager)) assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext.getContentResolver(), mLocalBluetoothManager)) .isEqualTo(mCachedBluetoothDevice); } } Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +10 −5 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import android.bluetooth.BluetoothLeBroadcastReceiveState; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothStatusCodes; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; Loading Loading @@ -835,9 +836,9 @@ public class BluetoothUtils { /** Get primary device group id in broadcast. */ @WorkerThread public static int getPrimaryGroupIdForBroadcast(@NonNull Context context) { public static int getPrimaryGroupIdForBroadcast(@NonNull ContentResolver contentResolver) { return Settings.Secure.getInt( context.getContentResolver(), contentResolver, getPrimaryGroupIdUriForBroadcast(), BluetoothCsipSetCoordinator.GROUP_ID_INVALID); } Loading @@ -846,9 +847,13 @@ public class BluetoothUtils { @Nullable @WorkerThread public static CachedBluetoothDevice getSecondaryDeviceForBroadcast( @NonNull Context context, @Nullable LocalBluetoothManager localBtManager) { @NonNull ContentResolver contentResolver, @Nullable LocalBluetoothManager localBtManager) { if (localBtManager == null) return null; int primaryGroupId = getPrimaryGroupIdForBroadcast(context); LocalBluetoothLeBroadcast broadcast = localBtManager.getProfileManager().getLeAudioBroadcastProfile(); if (!broadcast.isEnabled(null)) return null; int primaryGroupId = getPrimaryGroupIdForBroadcast(contentResolver); if (primaryGroupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) return null; LocalBluetoothLeBroadcastAssistant assistant = localBtManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -589,7 +589,8 @@ public class BluetoothUtilsTest { @Test public void getSecondaryDeviceForBroadcast_errorState_returnNull() { assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext, mLocalBluetoothManager)) assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext.getContentResolver(), mLocalBluetoothManager)) .isNull(); } Loading @@ -608,7 +609,8 @@ public class BluetoothUtilsTest { when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(state)); when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mBluetoothDevice)); assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext, mLocalBluetoothManager)) assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext.getContentResolver(), mLocalBluetoothManager)) .isNull(); } Loading Loading @@ -637,7 +639,8 @@ public class BluetoothUtilsTest { when(mAssistant.getAllConnectedDevices()) .thenReturn(ImmutableList.of(mBluetoothDevice, bluetoothDevice)); assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext, mLocalBluetoothManager)) assertThat(BluetoothUtils.getSecondaryDeviceForBroadcast(mContext.getContentResolver(), mLocalBluetoothManager)) .isEqualTo(mCachedBluetoothDevice); } }