diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-10-30 17:23:03 +0000 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-10-30 18:17:03 +0000 |
commit | 2d2391e849650ecab9dc3344b58b649c201293b2 (patch) | |
tree | 81ea9fb1a48a7096b6d8e560b31ce9135faf32ef /camera | |
parent | 51420db3f615a78736153165a4439d1f099e15b7 (diff) | |
download | device_samsung_smdk4412-common-2d2391e849650ecab9dc3344b58b649c201293b2.zip device_samsung_smdk4412-common-2d2391e849650ecab9dc3344b58b649c201293b2.tar.gz device_samsung_smdk4412-common-2d2391e849650ecab9dc3344b58b649c201293b2.tar.bz2 |
camera: Fix invalid parameter returns
The camera API expects invalid parameters not to return silently;
They should throw an exception, and set the bad parameter(s) back
to the last known good value.
Fixes android.hardware.cts.CameraTest#testImmediateZoom and
android.hardware.cts.CameraTest#testInvalidParameters
Change-Id: I6556369322b7560b0bb35fca57366b42579effbd
Diffstat (limited to 'camera')
-rw-r--r-- | camera/exynos_camera.c | 26 | ||||
-rw-r--r-- | camera/exynos_camera.h | 2 |
2 files changed, 24 insertions, 4 deletions
diff --git a/camera/exynos_camera.c b/camera/exynos_camera.c index b19ac6d..7b2875b 100644 --- a/camera/exynos_camera.c +++ b/camera/exynos_camera.c @@ -700,6 +700,13 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera, int force) if (preview_size_string != NULL) { sscanf(preview_size_string, "%dx%d", &preview_width, &preview_height); + if (preview_width < 0 && preview_height < 0) { + char reset_preview[128]; + sprintf(reset_preview, "%dx%d", exynos_camera->preview_width, exynos_camera->preview_height); + exynos_param_string_set(exynos_camera, "preview-size", + reset_preview); + return -EINVAL; + } if (preview_width != 0 && preview_width != exynos_camera->preview_width) exynos_camera->preview_width = preview_width; if (preview_height != 0 && preview_height != exynos_camera->preview_height) @@ -928,8 +935,11 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera, int force) focus_mode = FOCUS_MODE_CONTINOUS_VIDEO; else if (strcmp(focus_mode_string, "continuous-picture") == 0) focus_mode = FOCUS_MODE_CONTINOUS_PICTURE; - else - focus_mode = FOCUS_MODE_AUTO; + else { + exynos_param_string_set(exynos_camera, "focus-mode", + exynos_camera->raw_focus_mode); + return -EINVAL; + } } if (focus_mode != exynos_camera->focus_mode || force) { @@ -939,6 +949,7 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera, int force) } exynos_camera->focus_mode = focus_mode; + sprintf(exynos_camera->raw_focus_mode, "%s", focus_mode_string); } // Zoom @@ -952,6 +963,9 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera, int force) rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_ZOOM, zoom); if (rc < 0) ALOGE("%s: Unable to set camera zoom", __func__); + } else if (zoom > max_zoom) { + exynos_param_int_set(exynos_camera, "zoom", max_zoom); + return -EINVAL; } } @@ -995,11 +1009,15 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera, int force) flash_mode = FLASH_MODE_ON; else if (strcmp(flash_mode_string, "torch") == 0) flash_mode = FLASH_MODE_TORCH; - else - flash_mode = FLASH_MODE_AUTO; + else { + exynos_param_string_set(exynos_camera, "flash-mode", + exynos_camera->raw_flash_mode); + return -EINVAL; + } if (flash_mode != exynos_camera->flash_mode || force) { exynos_camera->flash_mode = flash_mode; + sprintf(exynos_camera->raw_flash_mode, "%s", flash_mode_string); rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_FLASH_MODE, flash_mode); if (rc < 0) ALOGE("%s:Unable to set flash mode", __func__); diff --git a/camera/exynos_camera.h b/camera/exynos_camera.h index 9e3d4f8..9895ef5 100644 --- a/camera/exynos_camera.h +++ b/camera/exynos_camera.h @@ -430,6 +430,8 @@ struct exynos_camera { int metering; int image_stabilization; char raw_focus_areas[PAGE_SIZE]; + char raw_focus_mode[64]; + char raw_flash_mode[64]; }; struct exynos_camera_addrs { |