diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2015-02-17 20:18:47 -0800 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2015-03-18 22:21:21 -0700 |
commit | cc776718c0be7c31fe5ab4fc1446d377be60369f (patch) | |
tree | c5f0633e27f6c36b938f6a57fea544996ac3d5ae /services/camera/libcameraservice/CameraFlashlight.cpp | |
parent | f9d19514b3e620b6339c98a442da833a702915ed (diff) | |
download | frameworks_av-cc776718c0be7c31fe5ab4fc1446d377be60369f.zip frameworks_av-cc776718c0be7c31fe5ab4fc1446d377be60369f.tar.gz frameworks_av-cc776718c0be7c31fe5ab4fc1446d377be60369f.tar.bz2 |
camera2: Add camera client eviction enforcement.
- This updates the CameraService to implement client
eviction behavior based on process priority.
Bug: 19186859
Change-Id: I646939b1cdf1a2237c4e5044164d55a2542cf36e
Diffstat (limited to 'services/camera/libcameraservice/CameraFlashlight.cpp')
-rw-r--r-- | services/camera/libcameraservice/CameraFlashlight.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index 8e894cd..6c237aa 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -110,6 +110,20 @@ status_t CameraFlashlight::setTorchMode(const String8& cameraId, bool enabled) { status_t res = OK; Mutex::Autolock l(mLock); + if (mOpenedCameraIds.indexOf(cameraId) != NAME_NOT_FOUND) { + // This case is needed to avoid state corruption during the following call sequence: + // CameraService::setTorchMode for camera ID 0 begins, does torch status checks + // CameraService::connect for camera ID 0 begins, calls prepareDeviceOpen, ends + // CameraService::setTorchMode for camera ID 0 continues, calls + // CameraFlashlight::setTorchMode + + // TODO: Move torch status checks and state updates behind this CameraFlashlight lock + // to avoid other similar race conditions. + ALOGE("%s: Camera device %s is in use, cannot set torch mode.", + __FUNCTION__, cameraId.string()); + return -EBUSY; + } + if (mFlashControl == NULL) { if (enabled == false) { return OK; |