Skip to content

Commit 3c02c12

Browse files
Wu-cheng LiAndroid (Google) Code Review
authored andcommitted
Merge "Allow Camera.setDisplayOrientation to be called when preview is active."
2 parents 1d6f70c + d303362 commit 3c02c12

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

core/java/android/hardware/Camera.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,10 @@ public final void takePicture(ShutterCallback shutter, PictureCallback raw,
10071007
* camera.setDisplayOrientation(result);
10081008
* }
10091009
* </pre>
1010+
*
1011+
* <p>Starting from API level 14, this method can be called when preview is
1012+
* active.
1013+
*
10101014
* @param degrees the angle that the picture will be rotated clockwise.
10111015
* Valid values are 0, 90, 180, and 270. The starting
10121016
* position is 0 (landscape).

services/camera/libcameraservice/CameraService.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,16 +849,16 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a
849849
if (result != NO_ERROR) return result;
850850

851851
if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
852-
// The orientation cannot be set during preview.
853-
if (mHardware->previewEnabled()) {
854-
return INVALID_OPERATION;
855-
}
856852
// Mirror the preview if the camera is front-facing.
857853
orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
858854
if (orientation == -1) return BAD_VALUE;
859855

860856
if (mOrientation != orientation) {
861857
mOrientation = orientation;
858+
if (mPreviewWindow != 0) {
859+
native_window_set_buffers_transform(mPreviewWindow.get(),
860+
mOrientation);
861+
}
862862
}
863863
return OK;
864864
} else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) {

0 commit comments

Comments
 (0)