diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2012-10-10 13:07:01 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-10 13:07:01 -0700 |
commit | 4e5e64e76a5db351b852109dd288953a4eaaad38 (patch) | |
tree | 7e6e79c5dd9650877d7552f690e23621372b8095 /services | |
parent | c59703111ee9e7451150a2d5190220398193da40 (diff) | |
parent | 50016d7e0f61bfbcf7eb490725d954db802a034e (diff) | |
download | frameworks_av-4e5e64e76a5db351b852109dd288953a4eaaad38.zip frameworks_av-4e5e64e76a5db351b852109dd288953a4eaaad38.tar.gz frameworks_av-4e5e64e76a5db351b852109dd288953a4eaaad38.tar.bz2 |
am e44d7f83: am c0379204: Camera: Limit valid caller PIDs for camera clients.
* commit 'e44d7f83a4d04b90417684d74f18ad8c703b981a':
Camera: Limit valid caller PIDs for camera clients.
Diffstat (limited to 'services')
-rw-r--r-- | services/camera/libcameraservice/Camera2Client.cpp | 24 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraClient.cpp | 7 |
2 files changed, 11 insertions, 20 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 7a6e344..cd9da42 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; } diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp index 7e199fa..b930c02 100644 --- a/services/camera/libcameraservice/CameraClient.cpp +++ b/services/camera/libcameraservice/CameraClient.cpp @@ -102,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); } @@ -125,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); @@ -219,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; } |