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

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

Merge "AudioService: ensure sink role for communication device"

parents 6d5d54ef 6aa23612
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -7670,8 +7670,10 @@ public class AudioManager {
     * or video calls. This method can be used by voice or video chat applications to select a
     * different audio device than the one selected by default by the platform.
     * <p>The device selection is expressed as an {@link AudioDeviceInfo} among devices returned by
     * {@link #getAvailableCommunicationDevices()}.
     * The selection is active as long as the requesting application process lives, until
     * {@link #getAvailableCommunicationDevices()}. Note that only devices in a sink role
     * (AKA output devices, see {@link AudioDeviceInfo#isSink()}) can be specified. The matching
     * source device is selected automatically by the platform.
     * <p>The selection is active as long as the requesting application process lives, until
     * {@link #clearCommunicationDevice} is called or until the device is disconnected.
     * It is therefore important for applications to clear the request when a call ends or the
     * the requesting activity or service is stopped or destroyed.
+8 −1
Original line number Diff line number Diff line
@@ -5863,6 +5863,9 @@ public class AudioService extends IAudioService.Stub
    };
    private boolean isValidCommunicationDevice(AudioDeviceInfo device) {
        if (!device.isSink()) {
            return false;
        }
        for (int type : VALID_COMMUNICATION_DEVICE_TYPES) {
            if (device.getType() == type) {
                return true;
@@ -5897,7 +5900,11 @@ public class AudioService extends IAudioService.Stub
                throw new IllegalArgumentException("invalid portID " + portId);
            }
            if (!isValidCommunicationDevice(device)) {
                throw new IllegalArgumentException("invalid device type " + device.getType());
                if (!device.isSink()) {
                    throw new IllegalArgumentException("device must have sink role");
                } else {
                    throw new IllegalArgumentException("invalid device type: " + device.getType());
                }
            }
        }
        final String eventSource = new StringBuilder()