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

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

Merge "AudioDeviceInfo: fix back microphone type conversion"

parents 97ada9bc 8858e6ff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public final class AudioDeviceAttributes implements Parcelable {
            mNativeType = AudioDeviceInfo.convertDeviceTypeToInternalDevice(type);
        } else if (role == ROLE_INPUT) {
            AudioDeviceInfo.enforceValidAudioDeviceTypeIn(type);
            mNativeType = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(type);
            mNativeType = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(type, address);
        } else {
            mNativeType = AudioSystem.DEVICE_NONE;
        }
+10 −4
Original line number Diff line number Diff line
@@ -581,7 +581,16 @@ public final class AudioDeviceInfo {

    /** @hide */
    public static int convertDeviceTypeToInternalInputDevice(int deviceType) {
        return EXT_TO_INT_INPUT_DEVICE_MAPPING.get(deviceType, AudioSystem.DEVICE_NONE);
        return convertDeviceTypeToInternalInputDevice(deviceType, "");
    }
    /** @hide */
    public static int convertDeviceTypeToInternalInputDevice(int deviceType, String address) {
        int internalType = EXT_TO_INT_INPUT_DEVICE_MAPPING.get(deviceType, AudioSystem.DEVICE_NONE);
        if (internalType == AudioSystem.DEVICE_IN_BUILTIN_MIC
                && "back".equals(address)) {
            internalType = AudioSystem.DEVICE_IN_BACK_MIC;
        }
        return internalType;
    }

    private static final SparseIntArray INT_TO_EXT_DEVICE_MAPPING;
@@ -671,9 +680,6 @@ public final class AudioDeviceInfo {
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_ACCESSORY, AudioSystem.DEVICE_OUT_USB_ACCESSORY);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_DOCK, AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_FM, AudioSystem.DEVICE_OUT_FM);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_MIC, AudioSystem.DEVICE_IN_BUILTIN_MIC);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_FM_TUNER, AudioSystem.DEVICE_IN_FM_TUNER);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TV_TUNER, AudioSystem.DEVICE_IN_TV_TUNER);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_OUT_TELEPHONY_TX);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_AUX_LINE, AudioSystem.DEVICE_OUT_AUX_LINE);
        EXT_TO_INT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_OUT_IP);
+1 −1
Original line number Diff line number Diff line
@@ -1915,7 +1915,7 @@ public class AudioSystem
            types[i] = devices.get(i).getInternalType();
            if (types[i] == AudioSystem.DEVICE_NONE) {
                types[i] = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(
                        devices.get(i).getType());
                        devices.get(i).getType(), devices.get(i).getAddress());
            }
            addresses[i] = devices.get(i).getAddress();
        }
+6 −1
Original line number Diff line number Diff line
@@ -511,7 +511,12 @@ public class AudioEffect {
        int deviceType = AudioSystem.DEVICE_NONE;
        String deviceAddress = "";
        if (device != null) {
            if (device.getRole() == AudioDeviceAttributes.ROLE_OUTPUT) {
                deviceType = AudioDeviceInfo.convertDeviceTypeToInternalDevice(device.getType());
            } else {
                deviceType = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(
                        device.getType(), device.getAddress());
            }
            deviceAddress = device.getAddress();
        }