diff options
author | qimengp <qimengp@codeaurora.org> | 2017-06-20 14:54:59 +0800 |
---|---|---|
committer | qimengp <qimengp@codeaurora.org> | 2017-07-19 12:02:35 +0800 |
commit | 1e1528b1ffff9ea88713ddd208ef43d1de0645a6 (patch) | |
tree | ce3fc6701291010e32cdef23ea622688e4b97da5 /src | |
parent | f90319b0d26d9dd1a6e0cf5a6e801adc300eb645 (diff) | |
download | android_packages_apps_Snap-1e1528b1ffff9ea88713ddd208ef43d1de0645a6.tar.gz android_packages_apps_Snap-1e1528b1ffff9ea88713ddd208ef43d1de0645a6.tar.bz2 android_packages_apps_Snap-1e1528b1ffff9ea88713ddd208ef43d1de0645a6.zip |
SnapdragonCamera: Add setprop WIDTHxHEIGHT for preview size support
Modify the setprop from set int to string to adapt more requirement
Change-Id: If961869951c20125cafa7d61ded74f8166faaa80
CRs-Fixed: 2070387
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/CaptureModule.java | 55 | ||||
-rwxr-xr-x | src/com/android/camera/PhotoModule.java | 45 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/util/PersistUtil.java | 20 |
3 files changed, 42 insertions, 78 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 6b9c6869e..eb52b36e6 100644..100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -2314,42 +2314,7 @@ public class CaptureModule implements CameraModule, PhotoController, updateMaxVideoDuration(); } - private Size checkOverridePreviewSize(int cur_width, int cur_height) { - int preview_resolution = PersistUtil.getCameraPreviewSize(); - switch (preview_resolution) { - case 1: { - cur_width = 640; - cur_height = 480; - Log.v(TAG, "Preview resolution hardcoded to 640x480"); - break; - } - case 2: { - cur_width = 720; - cur_height = 480; - Log.v(TAG, "Preview resolution hardcoded to 720x480"); - break; - } - case 3: { - cur_width = 1280; - cur_height = 720; - Log.v(TAG, "Preview resolution hardcoded to 1280x720"); - break; - } - case 4: { - cur_width = 1920; - cur_height = 1080; - Log.v(TAG, "Preview resolution hardcoded to 1920x1080"); - break; - } - default: { - Log.v(TAG, "Preview resolution as per Snapshot aspect ratio"); - break; - } - } - return new Size(cur_width, cur_height); - } private void updatePreviewSize() { - int preview_resolution = PersistUtil.getCameraPreviewSize(); int width = mPreviewSize.getWidth(); int height = mPreviewSize.getHeight(); @@ -2359,7 +2324,16 @@ public class CaptureModule implements CameraModule, PhotoController, width = mVideoSize.getWidth(); height = mVideoSize.getHeight(); } - mPreviewSize = checkOverridePreviewSize(width, height); + + Point previewSize = PersistUtil.getCameraPreviewSize(); + if (previewSize != null) { + width = previewSize.x; + height = previewSize.y; + } + + Log.d(TAG, "updatePreviewSize final preview size = " + width + ", " + height); + + mPreviewSize = new Size(width, height); mUI.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } @@ -3069,8 +3043,13 @@ public class CaptureModule implements CameraModule, PhotoController, Size[] prevSizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), MediaRecorder.class); mVideoPreviewSize = getOptimalPreviewSize(mVideoSize, prevSizes); - mVideoPreviewSize = checkOverridePreviewSize(mVideoPreviewSize.getWidth(), - mVideoPreviewSize.getHeight()); + + Point previewSize = PersistUtil.getCameraPreviewSize(); + if (previewSize != null) { + mVideoPreviewSize = new Size(previewSize.x, previewSize.y); + } + Log.d(TAG, "updatePreviewSize final preview size = " + mVideoPreviewSize.getWidth() + + ", " + mVideoPreviewSize.getHeight()); } private void updateVideoSnapshotSize() { diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index a9f9af91e..7f656648f 100755 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -29,6 +29,7 @@ import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; +import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.hardware.Camera.CameraInfo; @@ -84,6 +85,7 @@ import com.android.camera.ui.RotateTextToast; import com.android.camera.util.ApiHelper; import com.android.camera.util.CameraUtil; import com.android.camera.util.GcamHelper; +import com.android.camera.util.PersistUtil; import com.android.camera.util.UsageStatistics; import org.codeaurora.snapcam.R; import org.codeaurora.snapcam.wrapper.ParametersWrapper; @@ -4043,44 +4045,15 @@ public class PhotoModule Size optimalSize = CameraUtil.getOptimalPreviewSize(mActivity, sizes, (double) size.width / size.height); - //Read Preview Resolution from adb command - //value: 0(default) - Default value as per snapshot aspect ratio - //value: 1 - 640x480 - //value: 2 - 720x480 - //value: 3 - 1280x720 - //value: 4 - 1920x1080 - int preview_resolution = SystemProperties.getInt("persist.sys.camera.preview.size", 0); - switch (preview_resolution) { - case 1: { - optimalSize.width = 640; - optimalSize.height = 480; - Log.v(TAG, "Preview resolution hardcoded to 640x480"); - break; - } - case 2: { - optimalSize.width = 720; - optimalSize.height = 480; - Log.v(TAG, "Preview resolution hardcoded to 720x480"); - break; - } - case 3: { - optimalSize.width = 1280; - optimalSize.height = 720; - Log.v(TAG, "Preview resolution hardcoded to 1280x720"); - break; - } - case 4: { - optimalSize.width = 1920; - optimalSize.height = 1080; - Log.v(TAG, "Preview resolution hardcoded to 1920x1080"); - break; - } - default: { - Log.v(TAG, "Preview resolution as per Snapshot aspect ratio"); - break; - } + Point previewSize = PersistUtil.getCameraPreviewSize(); + if (previewSize != null) { + optimalSize.width = previewSize.x; + optimalSize.height = previewSize.y; } + Log.d(TAG, "updateCameraParametersPreference final preview size = " + + optimalSize.width + ", " + optimalSize.height); + Size original = mParameters.getPreviewSize(); if (!original.equals(optimalSize)) { mParameters.setPreviewSize(optimalSize.width, optimalSize.height); diff --git a/src/com/android/camera/util/PersistUtil.java b/src/com/android/camera/util/PersistUtil.java index 3b80a9b2e..c8df6006a 100644..100755 --- a/src/com/android/camera/util/PersistUtil.java +++ b/src/com/android/camera/util/PersistUtil.java @@ -28,7 +28,10 @@ */ package com.android.camera.util; +import android.graphics.Point; import android.os.SystemProperties; +import android.text.TextUtils; +import android.util.Log; public class PersistUtil { @@ -45,8 +48,8 @@ public class PersistUtil { SystemProperties.getBoolean("persist.vendor.camera.perf.skip_memck", false); private static final int PERSIST_LONGSHOT_SHOT_LIMIT = SystemProperties.getInt("persist.vendor.camera.longshot.shotnum", 50); - private static final int PERSIST_CAMERA_PREVIEW_SIZE = - SystemProperties.getInt("persist.vendor.camera.preview.size", 0); + private static final String PERSIST_CAMERA_PREVIEW_SIZE = + SystemProperties.get("persist.vendor.camera.preview.size", ""); private static final boolean PERSIST_CAMERA_CAMERA2 = SystemProperties.getBoolean("persist.vendor.camera.camera2", false); private static final boolean PERSIST_CAMERA_ZSL = @@ -85,8 +88,17 @@ public class PersistUtil { return PERSIST_LONGSHOT_SHOT_LIMIT; } - public static int getCameraPreviewSize() { - return PERSIST_CAMERA_PREVIEW_SIZE; + public static Point getCameraPreviewSize() { + Point result = null; + if (PERSIST_CAMERA_PREVIEW_SIZE != null) { + String[] sourceStrArray = PERSIST_CAMERA_PREVIEW_SIZE.split("x"); + if (sourceStrArray != null && sourceStrArray.length >= 2) { + result = new Point(); + result.x = Integer.parseInt(sourceStrArray[0]); + result.y = Integer.parseInt(sourceStrArray[1]); + } + } + return result; } public static boolean getCamera2Mode() { |