diff options
| author | Chien-Yu Chen <cychen@google.com> | 2015-09-01 14:16:44 -0700 | 
|---|---|---|
| committer | The Android Automerger <android-build@google.com> | 2015-09-02 14:04:12 -0700 | 
| commit | 66296c4e99da5f2dd0a3dbf048be0d6ffc49a559 (patch) | |
| tree | 2a18aa7589f908c300a166bedbc978f2b8aef351 /services/camera | |
| parent | 5e646341aa496c857a6740d9c802b6b06dae8a02 (diff) | |
| download | frameworks_av-66296c4e99da5f2dd0a3dbf048be0d6ffc49a559.zip frameworks_av-66296c4e99da5f2dd0a3dbf048be0d6ffc49a559.tar.gz frameworks_av-66296c4e99da5f2dd0a3dbf048be0d6ffc49a559.tar.bz2  | |
Camera: Fix flashlight deadlock
Use a dedicated mutex for torch UID map so it won't cause a deadlock
after flashlight app gets killed while the torch is on.
Bug: 23722318
Change-Id: I228377aa0412052d56b6b948361d9abaecbbc686
Diffstat (limited to 'services/camera')
| -rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 4 | ||||
| -rw-r--r-- | services/camera/libcameraservice/CameraService.h | 4 | 
2 files changed, 5 insertions, 3 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 43a8ec4..9a1101a 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -363,7 +363,7 @@ void CameraService::onTorchStatusChangedLocked(const String8& cameraId,      {          // Update battery life logging for flashlight -        Mutex::Autolock al(mTorchClientMapMutex); +        Mutex::Autolock al(mTorchUidMapMutex);          auto iter = mTorchUidMap.find(cameraId);          if (iter != mTorchUidMap.end()) {              int oldUid = iter->second.second; @@ -1262,7 +1262,7 @@ status_t CameraService::setTorchMode(const String16& cameraId, bool enabled,      {          // Update UID map - this is used in the torch status changed callbacks, so must be done          // before setTorchMode -        Mutex::Autolock al(mTorchClientMapMutex); +        Mutex::Autolock al(mTorchUidMapMutex);          if (mTorchUidMap.find(id) == mTorchUidMap.end()) {              mTorchUidMap[id].first = uid;              mTorchUidMap[id].second = uid; diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 7f4d43f..b56c161 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -648,8 +648,10 @@ private:      sp<CameraFlashlight> mFlashlight;      // guard mTorchStatusMap      Mutex                mTorchStatusMutex; -    // guard mTorchClientMap, mTorchUidMap +    // guard mTorchClientMap      Mutex                mTorchClientMapMutex; +    // guard mTorchUidMap +    Mutex                mTorchUidMapMutex;      // camera id -> torch status      KeyedVector<String8, ICameraServiceListener::TorchStatus> mTorchStatusMap;      // camera id -> torch client binder  | 
