From e6800cea0678dbc0bf697b44c3e4548b0253085c Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Mon, 4 Mar 2013 17:25:57 -0800 Subject: Camera: Make ProCamera connect take the same paths as Camera connect * ProCamera uses the app ops manager * Refactored connect calls to be as common as possible * Removed some useless not implemented function calls in ProClient Change-Id: I5dab30d20f0c202a494a07b2cfe4c1fa04a2a076 --- services/camera/libcameraservice/CameraService.h | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index d7a336c..c5e495f 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -108,6 +108,7 @@ public: virtual void disconnect() = 0; + // Return the remote callback binder object (e.g. IProCameraCallbacks) wp getRemote() { return mRemoteBinder; } @@ -247,34 +248,24 @@ public: return mRemoteCallback; } - // BasicClient implementation - virtual status_t initialize(camera_module_t *module); - /*** IProCamera implementation ***/ + virtual status_t connect(const sp& callbacks) + = 0; + virtual status_t exclusiveTryLock() = 0; + virtual status_t exclusiveLock() = 0; + virtual status_t exclusiveUnlock() = 0; - - virtual status_t connect( - const sp& callbacks); - virtual void disconnect(); - - virtual status_t exclusiveTryLock(); - virtual status_t exclusiveLock(); - virtual status_t exclusiveUnlock(); - - virtual bool hasExclusiveLock(); + virtual bool hasExclusiveLock() = 0; // Note that the callee gets a copy of the metadata. virtual int submitRequest(camera_metadata_t* metadata, - bool streaming = false); - virtual status_t cancelRequest(int requestId); - - virtual status_t requestStream(int streamId); - virtual status_t cancelStream(int streamId); + bool streaming = false) = 0; + virtual status_t cancelRequest(int requestId) = 0; // Callbacks from camera service - virtual void onExclusiveLockStolen(); + virtual void onExclusiveLockStolen() = 0; protected: virtual void notifyError(); @@ -287,6 +278,22 @@ private: // Delay-load the Camera HAL module virtual void onFirstRef(); + // Step 1. Check if we can connect, before we acquire the service lock. + bool validateConnect(int cameraId, + /*inout*/ + int& clientUid) const; + + // Step 2. Check if we can connect, after we acquire the service lock. + bool canConnectUnsafe(int cameraId, + const String16& clientPackageName, + const sp& remoteCallback, + /*out*/ + sp &client); + + // When connection is successful, initialize client and track its death + bool connectFinishUnsafe(const sp& client, + const sp& clientBinder); + virtual sp getClientByRemote(const wp& cameraClient); Mutex mServiceLock; -- cgit v1.1