diff options
author | Sascha Häberling <haeberling@google.com> | 2014-04-16 19:30:37 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-04-16 19:30:37 +0000 |
commit | bc34225d59a7d33fd0c1e0247af84ae11e4ee640 (patch) | |
tree | 90cfcafb70cfab846c97b37c02cb0d58f37a9ef5 | |
parent | 7d3c2dba1afc28d823ef2305109a3f1be24542b3 (diff) | |
parent | ace5f7f81899341d16bfea70c9bd4ec4b6ca2e56 (diff) | |
download | android_packages_apps_Camera2-bc34225d59a7d33fd0c1e0247af84ae11e4ee640.tar.gz android_packages_apps_Camera2-bc34225d59a7d33fd0c1e0247af84ae11e4ee640.tar.bz2 android_packages_apps_Camera2-bc34225d59a7d33fd0c1e0247af84ae11e4ee640.zip |
am ace5f7f8: Merge "Fix edge case in supported video quality selection." into gb-ub-photos-denali
* commit 'ace5f7f81899341d16bfea70c9bd4ec4b6ca2e56':
Fix edge case in supported video quality selection.
-rw-r--r-- | src/com/android/camera/settings/SettingsUtil.java | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/com/android/camera/settings/SettingsUtil.java b/src/com/android/camera/settings/SettingsUtil.java index 93613a1d6..c913190f8 100644 --- a/src/com/android/camera/settings/SettingsUtil.java +++ b/src/com/android/camera/settings/SettingsUtil.java @@ -294,9 +294,9 @@ public class SettingsUtil { // getNextSupportedQuality will throw an exception. // If only one quality is supported, then all three selected qualities // will be the same. - int largeIndex = getNextSupportedVideoQualityIndex(cameraId, 0); - int mediumIndex = getNextSupportedVideoQualityIndex(cameraId, largeIndex + 1); - int smallIndex = getNextSupportedVideoQualityIndex(cameraId, mediumIndex + 1); + int largeIndex = getNextSupportedVideoQualityIndex(cameraId, -1); + int mediumIndex = getNextSupportedVideoQualityIndex(cameraId, largeIndex); + int smallIndex = getNextSupportedVideoQualityIndex(cameraId, mediumIndex); SelectedVideoQualities selectedQualities = new SelectedVideoQualities(); selectedQualities.large = sVideoQualities[largeIndex]; @@ -311,28 +311,23 @@ public class SettingsUtil { * quality. */ private static int getNextSupportedVideoQualityIndex(int cameraId, int start) { - int i = start; + int i = start + 1; for (; i < sVideoQualities.length; ++i) { if (CamcorderProfile.hasProfile(cameraId, sVideoQualities[i])) { - break; + // We found a new supported quality. + return i; } } - // Were we not able to find a supported quality? - if (i >= sVideoQualities.length) { - if (start == 0) { - // This means we couldn't find any supported quality. - throw new IllegalArgumentException("Could not find supported video qualities."); - } else { - // We get here if start is larger than zero then we found a - // larger size already previously. In this edge case, just - // return the same index as the previous size. - return start; - } + // Failed to find another supported quality. + if (start < 0 || start >= sVideoQualities.length) { + // This means we couldn't find any supported quality. + throw new IllegalArgumentException("Could not find supported video qualities."); } - // We found a new supported quality. - return i; + // We previously found a larger supported size. In this edge case, just + // return the same index as the previous size. + return start; } /** |