summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shuzhen Wang <shuzhenwang@google.com> 2020-04-06 15:23:08 -0700
committer Shuzhen Wang <shuzhenwang@google.com> 2020-04-06 15:30:50 -0700
commitb80734fa0992c2796bb9d2863357cbb5fa19ec1c (patch)
treeb68bd86e7f2bceb72a18a8ae29520684431e12f4
parentfc294e8603a559e18d5140a45bce5af379d5e32c (diff)
Camera: Fix condition check for min/max zoom ratios
- minZoomRatio can be larger than 1.0f - assert both min and max zoom ratios to be greater than 0. - assert min zoom ratio to be equal or smaller than max zoom ratio. Test: CTS on Cuttlefish camera Bug: 153377715 Change-Id: Ia5d3f2ec7a51d4a35f199abe15a90c72cb7f3456
-rw-r--r--core/java/android/hardware/camera2/params/Capability.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/java/android/hardware/camera2/params/Capability.java b/core/java/android/hardware/camera2/params/Capability.java
index 6f59c5fdcb53..ebb534a48955 100644
--- a/core/java/android/hardware/camera2/params/Capability.java
+++ b/core/java/android/hardware/camera2/params/Capability.java
@@ -16,8 +16,8 @@
package android.hardware.camera2.params;
-import static com.android.internal.util.Preconditions.checkArgumentInRange;
import static com.android.internal.util.Preconditions.checkArgumentNonnegative;
+import static com.android.internal.util.Preconditions.checkArgumentPositive;
import android.annotation.NonNull;
import android.hardware.camera2.CameraCharacteristics;
@@ -64,9 +64,15 @@ public final class Capability {
"maxStreamingWidth must be nonnegative");
mMaxStreamingHeight = checkArgumentNonnegative(maxStreamingHeight,
"maxStreamingHeight must be nonnegative");
- mMinZoomRatio = checkArgumentInRange(minZoomRatio, 0.0f, 1.0f,
- "minZoomRatio must be between 0.0f and 1.0f");
- mMaxZoomRatio = maxZoomRatio;
+
+ if (minZoomRatio > maxZoomRatio) {
+ throw new IllegalArgumentException("minZoomRatio " + minZoomRatio
+ + " is greater than maxZoomRatio " + maxZoomRatio);
+ }
+ mMinZoomRatio = checkArgumentPositive(minZoomRatio,
+ "minZoomRatio must be positive");
+ mMaxZoomRatio = checkArgumentPositive(maxZoomRatio,
+ "maxZoomRatio must be positive");
}
/**