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

Commit fa9d5b2e authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Gerrit Code Review
Browse files

Merge "Replacing getActiveDevice by btAdapter.getActiveDevices()"

parents 525001ee e9a0a821
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -173,8 +173,10 @@ public class A2dpProfile implements LocalBluetoothProfile {
    }

    public BluetoothDevice getActiveDevice() {
        if (mService == null) return null;
        return mService.getActiveDevice();
        if (mBluetoothAdapter == null) return null;
        final List<BluetoothDevice> activeDevices = mBluetoothAdapter
                .getActiveDevices(BluetoothProfile.A2DP);
        return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
    }

    @Override
+4 −2
Original line number Diff line number Diff line
@@ -132,10 +132,12 @@ public class HeadsetProfile implements LocalBluetoothProfile {
    }

    public BluetoothDevice getActiveDevice() {
        if (mService == null) {
        if (mBluetoothAdapter == null) {
            return null;
        }
        return mService.getActiveDevice();
        final List<BluetoothDevice> activeDevices = mBluetoothAdapter
                .getActiveDevices(BluetoothProfile.HEADSET);
        return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
    }

    public boolean isAudioOn() {
+4 −2
Original line number Diff line number Diff line
@@ -168,8 +168,10 @@ public class HearingAidProfile implements LocalBluetoothProfile {
    }

    public List<BluetoothDevice> getActiveDevices() {
        if (mService == null) return new ArrayList<>();
        return mService.getActiveDevices();
        if (mBluetoothAdapter == null) {
            return new ArrayList<>();
        }
        return mBluetoothAdapter.getActiveDevices(BluetoothProfile.HEARING_AID);
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -21,12 +21,12 @@ import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_ALL;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;

import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothCodecConfig;
import android.bluetooth.BluetoothCodecStatus;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
@@ -177,10 +177,10 @@ public class LeAudioProfile implements LocalBluetoothProfile {
    }

    public List<BluetoothDevice> getActiveDevices() {
        if (mService == null) {
        if (mBluetoothAdapter == null) {
            return new ArrayList<>();
        }
        return mService.getActiveDevices();
        return mBluetoothAdapter.getActiveDevices(BluetoothProfile.LE_AUDIO);
    }

    @Override
+4 −1
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ public class A2dpProfileTest {
    private BluetoothDevice mDevice;
    @Mock
    private BluetoothA2dp mBluetoothA2dp;
    @Mock
    private BluetoothAdapter mBluetoothAdapter;
    private BluetoothProfile.ServiceListener mServiceListener;

    private A2dpProfile mProfile;
@@ -72,7 +74,8 @@ public class A2dpProfileTest {
        mProfile = new A2dpProfile(mContext, mDeviceManager, mProfileManager);
        mServiceListener = mShadowBluetoothAdapter.getServiceListener();
        mServiceListener.onServiceConnected(BluetoothProfile.A2DP, mBluetoothA2dp);
        when(mBluetoothA2dp.getActiveDevice()).thenReturn(mDevice);
        when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
                .thenReturn(Arrays.asList(mDevice));
    }

    @Test