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

Commit eb30e05d authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioService: add checks when getting A2DP codec config from BT service

Add checks missing from commit 9fbc205f.

Bug: 123166278
Bug: 111812273
Test: make
Change-Id: Ia8ec35163c30e24fcfd9454ea8f7e9139610b4d7
parent fffeac81
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -4746,13 +4746,19 @@ public class AudioService extends IAudioService.Stub

    private int getA2dpCodec(BluetoothDevice device) {
        synchronized (mA2dpAvrcpLock) {
            if (mA2dp != null) {
            if (mA2dp == null) {
                return AudioSystem.AUDIO_FORMAT_DEFAULT;
            }
            BluetoothCodecStatus btCodecStatus = mA2dp.getCodecStatus(device);
                BluetoothCodecConfig btCodecConfig = btCodecStatus.getCodecConfig();
                return mapBluetoothCodecToAudioFormat(btCodecConfig.getCodecType());
            if (btCodecStatus == null) {
                return AudioSystem.AUDIO_FORMAT_DEFAULT;
            }
            BluetoothCodecConfig btCodecConfig = btCodecStatus.getCodecConfig();
            if (btCodecConfig == null) {
                return AudioSystem.AUDIO_FORMAT_DEFAULT;
            }
            return mapBluetoothCodecToAudioFormat(btCodecConfig.getCodecType());
        }
    }

    /*