diff options
author | 2024-11-13 06:46:18 +0000 | |
---|---|---|
committer | 2024-11-30 03:22:01 +0000 | |
commit | 3b74adc96aa256207f961dcb3843764e2741c67b (patch) | |
tree | 444b56973bb9d152f7ecef848861472951287e29 | |
parent | 1039d29d3700f85c37b9b4ae360f873011ed50dd (diff) |
Integrate `getAudioInputControlPoints()` into SettingsLib
Add this API into VolumeControlProfile to get the AICS control points of
the remote device.
Flag: com.android.settingslib.flags.hearing_devices_ambient_volume_control
Bug: 357878944
Test: atest VolumeControlProfileTest
Change-Id: I0020c5babd5f176ad2f3db37e1237c5b8d3b5f32
2 files changed, 33 insertions, 0 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java index ab7a3db4b3bb..d85b92f0216b 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java @@ -21,6 +21,7 @@ import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; import android.annotation.CallbackExecutor; import android.annotation.IntRange; +import android.bluetooth.AudioInputControl; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; @@ -34,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.Executor; @@ -168,6 +170,7 @@ public class VolumeControlProfile implements LocalBluetoothProfile { } mService.setVolumeOffset(device, volumeOffset); } + /** * Provides information about the possibility to set volume offset on the remote device. If the * remote device supports Volume Offset Control Service, it is automatically connected. @@ -210,6 +213,22 @@ public class VolumeControlProfile implements LocalBluetoothProfile { mService.setDeviceVolume(device, volume, isGroupOp); } + /** + * Returns a list of {@link AudioInputControl} objects associated with a Bluetooth device. + * + * @param device The remote Bluetooth device. + * @return A list of {@link AudioInputControl} objects, or an empty list if no AICS instances + * are found or if an error occurs. + * @hide + */ + public @NonNull List<AudioInputControl> getAudioInputControlServices( + @NonNull BluetoothDevice device) { + if (mService == null) { + return Collections.emptyList(); + } + return mService.getAudioInputControlServices(device); + } + @Override public boolean accessProfileEnabled() { return false; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/VolumeControlProfileTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/VolumeControlProfileTest.java index 9c518de18582..bd67394dcc62 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/VolumeControlProfileTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/VolumeControlProfileTest.java @@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.bluetooth.AudioInputControl; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothProfile; @@ -45,6 +46,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.Executor; @@ -248,4 +250,16 @@ public class VolumeControlProfileTest { verify(mService).isVolumeOffsetAvailable(mBluetoothDevice); assertThat(available).isFalse(); } + + @Test + public void getAudioInputControlServices_verifyIsCalledAndReturnNonNullList() { + mServiceListener.onServiceConnected(BluetoothProfile.VOLUME_CONTROL, mService); + when(mService.getAudioInputControlServices(mBluetoothDevice)).thenReturn(new ArrayList<>()); + + final List<AudioInputControl> controls = mProfile.getAudioInputControlServices( + mBluetoothDevice); + + verify(mService).getAudioInputControlServices(mBluetoothDevice); + assertThat(controls).isNotNull(); + } } |