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

Commit 1412a1d2 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioRecord: ensure documented behavior of active rec config

Make sure getActiveRecordingConfiguration() doesn't throw an
exception when queried after the recorder is released as this
isn't part of the API contract

Bug: 170608713
Test: atest android.media.cts.AudioRecordTest#testGetActiveRecordingConfiguration
Change-Id: I8003056e65ab0e125b5478d6c765878b2840d4b9
parent 283d7b9c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
    //--------------------
    /**
     * Accessed by native methods: provides access to C++ AudioRecord object
     * Is 0 after release()
     */
    @SuppressWarnings("unused")
    @UnsupportedAppUsage
@@ -1863,7 +1864,11 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
        if (mNativeRecorderInJavaObj == 0) {
            return 0;
        }
        try {
            return native_getPortId();
        } catch (IllegalStateException e) {
            return 0;
        }
    }

    //--------------------------------------------------------------------------
@@ -2046,6 +2051,9 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
    private native final int native_get_active_microphones(
            ArrayList<MicrophoneInfo> activeMicrophones);

    /**
     * @throws IllegalStateException
     */
    private native int native_getPortId();

    private native int native_set_preferred_microphone_direction(int direction);