summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@cyanogenmod.org>2016-01-10 23:01:05 +0200
committerZhao Wei Liew <zhaoweiliew@gmail.com>2017-02-11 01:38:22 +0000
commitbb7712ea9d36fcbeca9585b920fd20fcaa496105 (patch)
treee848c427b447c659dfe44baccbc22837ccc125f6
parentf894729dac70ce8e486c7ea173e169eab41fef02 (diff)
downloadandroid_packages_apps_Snap-bb7712ea9d36fcbeca9585b920fd20fcaa496105.zip
android_packages_apps_Snap-bb7712ea9d36fcbeca9585b920fd20fcaa496105.tar.gz
android_packages_apps_Snap-bb7712ea9d36fcbeca9585b920fd20fcaa496105.tar.bz2
Snap: Fix NPE when parameters.getSupportedVideoSizes() is null
* Older devices do not support parameters.getSupportedVideoSizes() * Assume that the device reports valid profiles in media_profiles * Remove dead code Change-Id: Ic3488b6762496bd9498bc6bf8b48b2a2212bad51 (cherry picked from commit 2bc50511221788bf6a5815f92a07d95380e3d8ad)
-rw-r--r--src/com/android/camera/CameraSettings.java124
1 files changed, 22 insertions, 102 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index e234bdf..b9ff5fd 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -434,7 +434,7 @@ public class CameraSettings {
Context context, 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 = getSupportedVideoQualities(cameraId,parameters);
+ List<String> supported = getSupportedVideoQualities(cameraId, parameters);
assert (supported != null) : "No supported video quality is found";
for (String candidate : context.getResources().getStringArray(
R.array.pref_video_quality_entryvalues)) {
@@ -1018,7 +1018,7 @@ public class CameraSettings {
if (videoQuality != null) {
filterUnsupportedOptions(group, videoQuality, getSupportedVideoQualities(
- mCameraId,mParameters));
+ mCameraId, mParameters));
}
if (videoEncoder != null) {
@@ -1410,114 +1410,34 @@ public class CameraSettings {
initialCameraPictureSize(context, parameters);
writePreferredCameraId(preferences, currentCameraId);
}
- private static boolean checkSupportedVideoQuality(Parameters parameters,int width, int height){
- List <Size> supported = parameters.getSupportedVideoSizes();
- if (supported == null) {
- // video-size not specified in parameter list. just go along with the profile.
- return true;
- }
- int flag = 0;
- for (Size size : supported){
- //since we are having two profiles with same height, we are checking with height
- if (size.height == 480) {
- if (size.height == height && size.width == width) {
- flag = 1;
- break;
- }
- } else {
- if (size.width == width) {
- flag = 1;
- break;
- }
- }
- }
- if (flag == 1)
- return true;
- return false;
- }
- private static ArrayList<String> getSupportedVideoQuality(int cameraId,Parameters parameters) {
+ public static ArrayList<String> getSupportedVideoQualities(int cameraId,
+ Parameters parameters) {
ArrayList<String> supported = new ArrayList<String>();
- // Check for supported quality
- if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
- getFineResolutionQuality(supported,cameraId,parameters);
+ List<Size> supportedVideoSizes = parameters.getSupportedVideoSizes();
+ List<String> videoSizes;
+ if (supportedVideoSizes == null) {
+ // video-size not specified in parameter list,
+ // assume all profiles in media_profiles are supported.
+ videoSizes = new ArrayList<String>();
+ videoSizes.add("4096x2160");
+ videoSizes.add("3840x2160");
+ videoSizes.add("1920x1080");
+ videoSizes.add("1280x720");
+ videoSizes.add("720x480");
+ videoSizes.add("640x480");
+ videoSizes.add("352x288");
+ videoSizes.add("320x240");
+ videoSizes.add("176x144");
} else {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_HIGH));
- CamcorderProfile high = CamcorderProfile.get(
- cameraId, CamcorderProfile.QUALITY_HIGH);
- CamcorderProfile low = CamcorderProfile.get(
- cameraId, CamcorderProfile.QUALITY_LOW);
- if (high.videoFrameHeight * high.videoFrameWidth >
- low.videoFrameHeight * low.videoFrameWidth) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_LOW));
- }
- }
-
- return supported;
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
- private static void getFineResolutionQuality(ArrayList<String> supported,
- int cameraId,Parameters parameters) {
-
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_4KDCI)) {
- if (checkSupportedVideoQuality(parameters,4096,2160)) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_4KDCI));
- }
+ videoSizes = sizeListToStringList(supportedVideoSizes);
}
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_2160P)) {
- if (checkSupportedVideoQuality(parameters,3840,2160)) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_2160P));
- }
- }
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_1080P)) {
- if (checkSupportedVideoQuality(parameters,1920,1080)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_1080P));
- }
- }
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_720P)) {
- if (checkSupportedVideoQuality(parameters,1280,720)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_720P));
- }
- }
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) {
- if (checkSupportedVideoQuality(parameters,720,480)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_480P));
- }
- }
-
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_VGA)) {
- if (checkSupportedVideoQuality(parameters,640,480)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_VGA));
- }
- }
-
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_CIF)) {
- if (checkSupportedVideoQuality(parameters,352,288)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_CIF));
- }
- }
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_QVGA)) {
- if (checkSupportedVideoQuality(parameters,320,240)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_QVGA));
- }
- }
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_QCIF)) {
- if (checkSupportedVideoQuality(parameters,176,144)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_QCIF));
- }
- }
- }
-
- 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) {
+ for (String videoSize : videoSizes) {
if (VIDEO_QUALITY_TABLE.containsKey(videoSize)) {
int profile = VIDEO_QUALITY_TABLE.get(videoSize);
if (CamcorderProfile.hasProfile(cameraId, profile)) {
- supported.add(videoSize);
+ supported.add(videoSize);
}
}
}