am 0c243448: am 86a008ea: am 556e8377: am 513cd81a: am b5b05ae2: Merge "Update CTS Verifier camera video tests to check for a microphone in camera video recording tests." into kitkat-cts-dev

* commit '0c243448dbc6814a24da3b725c92d7d14f5a278d':
  Update CTS Verifier camera video tests to check for a microphone in camera video recording tests.
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
index 0a397e8..f3e87b3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
@@ -17,6 +17,7 @@
 
 import android.app.AlertDialog;
 import android.content.DialogInterface;
+import android.content.pm.PackageManager;
 import android.graphics.Matrix;
 import android.graphics.SurfaceTexture;
 import android.hardware.Camera;
@@ -144,17 +145,28 @@
     private boolean prepareVideoRecorder() {
 
         mMediaRecorder = new MediaRecorder();
+        CamcorderProfile profile = CamcorderProfile.get(mCurrentCameraId, mCurrentVideoSizeId);
 
         // Step 1: unlock and set camera to MediaRecorder
         mCamera.unlock();
         mMediaRecorder.setCamera(mCamera);
 
         // Step 2: set sources
-        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
+        if (hasMicrophone()) {
+            mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
+        }
         mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
 
         // Step 3: set a CamcorderProfile
-        mMediaRecorder.setProfile(CamcorderProfile.get(mCurrentCameraId, mCurrentVideoSizeId));
+        if (hasMicrophone()) {
+            mMediaRecorder.setProfile(profile);
+        } else {
+            mMediaRecorder.setOutputFormat(profile.fileFormat);
+            mMediaRecorder.setVideoFrameRate(profile.videoFrameRate);
+            mMediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
+            mMediaRecorder.setVideoEncodingBitRate(profile.videoBitRate);
+            mMediaRecorder.setVideoEncoder(profile.videoCodec);
+        }
 
         // Step 4: set output file
         outputVideoFile = getOutputMediaFile(MEDIA_TYPE_VIDEO);
@@ -767,4 +779,9 @@
                 .show();
     }
 
+    private boolean hasMicrophone() {
+        return CameraVideoActivity.this.getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_MICROPHONE);
+    }
+
 }