diff options
Diffstat (limited to 'services/camera/libcameraservice/api1/client2/Parameters.cpp')
-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) ? |