Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 982757d4 authored by Angela Wang's avatar Angela Wang Committed by Android (Google) Code Review
Browse files

Merge "Integrate `getAudioInputControlPoints()` into SettingsLib" into main

parents 32465dd9 3b74adc9
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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;
+14 −0
Original line number Diff line number Diff line
@@ -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();
    }
}