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

Commit cff45b1f authored by Etienne Ruffieux's avatar Etienne Ruffieux
Browse files

Replacing getActiveDevice by btAdapter.getActiveDevices()

BluetoothProfile.getActiveDevice() is hidden, packages
should call BluetoothAdapter.getActiveDevices(profile)
instead.

Tag: #feature
Bug: 200202780
Test: build
Change-Id: Iba61897e26ca3f36498593fb10d6c5de4b3e0d8c
parent 49945475
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.util.Log;
import com.android.internal.annotations.GuardedBy;

import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

@@ -503,7 +504,12 @@ public class BtHelper {
        // Discard timeout message
        mDeviceBroker.handleCancelFailureToConnectToBtHeadsetService();
        mBluetoothHeadset = headset;
        setBtScoActiveDevice(headset != null ? headset.getActiveDevice() : null);
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        List<BluetoothDevice> activeDevices = Collections.emptyList();
        if (adapter != null) {
            activeDevices = adapter.getActiveDevices(BluetoothProfile.HEADSET);
        }
        setBtScoActiveDevice((activeDevices.size() > 0) ? activeDevices.get(0) : null);
        // Refresh SCO audio state
        checkScoAudioState();
        if (mScoAudioState != SCO_STATE_ACTIVATE_REQ
+4 −4
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.util.SparseIntArray;
import com.android.internal.R;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -448,15 +447,16 @@ class BluetoothRouteProvider {
                case BluetoothProfile.A2DP:
                    mA2dpProfile = (BluetoothA2dp) proxy;
                    // It may contain null.
                    activeDevices = Collections.singletonList(mA2dpProfile.getActiveDevice());
                    activeDevices = mBluetoothAdapter.getActiveDevices(BluetoothProfile.A2DP);
                    break;
                case BluetoothProfile.HEARING_AID:
                    mHearingAidProfile = (BluetoothHearingAid) proxy;
                    activeDevices = mHearingAidProfile.getActiveDevices();
                    activeDevices = mBluetoothAdapter.getActiveDevices(
                            BluetoothProfile.HEARING_AID);
                    break;
                case BluetoothProfile.LE_AUDIO:
                    mLeAudioProfile = (BluetoothLeAudio) proxy;
                    activeDevices = mLeAudioProfile.getActiveDevices();
                    activeDevices = mBluetoothAdapter.getActiveDevices(BluetoothProfile.LE_AUDIO);
                    break;
                default:
                    return;