diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2014-09-25 14:48:28 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2014-09-26 11:20:47 -0700 |
commit | 85ea794c06e4ee8f9eaa03cb54ace3fd30cc5b34 (patch) | |
tree | 481ae48277ce0ea41780a75ca5283b42b928f660 | |
parent | a21b654eaed87e87eab4cf2596a420675ab4c6e1 (diff) | |
download | frameworks_av-85ea794c06e4ee8f9eaa03cb54ace3fd30cc5b34.zip frameworks_av-85ea794c06e4ee8f9eaa03cb54ace3fd30cc5b34.tar.gz frameworks_av-85ea794c06e4ee8f9eaa03cb54ace3fd30cc5b34.tar.bz2 |
Camera1 shim: If there's no flash, the keys need to be null.
Previously, we set FLASH_MODE_OFF for FLASH_MODE when a flash unit
isn't available. However, per the API documentation, the key has to
be null instead.
- Make sure that the flash mode and supported flash mode keys are null
if there's no flash unit on start
- Don't set flash mode in later setParameters calls if there is no
flash unit
- Map NULL value for flash mode key to FLASH_MODE_OFF for internal
consistency.
Bug: 17660716
Change-Id: I3033682f0b882b8c2004114e2afef31662caebda
-rw-r--r-- | services/camera/libcameraservice/api1/client2/Parameters.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp index aa9d746..9818c96 100644 --- a/services/camera/libcameraservice/api1/client2/Parameters.cpp +++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp @@ -643,11 +643,10 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) { params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, supportedFlashModes); } else { - flashMode = Parameters::FLASH_MODE_OFF; - params.set(CameraParameters::KEY_FLASH_MODE, - CameraParameters::FLASH_MODE_OFF); - params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, - CameraParameters::FLASH_MODE_OFF); + // No flash means null flash mode and supported flash modes keys, so + // remove them just to be safe + params.remove(CameraParameters::KEY_FLASH_MODE); + params.remove(CameraParameters::KEY_SUPPORTED_FLASH_MODES); } camera_metadata_ro_entry_t minFocusDistance = @@ -1617,7 +1616,9 @@ status_t Parameters::set(const String8& paramString) { if (validatedParams.flashMode != flashMode) { camera_metadata_ro_entry_t flashAvailable = staticInfo(ANDROID_FLASH_INFO_AVAILABLE, 1, 1); - if (!flashAvailable.data.u8[0] && + bool isFlashAvailable = + flashAvailable.data.u8[0] == ANDROID_FLASH_INFO_AVAILABLE_TRUE; + if (!isFlashAvailable && validatedParams.flashMode != Parameters::FLASH_MODE_OFF) { ALOGE("%s: Requested flash mode \"%s\" is not supported: " "No flash on device", __FUNCTION__, @@ -1642,9 +1643,11 @@ status_t Parameters::set(const String8& paramString) { newParams.get(CameraParameters::KEY_FLASH_MODE)); return BAD_VALUE; } - // Update in case of override - newParams.set(CameraParameters::KEY_FLASH_MODE, - flashModeEnumToString(validatedParams.flashMode)); + // Update in case of override, but only if flash is supported + if (isFlashAvailable) { + newParams.set(CameraParameters::KEY_FLASH_MODE, + flashModeEnumToString(validatedParams.flashMode)); + } } // WHITE_BALANCE @@ -2386,7 +2389,7 @@ Parameters::Parameters::flashMode_t Parameters::flashModeStringToEnum( const char *flashMode) { return !flashMode ? - Parameters::FLASH_MODE_INVALID : + Parameters::FLASH_MODE_OFF : !strcmp(flashMode, CameraParameters::FLASH_MODE_OFF) ? Parameters::FLASH_MODE_OFF : !strcmp(flashMode, CameraParameters::FLASH_MODE_AUTO) ? |