Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +21 −0 Original line number Diff line number Diff line Loading @@ -1390,4 +1390,25 @@ public class BluetoothUtils { + " updatedMetadata = " + updated); assistant.modifySource(sink, sourceId, updated); } /** * Checks if the Bluetooth LE Audio Broadcast Assistant profile is available and at least one * device is currently connected to it. * * @param bluetoothManager The {@link LocalBluetoothManager} instance to query. * @return {@code true} if at least one device is connected to the LE Audio Broadcast Assistant * profile, {@code false} otherwise. */ public static boolean hasConnectedBroadcastAssistantDevice( @NonNull LocalBluetoothManager bluetoothManager) { LocalBluetoothLeBroadcastAssistant assistantProfile = bluetoothManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); // assistantProfile can be null if the profile is not supported or available. if (assistantProfile == null) { return false; } return !assistantProfile.getAllConnectedDevices().isEmpty(); } } packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -1737,6 +1737,36 @@ public class BluetoothUtilsTest { assertTrue(updatedChannels.get(2).isSelected()); } @Test public void hasConnectedBroadcastAssistantDevice_assistantProfileNull_returnFalse() { when(mProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn(null); boolean isAssistantConnected = BluetoothUtils.hasConnectedBroadcastAssistantDevice(mLocalBluetoothManager); assertThat(isAssistantConnected).isFalse(); } @Test public void hasConnectedBroadcastAssistantDevice_noConnectedDevice_returnFalse() { when(mAssistant.getAllConnectedDevices()).thenReturn(List.of()); boolean isAssistantConnected = BluetoothUtils.hasConnectedBroadcastAssistantDevice(mLocalBluetoothManager); assertThat(isAssistantConnected).isFalse(); } @Test public void hasConnectedBroadcastAssistantDevice_hasConnectedDevice_returnFalse() { when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mBluetoothDevice)); boolean isAssistantConnected = BluetoothUtils.hasConnectedBroadcastAssistantDevice(mLocalBluetoothManager); assertThat(isAssistantConnected).isTrue(); } private BluetoothLeBroadcastMetadata createMetadataWithChannels( BluetoothLeBroadcastChannel... channels) { BluetoothLeBroadcastMetadata mockMetadata = mock(BluetoothLeBroadcastMetadata.class); Loading packages/SystemUI/res/layout/media_output_dialog.xml +11 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,17 @@ android:layout_height="wrap_content" android:visibility="gone"> <com.google.android.material.button.MaterialButton android:id="@+id/audio_sharing" style="@style/MediaOutput.Dialog.QuickAccessButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp" android:text="@string/media_output_dialog_button_share_audio" android:visibility="gone" app:icon="@drawable/ic_bt_le_audio_sharing" /> <com.google.android.material.button.MaterialButton android:id="@+id/connect_device" app:icon="@drawable/ic_add" Loading packages/SystemUI/res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3525,6 +3525,10 @@ <string name="media_output_end_session_dialog_stop">Stop</string> <!-- Button text for stopping sharing [CHAR LIMIT=60] --> <string name="media_output_dialog_button_stop_sharing">Stop sharing</string> <!-- Button text when doing audio sharing. [CHAR LIMIT=60] --> <string name="media_output_dialog_button_sharing_audio">Sharing audio</string> <!-- Button text for triggering audio sharing. [CHAR LIMIT=60] --> <string name="media_output_dialog_button_share_audio">Share audio</string> <!-- Label for clip data when copying the build number off QS [CHAR LIMIT=NONE]--> <string name="build_number_clip_data_label">Build number</string> Loading packages/SystemUI/src/com/android/systemui/media/dialog/AudioSharingButtonState.kt 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.media.dialog import androidx.annotation.StringRes data class AudioSharingButtonState(@StringRes val resId: Int, val isActive: Boolean) Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +21 −0 Original line number Diff line number Diff line Loading @@ -1390,4 +1390,25 @@ public class BluetoothUtils { + " updatedMetadata = " + updated); assistant.modifySource(sink, sourceId, updated); } /** * Checks if the Bluetooth LE Audio Broadcast Assistant profile is available and at least one * device is currently connected to it. * * @param bluetoothManager The {@link LocalBluetoothManager} instance to query. * @return {@code true} if at least one device is connected to the LE Audio Broadcast Assistant * profile, {@code false} otherwise. */ public static boolean hasConnectedBroadcastAssistantDevice( @NonNull LocalBluetoothManager bluetoothManager) { LocalBluetoothLeBroadcastAssistant assistantProfile = bluetoothManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); // assistantProfile can be null if the profile is not supported or available. if (assistantProfile == null) { return false; } return !assistantProfile.getAllConnectedDevices().isEmpty(); } }
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -1737,6 +1737,36 @@ public class BluetoothUtilsTest { assertTrue(updatedChannels.get(2).isSelected()); } @Test public void hasConnectedBroadcastAssistantDevice_assistantProfileNull_returnFalse() { when(mProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn(null); boolean isAssistantConnected = BluetoothUtils.hasConnectedBroadcastAssistantDevice(mLocalBluetoothManager); assertThat(isAssistantConnected).isFalse(); } @Test public void hasConnectedBroadcastAssistantDevice_noConnectedDevice_returnFalse() { when(mAssistant.getAllConnectedDevices()).thenReturn(List.of()); boolean isAssistantConnected = BluetoothUtils.hasConnectedBroadcastAssistantDevice(mLocalBluetoothManager); assertThat(isAssistantConnected).isFalse(); } @Test public void hasConnectedBroadcastAssistantDevice_hasConnectedDevice_returnFalse() { when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mBluetoothDevice)); boolean isAssistantConnected = BluetoothUtils.hasConnectedBroadcastAssistantDevice(mLocalBluetoothManager); assertThat(isAssistantConnected).isTrue(); } private BluetoothLeBroadcastMetadata createMetadataWithChannels( BluetoothLeBroadcastChannel... channels) { BluetoothLeBroadcastMetadata mockMetadata = mock(BluetoothLeBroadcastMetadata.class); Loading
packages/SystemUI/res/layout/media_output_dialog.xml +11 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,17 @@ android:layout_height="wrap_content" android:visibility="gone"> <com.google.android.material.button.MaterialButton android:id="@+id/audio_sharing" style="@style/MediaOutput.Dialog.QuickAccessButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp" android:text="@string/media_output_dialog_button_share_audio" android:visibility="gone" app:icon="@drawable/ic_bt_le_audio_sharing" /> <com.google.android.material.button.MaterialButton android:id="@+id/connect_device" app:icon="@drawable/ic_add" Loading
packages/SystemUI/res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3525,6 +3525,10 @@ <string name="media_output_end_session_dialog_stop">Stop</string> <!-- Button text for stopping sharing [CHAR LIMIT=60] --> <string name="media_output_dialog_button_stop_sharing">Stop sharing</string> <!-- Button text when doing audio sharing. [CHAR LIMIT=60] --> <string name="media_output_dialog_button_sharing_audio">Sharing audio</string> <!-- Button text for triggering audio sharing. [CHAR LIMIT=60] --> <string name="media_output_dialog_button_share_audio">Share audio</string> <!-- Label for clip data when copying the build number off QS [CHAR LIMIT=NONE]--> <string name="build_number_clip_data_label">Build number</string> Loading
packages/SystemUI/src/com/android/systemui/media/dialog/AudioSharingButtonState.kt 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.media.dialog import androidx.annotation.StringRes data class AudioSharingButtonState(@StringRes val resId: Int, val isActive: Boolean)