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
This commit is contained in:
Jean-Michel Trivi
2020-11-24 11:13:20 -08:00
parent 283d7b9c82
commit 1412a1d20c

View File

@@ -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;
}
return native_getPortId();
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);