summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@cyanogenmod.org>2016-01-10 23:01:05 +0200
committerMichael Bestas <mikeioannina@cyanogenmod.org>2016-01-11 03:28:02 +0200
commitf4f58540892ea529256de77f73f4948af82e8511 (patch)
treeacd9883d1d88b4b1b71e3e9e42a8decf0a5bf208
parent3615cea5b00e3fc2987359bf8cf3895f646a7103 (diff)
downloadandroid_packages_apps_Snap-f4f58540892ea529256de77f73f4948af82e8511.tar.gz
android_packages_apps_Snap-f4f58540892ea529256de77f73f4948af82e8511.tar.bz2
android_packages_apps_Snap-f4f58540892ea529256de77f73f4948af82e8511.zip
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
-rw-r--r--src/com/android/camera/CameraSettings.java118
1 files changed, 21 insertions, 97 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 4d8a13aeb..53d34af81 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -381,7 +381,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 = getSupportedVideoQualities(cameraId,parameters);
+ List<String> supported = getSupportedVideoQualities(cameraId, parameters);
assert (supported != null) : "No supported video quality is found";
return supported.get(0);
}
@@ -881,7 +881,7 @@ public class CameraSettings {
if (videoQuality != null) {
filterUnsupportedOptions(group, videoQuality, getSupportedVideoQualities(
- mCameraId,mParameters));
+ mCameraId, mParameters));
}
if (pictureSize != null) {
@@ -1242,116 +1242,40 @@ 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> temp;
+ if (supportedVideoSizes == null) {
+ // video-size not specified in parameter list,
+ // assume all profiles in media_profiles are supported.
+ temp = new ArrayList<String>();
+ temp.add("4096x2160");
+ temp.add("3840x2160");
+ temp.add("1920x1080");
+ temp.add("1280x720");
+ temp.add("720x480");
+ temp.add("640x480");
+ temp.add("352x288");
+ temp.add("320x240");
+ temp.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));
- }
+ temp = sizeListToStringList(supportedVideoSizes);
}
- 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);
+ supported.add(videoSize);
}
}
}
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));
- }
- }
- 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 boolean isInternalPreviewSupported(Parameters params) {
boolean ret = false;
if (null != params) {