diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/camera/libcameraservice/Camera2Client.cpp | 32 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraClient.cpp | 8 | ||||
-rw-r--r-- | services/camera/libcameraservice/camera2/Parameters.cpp | 3 |
3 files changed, 18 insertions, 25 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 7a6e344..0ab4e8c 100644 --- a/services/camera/libcameraservice/Camera2Client.cpp +++ b/services/camera/libcameraservice/Camera2Client.cpp @@ -65,10 +65,10 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService, status_t Camera2Client::checkPid(const char* checkLocation) const { int callingPid = getCallingPid(); - if (callingPid == mClientPid || callingPid == mServicePid) return NO_ERROR; + if (callingPid == mClientPid) return NO_ERROR; ALOGE("%s: attempt to use a locked camera from a different process" - " (old pid %d, new pid %d, servicePid %d)", checkLocation, mClientPid, callingPid, mServicePid); + " (old pid %d, new pid %d)", checkLocation, mClientPid, callingPid); return PERMISSION_DENIED; } @@ -139,19 +139,7 @@ Camera2Client::~Camera2Client() { mDestructionStarted = true; - 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(); - } + disconnect(); ALOGI("Camera %d: Closed", mCameraId); } @@ -372,7 +360,10 @@ void Camera2Client::disconnect() { ATRACE_CALL(); Mutex::Autolock icl(mICameraLock); status_t res; - if ( (res = checkPid(__FUNCTION__) ) != OK) return; + + // Allow both client and the media server to disconnect at all times + int callingPid = getCallingPid(); + if (callingPid != mClientPid && callingPid != mServicePid) return; if (mDevice == 0) return; @@ -382,6 +373,7 @@ void Camera2Client::disconnect() { { SharedParameters::Lock l(mParameters); + if (l.mParameters.state == Parameters::DISCONNECTED) return; l.mParameters.state = Parameters::DISCONNECTED; } @@ -462,9 +454,13 @@ status_t Camera2Client::unlock() { ALOGV("%s: Camera %d: Unlock call from pid %d; current client pid %d", __FUNCTION__, mCameraId, getCallingPid(), mClientPid); - // TODO: Check for uninterruptable conditions - if (mClientPid == getCallingPid()) { + SharedParameters::Lock l(mParameters); + if (l.mParameters.state == Parameters::RECORD || + l.mParameters.state == Parameters::VIDEO_SNAPSHOT) { + ALOGD("Not allowed to unlock camera during recording."); + return INVALID_OPERATION; + } mClientPid = 0; mCameraClient.clear(); mSharedCameraClient.clear(); diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp index 5b59ef9..b930c02 100644 --- a/services/camera/libcameraservice/CameraClient.cpp +++ b/services/camera/libcameraservice/CameraClient.cpp @@ -73,6 +73,7 @@ status_t CameraClient::initialize(camera_module_t *module) { if (res != OK) { ALOGE("%s: Camera %d: unable to initialize device: %s (%d)", __FUNCTION__, mCameraId, strerror(-res), res); + mHardware.clear(); return NO_INIT; } @@ -101,8 +102,6 @@ CameraClient::~CameraClient() { int callingPid = getCallingPid(); LOG1("CameraClient::~CameraClient E (pid %d, this %p)", callingPid, this); - // set mClientPid to let disconnet() tear down the hardware - mClientPid = callingPid; disconnect(); LOG1("CameraClient::~CameraClient X (pid %d, this %p)", callingPid, this); } @@ -124,7 +123,7 @@ status_t CameraClient::dump(int fd, const Vector<String16>& args) { status_t CameraClient::checkPid() const { int callingPid = getCallingPid(); - if (callingPid == mClientPid || callingPid == mServicePid) return NO_ERROR; + if (callingPid == mClientPid) return NO_ERROR; ALOGW("attempt to use a locked camera from a different process" " (old pid %d, new pid %d)", mClientPid, callingPid); @@ -218,7 +217,8 @@ void CameraClient::disconnect() { LOG1("disconnect E (pid %d)", callingPid); Mutex::Autolock lock(mLock); - if (checkPid() != NO_ERROR) { + // Allow both client and the media server to disconnect at all times + if (callingPid != mClientPid && callingPid != mServicePid) { ALOGW("different client - don't disconnect"); return; } diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp index 05494d3..3c679da 100644 --- a/services/camera/libcameraservice/camera2/Parameters.cpp +++ b/services/camera/libcameraservice/camera2/Parameters.cpp @@ -1739,9 +1739,6 @@ status_t Parameters::updateRequest(CameraMetadata *request) const { reqMeteringAreas, reqMeteringAreasSize); if (res != OK) return res; - res = request->update(ANDROID_CONTROL_AWB_REGIONS, - reqMeteringAreas, reqMeteringAreasSize); - if (res != OK) return res; delete[] reqMeteringAreas; /* don't include jpeg thumbnail size - it's valid for |