AudioRecord tests: only with a microphone

Try to build an AudioRecord instance only when the FEATURE_MICROPHONE
  is present.

Bug 22379284

Change-Id: Ice501fec72644a73ef2ce30d1c737990caf2cf84
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordTest.java b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
index 6ba1aeb..048f956 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
@@ -321,6 +321,9 @@
     // Test AudioRecord.Builder to verify the observed configuration of an AudioRecord built with
     // an empty Builder matches the documentation / expected values
     public void testAudioRecordBuilderDefault() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         // constants for test
         final String TEST_NAME = "testAudioRecordBuilderDefault";
         // expected values below match the AudioRecord.Builder documentation
@@ -352,6 +355,9 @@
     // Test AudioRecord.Builder to verify the observed configuration of an AudioRecord built with
     // an incomplete AudioFormat matches the documentation / expected values
     public void testAudioRecordBuilderPartialFormat() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         // constants for test
         final String TEST_NAME = "testAudioRecordBuilderPartialFormat";
         final int expectedRate = 16000;
@@ -380,6 +386,9 @@
     // Test AudioRecord.Builder to verify the observed configuration of an AudioRecord matches
     // the parameters used in the builder
     public void testAudioRecordBuilderParams() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         // constants for test
         final String TEST_NAME = "testAudioRecordBuilderParams";
         final int expectedRate = 8000;
@@ -418,6 +427,9 @@
 
     // Test AudioRecord to ensure we can build after a failure.
     public void testAudioRecordBufferSize() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         // constants for test
         final String TEST_NAME = "testAudioRecordBufferSize";