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

Commit 170b5d83 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "AudioService BtHelper: fix Bluetooth Headset to audio device mapping" into main

parents 1a065ef5 de679fe3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1093,7 +1093,8 @@ public class AudioDeviceBroker {

    /*package*/ static BtDeviceInfo createBtDeviceInfo(@NonNull BtDeviceChangedData d,
            @NonNull BluetoothDevice device, int state) {
        int audioDevice = BtHelper.getTypeFromProfile(d.mInfo.getProfile(), d.mInfo.isLeOutput());
        int audioDevice = BtHelper.getTypeFromProfile(
                d.mInfo.getProfile(), d.mInfo.isLeOutput(), device);
        return new BtDeviceInfo(d, device, state, audioDevice, AudioSystem.AUDIO_FORMAT_DEFAULT);
    }

+2 −1
Original line number Diff line number Diff line
@@ -1041,7 +1041,8 @@ public class AudioDeviceInventory {
                "onBluetoothDeviceConfigChange addr=" + address
                    + " event=" + BtHelper.deviceEventToString(event)));

        int deviceType = BtHelper.getTypeFromProfile(btInfo.mProfile, btInfo.mIsLeOutput);
        int deviceType = BtHelper.getTypeFromProfile(
                btInfo.mProfile, btInfo.mIsLeOutput, btDevice);

        boolean disconnectDevice = false;
        synchronized (mDevicesLock) {
+3 −2
Original line number Diff line number Diff line
@@ -1298,7 +1298,8 @@ public class BtHelper {
        return 0; // 0 is not a valid profile
    }

    /*package */ static int getTypeFromProfile(int profile, boolean isLeOutput) {
    /*package */ static int getTypeFromProfile(
            int profile, boolean isLeOutput, BluetoothDevice device) {
        switch (profile) {
            case BluetoothProfile.A2DP_SINK:
                return AudioSystem.DEVICE_IN_BLUETOOTH_A2DP;
@@ -1315,7 +1316,7 @@ public class BtHelper {
            case BluetoothProfile.LE_AUDIO_BROADCAST:
                return AudioSystem.DEVICE_OUT_BLE_BROADCAST;
            case BluetoothProfile.HEADSET:
                return AudioSystem.DEVICE_OUT_BLUETOOTH_SCO;
                return btHeadsetDeviceToAudioDevice(device).getInternalType();
            default:
                throw new IllegalArgumentException("Invalid profile " + profile);
        }