diff options
Diffstat (limited to 'services/camera/libcameraservice/Camera2Client.cpp')
| -rw-r--r-- | services/camera/libcameraservice/Camera2Client.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 59ec6b6..948b59f 100644 --- a/services/camera/libcameraservice/Camera2Client.cpp +++ b/services/camera/libcameraservice/Camera2Client.cpp @@ -47,9 +47,10 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService, const sp<ICameraClient>& cameraClient, int cameraId, int cameraFacing, - int clientPid): + int clientPid, + int servicePid): Client(cameraService, cameraClient, - cameraId, cameraFacing, clientPid), + cameraId, cameraFacing, clientPid, servicePid), mSharedCameraClient(cameraClient), mParameters(cameraId, cameraFacing) { @@ -64,10 +65,10 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService, status_t Camera2Client::checkPid(const char* checkLocation) const { int callingPid = getCallingPid(); - if (callingPid == mClientPid) return NO_ERROR; + if (callingPid == mClientPid || callingPid == mServicePid) return NO_ERROR; ALOGE("%s: attempt to use a locked camera from a different process" - " (old pid %d, new pid %d)", checkLocation, mClientPid, callingPid); + " (old pid %d, new pid %d, servicePid %d)", checkLocation, mClientPid, callingPid, mServicePid); return PERMISSION_DENIED; } @@ -138,8 +139,15 @@ Camera2Client::~Camera2Client() { mDestructionStarted = true; - SharedParameters::Lock l(mParameters); - if (l.mParameters.state != Parameters::DISCONNECTED) { + Parameters::State state; + // warning: + // holding on to locks more than necessary may be hazardous to your health + { + SharedParameters::Lock l(mParameters); + state = l.mParameters.state; + } + + if (state != Parameters::DISCONNECTED) { // Rewrite mClientPid to allow shutdown by CameraService mClientPid = getCallingPid(); disconnect(); |
