summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravank <sravank1@codeaurora.org>2010-08-18 19:58:36 +0530
committerSteve Kondik <shade@chemlab.org>2010-09-05 09:37:09 -0400
commite3a089d5eb5c60676241523008250a8494d47e57 (patch)
treea5e85ea52494f13ca92b70ffcc05c4e3980d36ec
parente080c01b997a55e2fe85c01a3374a23165b7adb8 (diff)
downloadframeworks_base-e3a089d5eb5c60676241523008250a8494d47e57.zip
frameworks_base-e3a089d5eb5c60676241523008250a8494d47e57.tar.gz
frameworks_base-e3a089d5eb5c60676241523008250a8494d47e57.tar.bz2
Camera : Clean up old camera client properly
Terminate the old client connection properly when an ANR occurs and the user requests to re-launch the camera application. CRs-fixed: 250354 Change-Id: I9989aa32ff1ecd1a3a49a3155a27d02a18a5a87d
-rwxr-xr-x[-rw-r--r--]camera/libcameraservice/CameraService.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 0ac089f..3cb3ce5 100644..100755
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -81,6 +81,8 @@ static int getCallingPid() {
return IPCThreadState::self()->getCallingPid();
}
+static bool cleanOldclient = false;
+
// ----------------------------------------------------------------------------
void CameraService::instantiate() {
@@ -129,8 +131,14 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
currentClient->mClientPid, currentCameraClient->asBinder().get());
if (kill(currentClient->mClientPid, 0) == -1 && errno == ESRCH) {
LOGV("The old client is dead!");
+ LOGE("forcefully terminating old client.. ref count ", currentClient->getStrongCount());
+ cleanOldclient = true;
+ mServiceLock.unlock();
+
+ currentClient->disconnect();
+ cleanOldclient = false;
}
- return client;
+ else return client;
}
} else {
// can't promote, the previous client has died...
@@ -144,7 +152,7 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
LOGV("Still have client, rejected");
return client;
}
-
+ LOGV("creating new client");
// create a new Client object
client = new Client(this, cameraClient, callingPid);
mClient = client;
@@ -396,12 +404,14 @@ void CameraService::Client::disconnect()
LOGV("Client::disconnect() E (pid %d client %p)",
callingPid, getCameraClient()->asBinder().get());
- Mutex::Autolock lock(mLock);
+ if(!cleanOldclient)
+ Mutex::Autolock lock(mLock);
+
if (mClientPid <= 0) {
LOGV("camera is unlocked (mClientPid = %d), don't tear down hardware", mClientPid);
return;
}
- if (checkPid() != NO_ERROR) {
+ if (!cleanOldclient && checkPid() != NO_ERROR) {
LOGV("Different client - don't disconnect");
return;
}