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

Commit d69942e2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix crash in AdapterService#disconnectAudio due to ArrayIndexOutOfBoundsException"

parents f3589894 20b0acf2
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1474,12 +1474,20 @@ public class HeadsetService extends ProfileService {
    }

    int disconnectAudio() {
        int disconnectResult = BluetoothStatusCodes.ERROR_NO_ACTIVE_DEVICES;
        synchronized (mStateMachines) {
            List<BluetoothDevice> activeAudioDevices = getNonIdleAudioDevices();
            BluetoothDevice activeAudioDevice =
                    activeAudioDevices.get(activeAudioDevices.size() - 1);
            return disconnectAudio(activeAudioDevice);
            for (BluetoothDevice device : getNonIdleAudioDevices()) {
                disconnectResult = disconnectAudio(device);
                if (disconnectResult == BluetoothStatusCodes.SUCCESS) {
                    return disconnectResult;
                } else {
                    Log.e(TAG, "disconnectAudio() from " + device + " failed with status code "
                            + disconnectResult);
                }
            }
        }
        logD("disconnectAudio() no active audio connection");
        return disconnectResult;
    }

    int disconnectAudio(BluetoothDevice device) {