Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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. Loading Loading @@ -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; Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/VolumeControlProfileTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } } Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/VolumeControlProfile.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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. Loading Loading @@ -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; Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/VolumeControlProfileTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } }