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

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

AudioManager: relax exceptions for setCommunicationDevice

Do not throw an IllegalArgumentException exception in
setCommunicationDevice() if the selected device is not
connected any more but return false instead; This race
condition cannot be avoided programmatically.

Bug: 264837721
Test: manual regression tests for call routing

Change-Id: I6ba0c81b89a5871a210a115885836693e4972fcb
parent 2953bacf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7687,7 +7687,8 @@ public class AudioManager {
        Objects.requireNonNull(device);
        try {
            if (device.getId() == 0) {
                throw new IllegalArgumentException("In valid device: " + device);
                Log.w(TAG, "setCommunicationDevice: device not found: " + device);
                return false;
            }
            return getService().setCommunicationDevice(mICallBack, device.getId());
        } catch (RemoteException e) {
+2 −1
Original line number Diff line number Diff line
@@ -5894,7 +5894,8 @@ public class AudioService extends IAudioService.Stub
        if (portId != 0) {
            device = AudioManager.getDeviceForPortId(portId, AudioManager.GET_DEVICES_OUTPUTS);
            if (device == null) {
                throw new IllegalArgumentException("invalid portID " + portId);
                Log.w(TAG, "setCommunicationDevice: invalid portID " + portId);
                return false;
            }
            if (!isValidCommunicationDevice(device)) {
                throw new IllegalArgumentException("invalid device type " + device.getType());