Camera orientation test updates

Make front-facing camera cycle through orientations in clockwise
direction, make more detailed instructions.

Bug: 7197509
Change-Id: I63b7b8fc79c83ef9b891bee3af15c5776d5d4920
diff --git a/apps/CtsVerifier/res/layout/co_main.xml b/apps/CtsVerifier/res/layout/co_main.xml
index 042b180..6fd18da 100644
--- a/apps/CtsVerifier/res/layout/co_main.xml
+++ b/apps/CtsVerifier/res/layout/co_main.xml
@@ -112,6 +112,11 @@
                     android:layout_height="wrap_content"
                     android:text="@string/co_instruction_text_photo_label" />
 
+                <TextView
+                    android:id="@+id/instruction_extra_text"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content" />
+
                 <Button
                     android:id="@+id/take_picture_button"
                     android:layout_width="match_parent"
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 67c677c..b088465 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -298,14 +298,22 @@
 
     <!-- Strings for Camera Orientation -->
     <string name="camera_orientation">Camera Orientation</string>
-    <string name="co_info">This test checks that the camera output is oriented in the correct direction, for each camera, and for each of four orientations. Read the instruction above the \"Take Photo\" button for further usability details.</string>
+    <string name="co_info">This test checks that the camera output is oriented
+    in the correct direction, for each camera, and for each of four
+    clockwise orientations. Choose \"Pass\" if both the preview window and the
+    still capture image are rotated clockwise by the amount specified. Otherwise,
+    choose \"Fail\". The physical orientation of the device does not matter. Read
+    the message above the \"Take Photo\" button for step-by-step instructions.
+    </string>
     <string name="co_preview_label">Camera preview</string>
     <string name="co_format_label">Oriented photo</string>
     <string name="co_camera_label">Camera:</string>
     <string name="co_orientation_label">Orientation</string>
+    <string name="co_orientation_direction_label">clockwise</string>
     <string name="co_instruction_heading_label">Instruction:</string>
     <string name="co_instruction_text_photo_label">Take a photo</string>
     <string name="co_instruction_text_passfail_label">Choose pass or fail, or take another photo.</string>
+    <string name="co_instruction_text_extra_label">(mirrored along vertical axis for front-facing camera)</string>
     <string name="co_photo_button_caption">Take Photo</string>
 
     <!-- Strings for Camera Formats -->
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
index 54f8902..b90f213 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
@@ -80,7 +80,7 @@
 
         setContentView(R.layout.co_main);
         setPassFailButtonClickListeners();
-        setInfoResources(R.string.camera_format, R.string.co_info, -1);
+        setInfoResources(R.string.camera_orientation, R.string.co_info, -1);
         mNumCameras = Camera.getNumberOfCameras();
 
         mPassButton         = (Button) findViewById(R.id.pass_button);
@@ -140,6 +140,8 @@
                 + Integer.toString(NUM_ORIENTATIONS)
                 + ": "
                 + mPreviewOrientations.get(mNextPreviewOrientation) + "\u00b0"
+                + " "
+                + getString(R.string.co_orientation_direction_label)
                 );
 
         TextView instructionLabel =
@@ -240,11 +242,12 @@
         Camera.Parameters p = mCamera.getParameters();
         Log.v(TAG, "Initializing picture format");
         p.setPictureFormat(ImageFormat.JPEG);
-        Log.v(TAG, "Initializing picture size");
         mOptimalSize = getOptimalPreviewSize(mPreviewSizes, 640, 480);
-        Log.v(TAG, "Initializing picture size");
+        Log.v(TAG, "Initializing picture size to "
+                + mOptimalSize.width + "x" + mOptimalSize.height);
         p.setPictureSize(mOptimalSize.width, mOptimalSize.height);
-        Log.v(TAG, "Initializing preview size");
+        Log.v(TAG, "Initializing preview size to "
+                + mOptimalSize.width + "x" + mOptimalSize.height);
         p.setPreviewSize(mOptimalSize.width, mOptimalSize.height);
 
         Log.v(TAG, "Setting camera parameters");
@@ -260,16 +263,17 @@
 
         // set preview orientation
         int degrees = mPreviewOrientations.get(mNextPreviewOrientation);
-        int result;
+        mCamera.setDisplayOrientation(degrees);
+
         android.hardware.Camera.CameraInfo info =
                 new android.hardware.Camera.CameraInfo();
         android.hardware.Camera.getCameraInfo(mCurrentCameraId, info);
         if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
-            result = (360 - degrees) % 360; // compensate the mirror
-        } else { // back-facing
-            result = degrees;
+            TextView cameraExtraLabel =
+                    (TextView) findViewById(R.id.instruction_extra_text);
+            cameraExtraLabel.setText(
+                    getString(R.string.co_instruction_text_extra_label));
         }
-        mCamera.setDisplayOrientation(result);
     }
 
     @Override
@@ -479,6 +483,7 @@
                 if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                     // mirror the image along vertical axis
                     mirrorX = new float[] {-1, 0, 0, 0, 1, 1, 0, 0, 1};
+                    degrees = (360 - degrees) % 360; // compensate the mirror
                 } else {
                     // leave image the same via identity matrix
                     mirrorX = new float[] {1, 0, 0, 0, 1, 0, 0, 0, 1};