diff options
author | Sai Kumar Sanagavarapu <ssanagav@codeaurora.org> | 2016-01-07 21:04:11 +0100 |
---|---|---|
committer | Daniel Hillenbrand <codeworkx@cyanogenmod.org> | 2016-01-07 13:26:05 -0800 |
commit | 04568574c6a24efcf8d15426d133979df557ea2e (patch) | |
tree | fac66607f4bb030ebaee7a0b7d235b183e92197e /src | |
parent | 6bf48d33cacbdcc1df5de29c5a07b1cf5bd1a974 (diff) | |
download | android_packages_apps_Snap-04568574c6a24efcf8d15426d133979df557ea2e.tar.gz android_packages_apps_Snap-04568574c6a24efcf8d15426d133979df557ea2e.tar.bz2 android_packages_apps_Snap-04568574c6a24efcf8d15426d133979df557ea2e.zip |
SnapdragonCamera: Query camcorder profiles before usage
1. Use generic camcorder profile query mechanism instead of
hardcoding profile enums in app.
2. Fix NPE during startpreview if mFocusManager is null.
Change-Id: I7bfc00f68f512c3029ca8ba75863583f1b376094
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 35 | ||||
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 3 | ||||
-rw-r--r-- | src/com/android/camera/VideoModule.java | 5 |
3 files changed, 38 insertions, 5 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index f6e4892cd..d97e3b86d 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -39,6 +39,7 @@ import org.codeaurora.snapcam.R; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.HashMap; import android.os.Build; import java.util.StringTokenizer; import android.os.SystemProperties; @@ -251,6 +252,22 @@ public class CameraSettings { public static String mKeyIso = null; public static String mKeyIsoValues = null; + public static final HashMap<String, Integer> + VIDEO_QUALITY_TABLE = new HashMap<String, Integer>(); + + static { + //video qualities + VIDEO_QUALITY_TABLE.put("4096x2160", CamcorderProfile.QUALITY_4KDCI); + VIDEO_QUALITY_TABLE.put("3840x2160", CamcorderProfile.QUALITY_2160P); + VIDEO_QUALITY_TABLE.put("1920x1080", CamcorderProfile.QUALITY_1080P); + VIDEO_QUALITY_TABLE.put("1280x720", CamcorderProfile.QUALITY_720P); + VIDEO_QUALITY_TABLE.put("720x480", CamcorderProfile.QUALITY_480P); + VIDEO_QUALITY_TABLE.put("640x480", CamcorderProfile.QUALITY_VGA); + VIDEO_QUALITY_TABLE.put("352x288", CamcorderProfile.QUALITY_CIF); + VIDEO_QUALITY_TABLE.put("320x240", CamcorderProfile.QUALITY_QVGA); + VIDEO_QUALITY_TABLE.put("176x144", CamcorderProfile.QUALITY_QCIF); + } + public CameraSettings(Activity activity, Parameters parameters, int cameraId, CameraInfo[] cameraInfo) { mContext = activity; @@ -320,7 +337,7 @@ public class CameraSettings { int cameraId, Parameters parameters) { // When launching the camera app first time, we will set the video quality // to the first one (i.e. highest quality) in the supported list - List<String> supported = getSupportedVideoQuality(cameraId,parameters); + List<String> supported = getSupportedVideoQualities(cameraId,parameters); assert (supported != null) : "No supported video quality is found"; return supported.get(0); } @@ -819,7 +836,7 @@ public class CameraSettings { } if (videoQuality != null) { - filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality( + filterUnsupportedOptions(group, videoQuality, getSupportedVideoQualities( mCameraId,mParameters)); } @@ -1227,6 +1244,20 @@ public class CameraSettings { return supported; } + public static ArrayList<String> getSupportedVideoQualities(int cameraId,Parameters parameters) { + ArrayList<String> supported = new ArrayList<String>(); + List<String> temp = sizeListToStringList(parameters.getSupportedVideoSizes()); + for (String videoSize : temp) { + if (VIDEO_QUALITY_TABLE.containsKey(videoSize)) { + int profile = VIDEO_QUALITY_TABLE.get(videoSize); + if (CamcorderProfile.hasProfile(cameraId, profile)) { + supported.add(videoSize); + } + } + } + return supported; + } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private static void getFineResolutionQuality(ArrayList<String> supported, int cameraId,Parameters parameters) { diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 78863230d..d55a16ffb 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -2654,7 +2654,8 @@ public class PhotoModule /** This can run on a background thread, so don't do UI updates here. Post any view updates to MainHandler or do it on onPreviewStarted() . */ private void startPreview() { - if (mPaused || mCameraDevice == null || mParameters == null) { + if (mPaused || (mCameraDevice == null) || (null == mFocusManager) || + (mParameters == null)) { return; } diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 28c62f360..9c3355cb6 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -854,7 +854,8 @@ public class VideoModule implements CameraModule, String defaultQuality = mActivity.getResources().getString( R.string.pref_video_quality_default); if (!defaultQuality.equals("")) { - if (CamcorderProfile.hasProfile(Integer.parseInt(defaultQuality))) { + if (CamcorderProfile.hasProfile( + CameraSettings.VIDEO_QUALITY_TABLE.get(defaultQuality))) { videoQuality = defaultQuality; } } else { @@ -864,7 +865,7 @@ public class VideoModule implements CameraModule, } mPreferences.edit().putString(CameraSettings.KEY_VIDEO_QUALITY, videoQuality).apply(); } - int quality = Integer.valueOf(videoQuality); + int quality = CameraSettings.VIDEO_QUALITY_TABLE.get(videoQuality); // Set video quality. Intent intent = mActivity.getIntent(); |