diff options
| author | 2020-11-24 11:13:20 -0800 | |
|---|---|---|
| committer | 2020-11-24 11:13:20 -0800 | |
| commit | 1412a1d20c04982ead48c57a78b7bdbaf9b13adb (patch) | |
| tree | fcc1d7c7429cb5400e52a4d0c713c4dba6b96d4f | |
| parent | 283d7b9c82e7c23c430b796dc29efe8152f7e31e (diff) | |
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
| -rw-r--r-- | media/java/android/media/AudioRecord.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index c9cdbb0ed277..6570aabf8e2d 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -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); |