From 2fd2440d0175ca3e196b01b7541a9e0d4ed9a694 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Thu, 23 Feb 2012 19:01:00 -0800 Subject: Add a new camera open API that allows taking the ownership. The purpose is to let face unlock always get the camera successfully. What happened was the camera applications may have opened the camera in onResume under the lock screen. This API lets face unlock take the camera from the camera application. A new permission will be added, so other applicatoins won't be able to take the camera from the face unlock. bug:5584464 Change-Id: Ib3d9dcbc2161815b68db42327dc01148453704c6 --- camera/Camera.cpp | 4 ++-- camera/ICameraService.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'camera') diff --git a/camera/Camera.cpp b/camera/Camera.cpp index d43cb0b..b81fe86 100644 --- a/camera/Camera.cpp +++ b/camera/Camera.cpp @@ -116,13 +116,13 @@ status_t Camera::getCameraInfo(int cameraId, return cs->getCameraInfo(cameraId, cameraInfo); } -sp Camera::connect(int cameraId) +sp Camera::connect(int cameraId, bool force, bool keep) { ALOGV("connect"); sp c = new Camera(); const sp& cs = getCameraService(); if (cs != 0) { - c->mCamera = cs->connect(c, cameraId); + c->mCamera = cs->connect(c, cameraId, force, keep); } if (c->mCamera != 0) { c->mCamera->asBinder()->linkToDeath(c); diff --git a/camera/ICameraService.cpp b/camera/ICameraService.cpp index 85f1a29..c74298a 100644 --- a/camera/ICameraService.cpp +++ b/camera/ICameraService.cpp @@ -56,12 +56,15 @@ public: } // connect to camera service - virtual sp connect(const sp& cameraClient, int cameraId) + virtual sp connect(const sp& cameraClient, int cameraId, + bool force, bool keep) { Parcel data, reply; data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); data.writeStrongBinder(cameraClient->asBinder()); data.writeInt32(cameraId); + data.writeInt32(force); + data.writeInt32(keep); remote()->transact(BnCameraService::CONNECT, data, &reply); return interface_cast(reply.readStrongBinder()); } @@ -93,7 +96,10 @@ status_t BnCameraService::onTransact( case CONNECT: { CHECK_INTERFACE(ICameraService, data, reply); sp cameraClient = interface_cast(data.readStrongBinder()); - sp camera = connect(cameraClient, data.readInt32()); + const int cameraId = data.readInt32(); + const int force = data.readInt32(); + const int keep = data.readInt32(); + sp camera = connect(cameraClient, cameraId, force, keep); reply->writeStrongBinder(camera->asBinder()); return NO_ERROR; } break; @@ -105,4 +111,3 @@ status_t BnCameraService::onTransact( // ---------------------------------------------------------------------------- }; // namespace android - -- cgit v1.1