Add support for setting camera display orientation.
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index a8e217e..81d60dc 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -1191,14 +1191,6 @@
CameraParameters p(params);
- // The orientation parameter is actually for CameraService, not for the camera driver.
- if (p.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
- LOGV("portrait mode");
- mOrientation = ISurface::BufferHeap::ROT_90;
- } else {
- mOrientation = 0;
- }
-
return mHardware->setParameters(p);
}
@@ -1224,6 +1216,30 @@
status_t result = checkPid();
if (result != NO_ERROR) return result;
+ if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
+ // The orientation cannot be set during preview.
+ if (mHardware->previewEnabled()) {
+ return INVALID_OPERATION;
+ }
+ switch (arg1) {
+ case 0:
+ mOrientation = ISurface::BufferHeap::ROT_0;
+ break;
+ case 90:
+ mOrientation = ISurface::BufferHeap::ROT_90;
+ break;
+ case 180:
+ mOrientation = ISurface::BufferHeap::ROT_180;
+ break;
+ case 270:
+ mOrientation = ISurface::BufferHeap::ROT_270;
+ break;
+ default:
+ return BAD_VALUE;
+ }
+ return OK;
+ }
+
if (mHardware == 0) {
LOGE("mHardware is NULL, returning.");
return INVALID_OPERATION;
diff --git a/include/ui/Camera.h b/include/ui/Camera.h
index 5219772..c506fb8 100644
--- a/include/ui/Camera.h
+++ b/include/ui/Camera.h
@@ -82,6 +82,7 @@
enum {
CAMERA_CMD_START_SMOOTH_ZOOM = 1,
CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,
+ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,
};
// camera fatal errors
@@ -209,4 +210,3 @@
}; // namespace android
#endif
-
diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h
index a5ea133..cae0676 100644
--- a/include/ui/CameraParameters.h
+++ b/include/ui/CameraParameters.h
@@ -29,12 +29,6 @@
CameraParameters(const String8 ¶ms) { unflatten(params); }
~CameraParameters();
- enum {
- CAMERA_ORIENTATION_UNKNOWN = 0,
- CAMERA_ORIENTATION_PORTRAIT = 1,
- CAMERA_ORIENTATION_LANDSCAPE = 2,
- };
-
String8 flatten() const;
void unflatten(const String8 ¶ms);
@@ -63,9 +57,6 @@
void setPictureFormat(const char *format);
const char *getPictureFormat() const;
- int getOrientation() const;
- void setOrientation(int orientation);
-
void dump() const;
status_t dump(int fd, const Vector<String16>& args) const;
diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp
index 2e0409b..a94f6b9 100644
--- a/libs/ui/CameraParameters.cpp
+++ b/libs/ui/CameraParameters.cpp
@@ -121,9 +121,6 @@
const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
-static const char* portrait = "portrait";
-static const char* landscape = "landscape";
-
CameraParameters::CameraParameters()
: mMap()
{
@@ -282,23 +279,6 @@
set(KEY_PREVIEW_FORMAT, format);
}
-int CameraParameters::getOrientation() const
-{
- const char* orientation = get("orientation");
- if (orientation && !strcmp(orientation, portrait))
- return CAMERA_ORIENTATION_PORTRAIT;
- return CAMERA_ORIENTATION_LANDSCAPE;
-}
-
-void CameraParameters::setOrientation(int orientation)
-{
- if (orientation == CAMERA_ORIENTATION_PORTRAIT) {
- set("orientation", portrait);
- } else {
- set("orientation", landscape);
- }
-}
-
const char *CameraParameters::getPreviewFormat() const
{
return get(KEY_PREVIEW_FORMAT);