Merge change 5199 into donut
* changes: Only remove client after the hardware is teared down, so a new client is rejected before old client is done.
This commit is contained in:
@ -98,7 +98,7 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
|
|||||||
LOGD("CameraService::connect E (pid %d, client %p)", callingPid,
|
LOGD("CameraService::connect E (pid %d, client %p)", callingPid,
|
||||||
cameraClient->asBinder().get());
|
cameraClient->asBinder().get());
|
||||||
|
|
||||||
Mutex::Autolock lock(mLock);
|
Mutex::Autolock lock(mServiceLock);
|
||||||
sp<Client> client;
|
sp<Client> client;
|
||||||
if (mClient != 0) {
|
if (mClient != 0) {
|
||||||
sp<Client> currentClient = mClient.promote();
|
sp<Client> currentClient = mClient.promote();
|
||||||
@ -125,12 +125,13 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
|
|||||||
LOGD("New client (pid %d) connecting, old reference was dangling...",
|
LOGD("New client (pid %d) connecting, old reference was dangling...",
|
||||||
callingPid);
|
callingPid);
|
||||||
mClient.clear();
|
mClient.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mUsers > 0) {
|
if (mUsers > 0) {
|
||||||
LOGD("Still have client, rejected");
|
LOGD("Still have client, rejected");
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a new Client object
|
// create a new Client object
|
||||||
client = new Client(this, cameraClient, callingPid);
|
client = new Client(this, cameraClient, callingPid);
|
||||||
@ -152,7 +153,7 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient)
|
|||||||
// destructor won't be called with the lock held.
|
// destructor won't be called with the lock held.
|
||||||
sp<Client> client;
|
sp<Client> client;
|
||||||
|
|
||||||
Mutex::Autolock lock(mLock);
|
Mutex::Autolock lock(mServiceLock);
|
||||||
|
|
||||||
if (mClient == 0) {
|
if (mClient == 0) {
|
||||||
// This happens when we have already disconnected.
|
// This happens when we have already disconnected.
|
||||||
@ -390,8 +391,6 @@ void CameraService::Client::disconnect()
|
|||||||
// from the user directly, or called by the destructor.
|
// from the user directly, or called by the destructor.
|
||||||
if (mHardware == 0) return;
|
if (mHardware == 0) return;
|
||||||
|
|
||||||
mCameraService->removeClient(mCameraClient);
|
|
||||||
|
|
||||||
LOGD("hardware teardown");
|
LOGD("hardware teardown");
|
||||||
// Before destroying mHardware, we must make sure it's in the
|
// Before destroying mHardware, we must make sure it's in the
|
||||||
// idle state.
|
// idle state.
|
||||||
@ -402,6 +401,7 @@ void CameraService::Client::disconnect()
|
|||||||
mHardware->release();
|
mHardware->release();
|
||||||
mHardware.clear();
|
mHardware.clear();
|
||||||
|
|
||||||
|
mCameraService->removeClient(mCameraClient);
|
||||||
mCameraService->decUsers();
|
mCameraService->decUsers();
|
||||||
|
|
||||||
LOGD("Client::disconnect() X (pid %d)", callingPid);
|
LOGD("Client::disconnect() X (pid %d)", callingPid);
|
||||||
@ -661,7 +661,7 @@ sp<CameraService::Client> CameraService::Client::getClientFromCookie(void* user)
|
|||||||
sp<Client> client = 0;
|
sp<Client> client = 0;
|
||||||
CameraService *service = static_cast<CameraService*>(user);
|
CameraService *service = static_cast<CameraService*>(user);
|
||||||
if (service != NULL) {
|
if (service != NULL) {
|
||||||
Mutex::Autolock ourLock(service->mLock);
|
Mutex::Autolock ourLock(service->mServiceLock);
|
||||||
if (service->mClient != 0) {
|
if (service->mClient != 0) {
|
||||||
client = service->mClient.promote();
|
client = service->mClient.promote();
|
||||||
if (client == 0) {
|
if (client == 0) {
|
||||||
@ -1104,7 +1104,7 @@ status_t CameraService::dump(int fd, const Vector<String16>& args)
|
|||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
write(fd, result.string(), result.size());
|
write(fd, result.string(), result.size());
|
||||||
} else {
|
} else {
|
||||||
AutoMutex lock(&mLock);
|
AutoMutex lock(&mServiceLock);
|
||||||
if (mClient != 0) {
|
if (mClient != 0) {
|
||||||
sp<Client> currentClient = mClient.promote();
|
sp<Client> currentClient = mClient.promote();
|
||||||
sprintf(buffer, "Client (%p) PID: %d\n",
|
sprintf(buffer, "Client (%p) PID: %d\n",
|
||||||
|
@ -199,7 +199,7 @@ private:
|
|||||||
virtual void incUsers();
|
virtual void incUsers();
|
||||||
virtual void decUsers();
|
virtual void decUsers();
|
||||||
|
|
||||||
mutable Mutex mLock;
|
mutable Mutex mServiceLock;
|
||||||
wp<Client> mClient;
|
wp<Client> mClient;
|
||||||
|
|
||||||
#if DEBUG_HEAP_LEAKS
|
#if DEBUG_HEAP_LEAKS
|
||||||
|
Reference in New Issue
Block a user