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

Commit 6e3c2ac9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "audio: Align api2aidl_NativeType_AudioDeviceDescription with native" into main

parents 5704fa07 d7e56a68
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -154,6 +154,13 @@ jobject legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel(
            });
            });
}
}


/* Used for test purposes only, not efficient. */
jobject legacy2aidl_audio_devices_t_AudioDeviceDescription_Parcel(JNIEnv* env, jobject,
                                                                  int /*audio_devices_t*/ legacy) {
    return legacy2aidlParcel(env, static_cast<audio_devices_t>(legacy),
                             legacy2aidl_audio_devices_t_AudioDeviceDescription);
}

int aidl2legacy_AudioFormatDescription_Parcel_audio_format_t(JNIEnv* env, jobject,
int aidl2legacy_AudioFormatDescription_Parcel_audio_format_t(JNIEnv* env, jobject,
                                                             jobject jParcel) {
                                                             jobject jParcel) {
    return aidlParcel2legacy<
    return aidlParcel2legacy<
@@ -208,6 +215,8 @@ const JNINativeMethod gMethods[] = {
         reinterpret_cast<void*>(aidl2legacy_AudioChannelLayout_Parcel_audio_channel_mask_t)},
         reinterpret_cast<void*>(aidl2legacy_AudioChannelLayout_Parcel_audio_channel_mask_t)},
        {"legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel", "(IZ)Landroid/os/Parcel;",
        {"legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel", "(IZ)Landroid/os/Parcel;",
         reinterpret_cast<void*>(legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel)},
         reinterpret_cast<void*>(legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel)},
        {"legacy2aidl_audio_devices_t_AudioDeviceDescription_Parcel", "(I)Landroid/os/Parcel;",
         reinterpret_cast<void*>(legacy2aidl_audio_devices_t_AudioDeviceDescription_Parcel)},
        {"aidl2legacy_AudioFormatDescription_Parcel_audio_format_t", "(Landroid/os/Parcel;)I",
        {"aidl2legacy_AudioFormatDescription_Parcel_audio_format_t", "(Landroid/os/Parcel;)I",
         reinterpret_cast<void*>(aidl2legacy_AudioFormatDescription_Parcel_audio_format_t)},
         reinterpret_cast<void*>(aidl2legacy_AudioFormatDescription_Parcel_audio_format_t)},
        {"legacy2aidl_audio_format_t_AudioFormatDescription_Parcel", "(I)Landroid/os/Parcel;",
        {"legacy2aidl_audio_format_t_AudioFormatDescription_Parcel", "(I)Landroid/os/Parcel;",
+21 −4
Original line number Original line Diff line number Diff line
@@ -834,18 +834,18 @@ public class AidlConversion {
                aidl.connection = AudioDeviceDescription.CONNECTION_IP_V4;
                aidl.connection = AudioDeviceDescription.CONNECTION_IP_V4;
                break;
                break;
            case AudioSystem.DEVICE_IN_BUS:
            case AudioSystem.DEVICE_IN_BUS:
                aidl.type = AudioDeviceType.IN_DEVICE;
                aidl.type = AudioDeviceType.IN_BUS;
                aidl.connection = AudioDeviceDescription.CONNECTION_BUS;
                break;
                break;
            case AudioSystem.DEVICE_OUT_BUS:
            case AudioSystem.DEVICE_OUT_BUS:
                aidl.type = AudioDeviceType.OUT_DEVICE;
                aidl.type = AudioDeviceType.OUT_BUS;
                aidl.connection = AudioDeviceDescription.CONNECTION_BUS;
                break;
                break;
            case AudioSystem.DEVICE_IN_PROXY:
            case AudioSystem.DEVICE_IN_PROXY:
                aidl.type = AudioDeviceType.IN_AFE_PROXY;
                aidl.type = AudioDeviceType.IN_AFE_PROXY;
                aidl.connection = AudioDeviceDescription.CONNECTION_VIRTUAL;
                break;
                break;
            case AudioSystem.DEVICE_OUT_PROXY:
            case AudioSystem.DEVICE_OUT_PROXY:
                aidl.type = AudioDeviceType.OUT_AFE_PROXY;
                aidl.type = AudioDeviceType.OUT_AFE_PROXY;
                aidl.connection = AudioDeviceDescription.CONNECTION_VIRTUAL;
                break;
                break;
            case AudioSystem.DEVICE_IN_USB_HEADSET:
            case AudioSystem.DEVICE_IN_USB_HEADSET:
                aidl.type = AudioDeviceType.IN_HEADSET;
                aidl.type = AudioDeviceType.IN_HEADSET;
@@ -891,10 +891,27 @@ public class AidlConversion {
        return aidl;
        return aidl;
    }
    }


    /** For test purposes only, not efficient. */
    public static AudioDeviceDescription legacy2aidl_audio_devices_t_AudioDeviceDescriptionTestOnly(
            int nativeType) {
        Parcel in = legacy2aidl_audio_devices_t_AudioDeviceDescription_Parcel(nativeType);
        if (in != null) {
            try {
                return AudioDeviceDescription.CREATOR.createFromParcel(in);
            } finally {
                in.recycle();
            }
        }
        throw new IllegalArgumentException(
                "Failed to convert legacy audio_devices_t value " + nativeType);
    }

    private static native int aidl2legacy_AudioChannelLayout_Parcel_audio_channel_mask_t(
    private static native int aidl2legacy_AudioChannelLayout_Parcel_audio_channel_mask_t(
            Parcel aidl, boolean isInput);
            Parcel aidl, boolean isInput);
    private static native Parcel legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel(
    private static native Parcel legacy2aidl_audio_channel_mask_t_AudioChannelLayout_Parcel(
            int legacy, boolean isInput);
            int legacy, boolean isInput);
    private static native Parcel legacy2aidl_audio_devices_t_AudioDeviceDescription_Parcel(
            int legacy);
    private static native int aidl2legacy_AudioFormatDescription_Parcel_audio_format_t(
    private static native int aidl2legacy_AudioFormatDescription_Parcel_audio_format_t(
            Parcel aidl);
            Parcel aidl);
    private static native Parcel legacy2aidl_audio_format_t_AudioFormatDescription_Parcel(
    private static native Parcel legacy2aidl_audio_format_t_AudioFormatDescription_Parcel(
+9 −10
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package android.media.audio.common;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
@@ -508,21 +507,21 @@ public final class AidlConversionUnitTests {
    @Test
    @Test
    public void testAudioDeviceDescriptionConversion() {
    public void testAudioDeviceDescriptionConversion() {
        for (int nativeDeviceType : AudioSystem.DEVICE_OUT_ALL_SET) {
        for (int nativeDeviceType : AudioSystem.DEVICE_OUT_ALL_SET) {
            assertNotEquals(
            assertEquals(
                    AidlConversion.api2aidl_NativeType_AudioDeviceDescription(nativeDeviceType)
                    /* Reference value obtained from the native converter. */
                            .type,
                    AidlConversion.legacy2aidl_audio_devices_t_AudioDeviceDescriptionTestOnly(
                    AudioDeviceType.NONE);
                            nativeDeviceType),
                    AidlConversion.api2aidl_NativeType_AudioDeviceDescription(nativeDeviceType));
        }
        }

        for (int nativeDeviceType : AudioSystem.DEVICE_IN_ALL_SET) {
        for (int nativeDeviceType : AudioSystem.DEVICE_IN_ALL_SET) {
            if (nativeDeviceType == AudioSystem.DEVICE_IN_COMMUNICATION
            if (nativeDeviceType == AudioSystem.DEVICE_IN_COMMUNICATION
                    || nativeDeviceType == AudioSystem.DEVICE_IN_AMBIENT) {
                    || nativeDeviceType == AudioSystem.DEVICE_IN_AMBIENT) {
                continue;
                continue;
            }
            }
            assertNotEquals(
            assertEquals(
                    AidlConversion.api2aidl_NativeType_AudioDeviceDescription(nativeDeviceType)
                    AidlConversion.legacy2aidl_audio_devices_t_AudioDeviceDescriptionTestOnly(
                            .type,
                            nativeDeviceType),
                    AudioDeviceType.NONE);
                    AidlConversion.api2aidl_NativeType_AudioDeviceDescription(nativeDeviceType));
        }
        }
    }
    }