summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/Camera2Client.cpp
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2012-10-02 16:05:11 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-03 11:39:08 -0700
commit8dcdb9553defafa1166c64b496e1ee390e4eadfa (patch)
tree4aa76e6945e95aac4538a1b49475efc932fb114c /services/camera/libcameraservice/Camera2Client.cpp
parent0cb290b2304ef582a5afa9a45a4594944e89156e (diff)
downloadframeworks_av-8dcdb9553defafa1166c64b496e1ee390e4eadfa.zip
frameworks_av-8dcdb9553defafa1166c64b496e1ee390e4eadfa.tar.gz
frameworks_av-8dcdb9553defafa1166c64b496e1ee390e4eadfa.tar.bz2
Camera2: Handle client processes dying by closing camera resources
CameraService now subscribes to binder death notifications for each client, and disconnects the client if the death happened without cleanly shutting down the client first. Bug: 7258314 Change-Id: I7803836b589fd8f0dfe00f6c28a707b82012e751
Diffstat (limited to 'services/camera/libcameraservice/Camera2Client.cpp')
-rw-r--r--services/camera/libcameraservice/Camera2Client.cpp20
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();