auto import from //branches/cupcake/...@127101
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index 4a325ac..50c6008 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -125,10 +125,9 @@
status_t Camera::reconnect()
{
LOGV("reconnect");
- if (mCamera != 0) {
- return mCamera->connect(this);
- }
- return NO_INIT;
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->connect(this);
}
sp<ICamera> Camera::remote()
@@ -138,14 +137,16 @@
status_t Camera::lock()
{
- if (mCamera != 0) return mCamera->lock();
- return NO_INIT;
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->lock();
}
status_t Camera::unlock()
{
- if (mCamera != 0) return mCamera->unlock();
- return NO_INIT;
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->unlock();
}
// pass the buffered ISurface to the camera service
@@ -156,7 +157,9 @@
LOGE("app passed NULL surface");
return NO_INIT;
}
- return mCamera->setPreviewDisplay(surface->getISurface());
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->setPreviewDisplay(surface->getISurface());
}
status_t Camera::setPreviewDisplay(const sp<ISurface>& surface)
@@ -166,7 +169,9 @@
LOGE("app passed NULL surface");
return NO_INIT;
}
- return mCamera->setPreviewDisplay(surface);
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->setPreviewDisplay(surface);
}
@@ -174,48 +179,62 @@
status_t Camera::startPreview()
{
LOGV("startPreview");
- return mCamera->startPreview();
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->startPreview();
}
// stop preview mode
void Camera::stopPreview()
{
LOGV("stopPreview");
- mCamera->stopPreview();
+ sp <ICamera> c = mCamera;
+ if (c == 0) return;
+ c->stopPreview();
}
// get preview state
bool Camera::previewEnabled()
{
LOGV("previewEnabled");
- return mCamera->previewEnabled();
+ sp <ICamera> c = mCamera;
+ if (c == 0) return false;
+ return c->previewEnabled();
}
status_t Camera::autoFocus()
{
LOGV("autoFocus");
- return mCamera->autoFocus();
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->autoFocus();
}
// take a picture
status_t Camera::takePicture()
{
LOGV("takePicture");
- return mCamera->takePicture();
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->takePicture();
}
// set preview/capture parameters - key/value pairs
status_t Camera::setParameters(const String8& params)
{
LOGV("setParameters");
- return mCamera->setParameters(params);
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->setParameters(params);
}
// get preview/capture parameters - key/value pairs
String8 Camera::getParameters() const
{
LOGV("getParameters");
- String8 params = mCamera->getParameters();
+ String8 params;
+ sp <ICamera> c = mCamera;
+ if (c != 0) params = mCamera->getParameters();
return params;
}
@@ -252,6 +271,8 @@
LOGV("setFrameCallback");
mFrameCallback = cb;
mFrameCallbackCookie = cookie;
+ sp <ICamera> c = mCamera;
+ if (c == 0) return;
mCamera->setFrameCallbackFlag(frame_callback_flag);
}
diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp
index 2745f52..c8e6168 100644
--- a/libs/ui/Overlay.cpp
+++ b/libs/ui/Overlay.cpp
@@ -74,7 +74,7 @@
return mStatus;
}
-overlay_handle_t const* Overlay::getHandleRef() const {
+overlay_handle_t Overlay::getHandleRef() const {
if (mStatus != NO_ERROR) return NULL;
return mOverlayRef->mOverlayHandle;
}
@@ -112,7 +112,7 @@
{
}
-OverlayRef::OverlayRef(overlay_handle_t const* handle, const sp<IOverlay>& channel,
+OverlayRef::OverlayRef(overlay_handle_t handle, const sp<IOverlay>& channel,
uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs)
: mOverlayHandle(handle), mOverlayChannel(channel),
mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs),
@@ -126,7 +126,7 @@
/* FIXME: handles should be promoted to "real" API and be handled by
* the framework */
for (int i=0 ; i<mOverlayHandle->numFds ; i++) {
- close(mOverlayHandle->fds[i]);
+ close(mOverlayHandle->data[i]);
}
free((void*)mOverlayHandle);
}
@@ -141,16 +141,8 @@
uint32_t f = data.readInt32();
uint32_t ws = data.readInt32();
uint32_t hs = data.readInt32();
- /* FIXME: handles should be promoted to "real" API and be handled by
- * the framework */
- int numfd = data.readInt32();
- int numint = data.readInt32();
- overlay_handle_t* handle = (overlay_handle_t*)malloc(
- sizeof(overlay_handle_t) + numint*sizeof(int));
- for (int i=0 ; i<numfd ; i++)
- handle->fds[i] = data.readFileDescriptor();
- for (int i=0 ; i<numint ; i++)
- handle->data[i] = data.readInt32();
+ native_handle* handle = data.readNativeHandle(NULL, NULL);
+
result = new OverlayRef();
result->mOverlayHandle = handle;
result->mOverlayChannel = overlay;
@@ -171,14 +163,7 @@
reply->writeInt32(o->mFormat);
reply->writeInt32(o->mWidthStride);
reply->writeInt32(o->mHeightStride);
- /* FIXME: handles should be promoted to "real" API and be handled by
- * the framework */
- reply->writeInt32(o->mOverlayHandle->numFds);
- reply->writeInt32(o->mOverlayHandle->numInts);
- for (int i=0 ; i<o->mOverlayHandle->numFds ; i++)
- reply->writeFileDescriptor(o->mOverlayHandle->fds[i]);
- for (int i=0 ; i<o->mOverlayHandle->numInts ; i++)
- reply->writeInt32(o->mOverlayHandle->data[i]);
+ reply->writeNativeHandle(*(o->mOverlayHandle));
} else {
reply->writeStrongBinder(NULL);
}