Fix orientation test and improve its instructions
bug: 7233481
Change-Id: I58655ef50e2097ccca07219261df949a175506f4
diff --git a/apps/CtsVerifier/res/layout/co_main.xml b/apps/CtsVerifier/res/layout/co_main.xml
index 6fd18da..e3ddf49 100644
--- a/apps/CtsVerifier/res/layout/co_main.xml
+++ b/apps/CtsVerifier/res/layout/co_main.xml
@@ -121,7 +121,7 @@
android:id="@+id/take_picture_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:enabled="true"
+ android:enabled="false"
android:text="@string/co_photo_button_caption" />
</LinearLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index b088465..99108ae 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -298,12 +298,17 @@
<!-- 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
- 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 name="co_info">This test verifies the orientation capabilities of
+ camera preview and capture.\n - The left view shows a preview window rotated
+ clockwise by a given magnitude of degrees.\n - The right view, after taking
+ a photo, shows the captured image.\n - For each camera and orientation, both
+ the left and right views should appear rotated clockwise by the amount of
+ degrees specified. Choose \"Pass\" if this is the case. Otherwise, choose
+ \"Fail\".\n - For front-facing cameras, the test will horizontally mirror
+ the captured image prior to rotation, in attempt to make the left and right
+ views appear the same.\n - The physical orientation of the device does not
+ matter.\n - 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>
@@ -312,8 +317,8 @@
<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_instruction_text_passfail_label">Choose \"Pass\" if the left view is oriented the same as the right view. Otherwise, choose \"Fail\".</string>
+ <string name="co_instruction_text_extra_label">(mirrored horizontally prior to rotation, since camera is front-facing)</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 b90f2132..b970e40 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
@@ -51,6 +51,7 @@
private static final String TAG = "CameraOrientation";
private static final int STATE_OFF = 0;
private static final int STATE_PREVIEW = 1;
+ private static final int STATE_CAPTURE = 2;
private static final int NUM_ORIENTATIONS = 4;
private static final String STAGE_INDEX_EXTRA = "stageIndex";
@@ -69,6 +70,7 @@
private int mNumCameras;
private int mCurrentCameraId = -1;
private int mState = STATE_OFF;
+ private boolean mSizeAdjusted;
private StringBuilder mReportBuilder = new StringBuilder();
private final TreeSet<String> mTestedCombinations = new TreeSet<String>();
@@ -123,6 +125,7 @@
resetButtons();
// Set initial values
+ mSizeAdjusted = false;
mCurrentCameraId = settings.mCameraId;
TextView cameraLabel = (TextView) findViewById(R.id.camera_text);
cameraLabel.setText(
@@ -148,7 +151,7 @@
(TextView) findViewById(R.id.instruction_text);
instructionLabel.setText(R.string.co_instruction_text_photo_label);
- mTakePictureButton.setEnabled(true);
+ mTakePictureButton.setEnabled(false);
setUpCamera(mCurrentCameraId);
}
@@ -230,7 +233,6 @@
return;
}
- mState = STATE_PREVIEW;
mCamera.setPreviewCallback(mPreviewCallback);
try {
@@ -274,6 +276,8 @@
cameraExtraLabel.setText(
getString(R.string.co_instruction_text_extra_label));
}
+
+ mState = STATE_PREVIEW;
}
@Override
@@ -281,8 +285,12 @@
Log.v(TAG, "Click detected");
if (view == mFormatView || view == mTakePictureButton) {
- Log.v(TAG, "Taking picture");
- mCamera.takePicture(null, null, null, mCameraCallback);
+ if(mState == STATE_PREVIEW) {
+ mTakePictureButton.setEnabled(false);
+ Log.v(TAG, "Taking picture");
+ mCamera.takePicture(null, null, null, mCameraCallback);
+ mState = STATE_CAPTURE;
+ }
}
if(view == mPassButton || view == mFailButton) {
@@ -443,27 +451,30 @@
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
// adjust camera preview to match output image's aspect ratio
+ if(!mSizeAdjusted && mState == STATE_PREVIEW) {
+ int viewWidth = mFormatView.getWidth();
+ int viewHeight = mFormatView.getHeight();
+ int newWidth, newHeight;
- int viewWidth = mFormatView.getWidth();
- int viewHeight = mFormatView.getHeight();
- int newWidth, newHeight;
+ if (mPreviewOrientations.get(mNextPreviewOrientation) == 0
+ || mPreviewOrientations.get(mNextPreviewOrientation) == 180) {
+ // make preview width same as output image width,
+ // then calculate height using output image's height/width ratio
+ newWidth = viewWidth;
+ newHeight = (int) (viewWidth * ((double) mOptimalSize.height /
+ (double) mOptimalSize.width));
+ }
+ else {
+ newHeight = viewHeight;
+ newWidth = (int) (viewHeight * ((double) mOptimalSize.height /
+ (double) mOptimalSize.width));
+ }
- if (mPreviewOrientations.get(mNextPreviewOrientation) == 0
- || mPreviewOrientations.get(mNextPreviewOrientation) == 180) {
- // make preview width same as output image width,
- // then calculate height using output image's height/width ratio
- newWidth = viewWidth;
- newHeight = (int) (viewWidth * ((double) mOptimalSize.height /
- (double) mOptimalSize.width));
+ LayoutParams layoutParams = new LayoutParams(newWidth, newHeight);
+ mCameraView.setLayoutParams(layoutParams);
+ mSizeAdjusted = true;
+ mTakePictureButton.setEnabled(true);
}
- else {
- newHeight = viewHeight;
- newWidth = (int) (viewHeight * ((double) mOptimalSize.height /
- (double) mOptimalSize.width));
- }
-
- LayoutParams layoutParams = new LayoutParams(newWidth, newHeight);
- mCameraView.setLayoutParams(layoutParams);
}
};