summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/CameraService.cpp
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-09-23 17:17:43 -0700
committerWu-cheng Li <wuchengli@google.com>2010-09-27 11:49:56 -0700
commitb3347bc6d797d402b21b9b524de15c10b134c13d (patch)
tree031c491d939f6c650b4c90096f1703ead90dd2a5 /services/camera/libcameraservice/CameraService.cpp
parent4e9751f0770c8bfe6f7d57465cba754af5aa942b (diff)
downloadframeworks_base-b3347bc6d797d402b21b9b524de15c10b134c13d.zip
frameworks_base-b3347bc6d797d402b21b9b524de15c10b134c13d.tar.gz
frameworks_base-b3347bc6d797d402b21b9b524de15c10b134c13d.tar.bz2
The old overlay should be destroyed if orientation changes.
Previously the orientation was wrong after suspend and resume. When the camera app is resumed behide the lock screen, it orinteation is portrait. When users slide to unlock the screen, surfaceChanged is called and the orientation is landscape. The camera app stops the preview, sets the display orientation, and starts the preview. Overlay should be destroyed if the orientation has changed. bug:3031640 Change-Id: I38b527f9ea78c91b538463292152c023383b4695
Diffstat (limited to 'services/camera/libcameraservice/CameraService.cpp')
-rw-r--r--services/camera/libcameraservice/CameraService.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index ea2c5d4..58209fd 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -319,6 +319,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
// Callback is disabled by default
mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
mOrientation = 0;
+ mOrientationChanged = false;
cameraService->setCameraBusy(cameraId);
cameraService->loadSound();
LOG1("Client::Client X (pid %d)", callingPid);
@@ -496,6 +497,7 @@ status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface) {
// Force the destruction of any previous overlay
sp<Overlay> dummy;
mHardware->setOverlay(dummy);
+ mOverlayRef = 0;
} else {
mSurface->unregisterBuffers();
}
@@ -539,11 +541,12 @@ status_t CameraService::Client::setOverlay() {
CameraParameters params(mHardware->getParameters());
params.getPreviewSize(&w, &h);
- if (w != mOverlayW || h != mOverlayH) {
+ if (w != mOverlayW || h != mOverlayH || mOrientationChanged) {
// Force the destruction of any previous overlay
sp<Overlay> dummy;
mHardware->setOverlay(dummy);
mOverlayRef = 0;
+ mOrientationChanged = false;
}
status_t result = NO_ERROR;
@@ -810,6 +813,7 @@ String8 CameraService::Client::getParameters() const {
status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
LOG1("sendCommand (pid %d)", getCallingPid());
+ int orientation;
Mutex::Autolock lock(mLock);
status_t result = checkPidAndHardware();
if (result != NO_ERROR) return result;
@@ -821,20 +825,24 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a
}
switch (arg1) {
case 0:
- mOrientation = ISurface::BufferHeap::ROT_0;
+ orientation = ISurface::BufferHeap::ROT_0;
break;
case 90:
- mOrientation = ISurface::BufferHeap::ROT_90;
+ orientation = ISurface::BufferHeap::ROT_90;
break;
case 180:
- mOrientation = ISurface::BufferHeap::ROT_180;
+ orientation = ISurface::BufferHeap::ROT_180;
break;
case 270:
- mOrientation = ISurface::BufferHeap::ROT_270;
+ orientation = ISurface::BufferHeap::ROT_270;
break;
default:
return BAD_VALUE;
}
+ if (mOrientation != orientation) {
+ mOrientation = orientation;
+ if (mOverlayRef != 0) mOrientationChanged = true;
+ }
return OK;
}