summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@cyanogenmod.org>2016-01-10 23:01:05 +0200
committerChippa-a <vusal1372@gmail.com>2019-10-25 15:55:25 +0300
commitb3b317ddc52253815d5392f2159c90dc89e4d693 (patch)
tree34f5fecad6482666195d865127b5bf2453877482 /src/com
parent84c342fac8bf0ca794a1731a828cec97d5b0da38 (diff)
downloadandroid_packages_apps_Snap-b3b317ddc52253815d5392f2159c90dc89e4d693.tar.gz
android_packages_apps_Snap-b3b317ddc52253815d5392f2159c90dc89e4d693.tar.bz2
android_packages_apps_Snap-b3b317ddc52253815d5392f2159c90dc89e4d693.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
Diffstat (limited to 'src/com')
-rwxr-xr-xsrc/com/android/camera/CameraSettings.java119
1 files changed, 19 insertions, 100 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 2fdd60ed4..0514ea916 100755
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -1493,114 +1493,33 @@ 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));
- }
- }
-
- return supported;
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
- private static void getFineResolutionQuality(ArrayList<String> supported,
- int cameraId,Parameters parameters) {
-
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfileWrapper.QUALITY_4KDCI)) {
- if (checkSupportedVideoQuality(parameters,4096,2160)) {
- supported.add(Integer.toString(CamcorderProfileWrapper.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, CamcorderProfileWrapper.QUALITY_VGA)) {
- if (checkSupportedVideoQuality(parameters,640,480)){
- supported.add(Integer.toString(CamcorderProfileWrapper.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));
- }
+ temp = sizeListToStringList(supportedVideoSizes);
}
- }
- 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);
}
}
}