From de19f2c9a36a081dbea3d74a73c2bb496754caab Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Wed, 27 Jul 2022 02:06:18 -0400 Subject: [PATCH 01/10] Adding support for the android 11+ Camera2 CONTROL_ZOOM_RATIO_RANGE camera preference. This preference is essential for supporting Logical cameras on the rear which after android 11 wrap multiple cameras (ultrawide, normal, superzoom, etc) into a single rear facing camera. This updates change how zoom functions as well as how min and max zoom is set to be compliant with those updates as long as the user device is on android 11+. --- .../camera_android/android/build.gradle | 1 + .../plugins/camera/CameraProperties.java | 40 +++++- .../io/flutter/plugins/camera/CameraZoom.java | 52 -------- .../features/zoomlevel/ZoomLevelFeature.java | 44 +++--- .../camera/features/zoomlevel/ZoomUtils.java | 6 +- .../camera/CameraPropertiesImplTest.java | 24 ++++ .../plugins/camera/CameraZoomTest.java | 125 ------------------ .../zoomlevel/ZoomLevelFeatureTest.java | 2 +- .../features/zoomlevel/ZoomUtilsTest.java | 37 ++++-- 9 files changed, 126 insertions(+), 205 deletions(-) delete mode 100644 packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraZoom.java delete mode 100644 packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraZoomTest.java diff --git a/packages/camera/camera_android/android/build.gradle b/packages/camera/camera_android/android/build.gradle index 1967ebaf0236..743e656d1370 100644 --- a/packages/camera/camera_android/android/build.gradle +++ b/packages/camera/camera_android/android/build.gradle @@ -59,6 +59,7 @@ android { } dependencies { + testImplementation project(path: ':camera_android') compileOnly 'androidx.annotation:annotation:1.1.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-inline:4.6.1' diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java index 95efebbf6488..6d729e0df0f4 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java @@ -147,13 +147,37 @@ public interface CameraProperties { * height and crop region height, for @see android.scaler.cropRegion. * *

By default maps to the @see - * android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM key. + * android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM key * * @return Float Maximum ratio between both active area width and crop region width, and active - * area height and crop region height + * area height and crop region height. */ Float getScalerAvailableMaxDigitalZoom(); + /** + * Returns the minimum ratio between both active area width and crop region width, and active area + * height and crop region height, for @see android.scaler.cropRegion. + * + *

By default maps to the @see + * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's lower value. + * + * @return Float Minimum ratio between the default zoom ratio and the maximum possible zoom + */ + @RequiresApi(api = VERSION_CODES.R) + Float getScalerMinZoomRatio(); + + /** + * Returns the minimum ratio between both active area width and crop region width, and active area + * height and crop region height, for @see android.scaler.cropRegion. + * + *

By default maps to the @see + * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's lower value. + * + * @return Float Minimum ratio between the default zoom ratio and the maximum possible zoom + */ + @RequiresApi(api = VERSION_CODES.R) + Float getScalerMaxZoomRatio(); + /** * Returns the area of the image sensor which corresponds to active pixels after any geometric * distortion correction has been applied. @@ -315,6 +339,18 @@ public Float getScalerAvailableMaxDigitalZoom() { return cameraCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM); } + @RequiresApi(api = VERSION_CODES.R) + @Override + public Float getScalerMaxZoomRatio() { + return cameraCharacteristics.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE).getUpper(); + } + + @RequiresApi(api = VERSION_CODES.R) + @Override + public Float getScalerMinZoomRatio() { + return cameraCharacteristics.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE).getLower(); + } + @Override public Rect getSensorInfoActiveArraySize() { return cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraZoom.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraZoom.java deleted file mode 100644 index 42ad6d76dcfc..000000000000 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraZoom.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package io.flutter.plugins.camera; - -import android.graphics.Rect; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.math.MathUtils; - -public final class CameraZoom { - public static final float DEFAULT_ZOOM_FACTOR = 1.0f; - - @NonNull private final Rect cropRegion = new Rect(); - @Nullable private final Rect sensorSize; - - public final float maxZoom; - public final boolean hasSupport; - - public CameraZoom(@Nullable final Rect sensorArraySize, final Float maxZoom) { - this.sensorSize = sensorArraySize; - - if (this.sensorSize == null) { - this.maxZoom = DEFAULT_ZOOM_FACTOR; - this.hasSupport = false; - return; - } - - this.maxZoom = - ((maxZoom == null) || (maxZoom < DEFAULT_ZOOM_FACTOR)) ? DEFAULT_ZOOM_FACTOR : maxZoom; - - this.hasSupport = (Float.compare(this.maxZoom, DEFAULT_ZOOM_FACTOR) > 0); - } - - public Rect computeZoom(final float zoom) { - if (sensorSize == null || !this.hasSupport) { - return null; - } - - final float newZoom = MathUtils.clamp(zoom, DEFAULT_ZOOM_FACTOR, this.maxZoom); - - final int centerX = this.sensorSize.width() / 2; - final int centerY = this.sensorSize.height() / 2; - final int deltaX = (int) ((0.5f * this.sensorSize.width()) / newZoom); - final int deltaY = (int) ((0.5f * this.sensorSize.height()) / newZoom); - - this.cropRegion.set(centerX - deltaX, centerY - deltaY, centerX + deltaX, centerY + deltaY); - - return cropRegion; - } -} diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java index 736fad4d92dc..b0e991b6bf4f 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java @@ -6,16 +6,17 @@ import android.graphics.Rect; import android.hardware.camera2.CaptureRequest; +import android.os.Build; import io.flutter.plugins.camera.CameraProperties; import io.flutter.plugins.camera.features.CameraFeature; /** Controls the zoom configuration on the {@link android.hardware.camera2} API. */ public class ZoomLevelFeature extends CameraFeature { - private static final float MINIMUM_ZOOM_LEVEL = 1.0f; private final boolean hasSupport; private final Rect sensorArraySize; - private Float currentSetting = MINIMUM_ZOOM_LEVEL; - private Float maximumZoomLevel = MINIMUM_ZOOM_LEVEL; + private Float currentSetting = 1.0f; + private Float minimumZoomLevel = currentSetting; + private Float maximumZoomLevel; /** * Creates a new instance of the {@link ZoomLevelFeature}. @@ -28,18 +29,24 @@ public ZoomLevelFeature(CameraProperties cameraProperties) { sensorArraySize = cameraProperties.getSensorInfoActiveArraySize(); if (sensorArraySize == null) { - maximumZoomLevel = MINIMUM_ZOOM_LEVEL; + maximumZoomLevel = minimumZoomLevel; hasSupport = false; return; } - Float maxDigitalZoom = cameraProperties.getScalerAvailableMaxDigitalZoom(); - maximumZoomLevel = - ((maxDigitalZoom == null) || (maxDigitalZoom < MINIMUM_ZOOM_LEVEL)) - ? MINIMUM_ZOOM_LEVEL - : maxDigitalZoom; + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + minimumZoomLevel = cameraProperties.getScalerMinZoomRatio(); + maximumZoomLevel = cameraProperties.getScalerMaxZoomRatio(); + } else { + minimumZoomLevel = 1.0f; + Float maxDigitalZoom = cameraProperties.getScalerAvailableMaxDigitalZoom(); + maximumZoomLevel = + ((maxDigitalZoom == null) || (maxDigitalZoom < minimumZoomLevel)) + ? minimumZoomLevel + : maxDigitalZoom; + } - hasSupport = (Float.compare(maximumZoomLevel, MINIMUM_ZOOM_LEVEL) > 0); + hasSupport = (Float.compare(maximumZoomLevel, minimumZoomLevel) > 0); } @Override @@ -67,11 +74,16 @@ public void updateBuilder(CaptureRequest.Builder requestBuilder) { if (!checkIsSupported()) { return; } - - final Rect computedZoom = - ZoomUtils.computeZoom( - currentSetting, sensorArraySize, MINIMUM_ZOOM_LEVEL, maximumZoomLevel); - requestBuilder.set(CaptureRequest.SCALER_CROP_REGION, computedZoom); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + requestBuilder.set( + CaptureRequest.CONTROL_ZOOM_RATIO, + ZoomUtils.computeZoomRatio(currentSetting, minimumZoomLevel, maximumZoomLevel)); + } else { + final Rect computedZoom = + ZoomUtils.computeZoomRect( + currentSetting, sensorArraySize, minimumZoomLevel, maximumZoomLevel); + requestBuilder.set(CaptureRequest.SCALER_CROP_REGION, computedZoom); + } } /** @@ -80,7 +92,7 @@ public void updateBuilder(CaptureRequest.Builder requestBuilder) { * @return The minimum zoom level. */ public float getMinimumZoomLevel() { - return MINIMUM_ZOOM_LEVEL; + return minimumZoomLevel; } /** diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java index a4890b952cff..cb02d8123579 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java @@ -26,7 +26,7 @@ final class ZoomUtils { * @param maximumZoomLevel The maximim supported zoom level. * @return An image sensor area based on the supplied zoom settings */ - static Rect computeZoom( + static Rect computeZoomRect( float zoom, @NonNull Rect sensorArraySize, float minimumZoomLevel, float maximumZoomLevel) { final float newZoom = MathUtils.clamp(zoom, minimumZoomLevel, maximumZoomLevel); @@ -37,4 +37,8 @@ static Rect computeZoom( return new Rect(centerX - deltaX, centerY - deltaY, centerX + deltaX, centerY + deltaY); } + + static Float computeZoomRatio(float zoom, float minimumZoomLevel, float maximumZoomLevel) { + return MathUtils.clamp(zoom, minimumZoomLevel, maximumZoomLevel); + } } diff --git a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraPropertiesImplTest.java b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraPropertiesImplTest.java index 40db12ee0fc3..c61be04465ab 100644 --- a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraPropertiesImplTest.java +++ b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraPropertiesImplTest.java @@ -201,6 +201,30 @@ public void getScalerAvailableMaxDigitalZoomTest() { assertEquals(actualDigitalZoom, expectedDigitalZoom); } + @Test + public void getScalerGetScalerMinZoomRatioTest() { + Range zoomRange = mock(Range.class); + when(mockCharacteristics.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE)) + .thenReturn(zoomRange); + + Float minZoom = cameraProperties.getScalerMinZoomRatio(); + + verify(mockCharacteristics, times(1)).get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE); + assertEquals(zoomRange.getLower(), minZoom); + } + + @Test + public void getScalerGetScalerMaxZoomRatioTest() { + Range zoomRange = mock(Range.class); + when(mockCharacteristics.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE)) + .thenReturn(zoomRange); + + Float maxZoom = cameraProperties.getScalerMaxZoomRatio(); + + verify(mockCharacteristics, times(1)).get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE); + assertEquals(zoomRange.getUpper(), maxZoom); + } + @Test public void getSensorInfoActiveArraySizeTest() { Rect expectedArraySize = mock(Rect.class); diff --git a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraZoomTest.java b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraZoomTest.java deleted file mode 100644 index d3e495551608..000000000000 --- a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/CameraZoomTest.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package io.flutter.plugins.camera; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import android.graphics.Rect; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; - -@RunWith(RobolectricTestRunner.class) -public class CameraZoomTest { - - @Test - public void ctor_whenParametersAreValid() { - final Rect sensorSize = new Rect(0, 0, 0, 0); - final Float maxZoom = 4.0f; - final CameraZoom cameraZoom = new CameraZoom(sensorSize, maxZoom); - - assertNotNull(cameraZoom); - assertTrue(cameraZoom.hasSupport); - assertEquals(4.0f, cameraZoom.maxZoom, 0); - assertEquals(1.0f, CameraZoom.DEFAULT_ZOOM_FACTOR, 0); - } - - @Test - public void ctor_whenSensorSizeIsNull() { - final Rect sensorSize = null; - final Float maxZoom = 4.0f; - final CameraZoom cameraZoom = new CameraZoom(sensorSize, maxZoom); - - assertNotNull(cameraZoom); - assertFalse(cameraZoom.hasSupport); - assertEquals(cameraZoom.maxZoom, 1.0f, 0); - } - - @Test - public void ctor_whenMaxZoomIsNull() { - final Rect sensorSize = new Rect(0, 0, 0, 0); - final Float maxZoom = null; - final CameraZoom cameraZoom = new CameraZoom(sensorSize, maxZoom); - - assertNotNull(cameraZoom); - assertFalse(cameraZoom.hasSupport); - assertEquals(cameraZoom.maxZoom, 1.0f, 0); - } - - @Test - public void ctor_whenMaxZoomIsSmallerThenDefaultZoomFactor() { - final Rect sensorSize = new Rect(0, 0, 0, 0); - final Float maxZoom = 0.5f; - final CameraZoom cameraZoom = new CameraZoom(sensorSize, maxZoom); - - assertNotNull(cameraZoom); - assertFalse(cameraZoom.hasSupport); - assertEquals(cameraZoom.maxZoom, 1.0f, 0); - } - - @Test - public void setZoom_whenNoSupportShouldNotSetScalerCropRegion() { - final CameraZoom cameraZoom = new CameraZoom(null, null); - final Rect computedZoom = cameraZoom.computeZoom(2f); - - assertNull(computedZoom); - } - - @Test - public void setZoom_whenSensorSizeEqualsZeroShouldReturnCropRegionOfZero() { - final Rect sensorSize = new Rect(0, 0, 0, 0); - final CameraZoom cameraZoom = new CameraZoom(sensorSize, 20f); - final Rect computedZoom = cameraZoom.computeZoom(18f); - - assertNotNull(computedZoom); - assertEquals(computedZoom.left, 0); - assertEquals(computedZoom.top, 0); - assertEquals(computedZoom.right, 0); - assertEquals(computedZoom.bottom, 0); - } - - @Test - public void setZoom_whenSensorSizeIsValidShouldReturnCropRegion() { - final Rect sensorSize = new Rect(0, 0, 100, 100); - final CameraZoom cameraZoom = new CameraZoom(sensorSize, 20f); - final Rect computedZoom = cameraZoom.computeZoom(18f); - - assertNotNull(computedZoom); - assertEquals(computedZoom.left, 48); - assertEquals(computedZoom.top, 48); - assertEquals(computedZoom.right, 52); - assertEquals(computedZoom.bottom, 52); - } - - @Test - public void setZoom_whenZoomIsGreaterThenMaxZoomClampToMaxZoom() { - final Rect sensorSize = new Rect(0, 0, 100, 100); - final CameraZoom cameraZoom = new CameraZoom(sensorSize, 10f); - final Rect computedZoom = cameraZoom.computeZoom(25f); - - assertNotNull(computedZoom); - assertEquals(computedZoom.left, 45); - assertEquals(computedZoom.top, 45); - assertEquals(computedZoom.right, 55); - assertEquals(computedZoom.bottom, 55); - } - - @Test - public void setZoom_whenZoomIsSmallerThenMinZoomClampToMinZoom() { - final Rect sensorSize = new Rect(0, 0, 100, 100); - final CameraZoom cameraZoom = new CameraZoom(sensorSize, 10f); - final Rect computedZoom = cameraZoom.computeZoom(0.5f); - - assertNotNull(computedZoom); - assertEquals(computedZoom.left, 0); - assertEquals(computedZoom.top, 0); - assertEquals(computedZoom.right, 100); - assertEquals(computedZoom.bottom, 100); - } -} diff --git a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java index 9f05cc255a8b..38564e5622cf 100644 --- a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java +++ b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java @@ -40,7 +40,7 @@ public void before() { mockSensorArray = mock(Rect.class); mockedStaticCameraZoom - .when(() -> ZoomUtils.computeZoom(anyFloat(), any(), anyFloat(), anyFloat())) + .when(() -> ZoomUtils.computeZoomRect(anyFloat(), any(), anyFloat(), anyFloat())) .thenReturn(mockZoomArea); } diff --git a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtilsTest.java b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtilsTest.java index 28160ff30714..2f6160816d15 100644 --- a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtilsTest.java +++ b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtilsTest.java @@ -15,9 +15,9 @@ @RunWith(RobolectricTestRunner.class) public class ZoomUtilsTest { @Test - public void setZoom_whenSensorSizeEqualsZeroShouldReturnCropRegionOfZero() { + public void setZoomRect_whenSensorSizeEqualsZeroShouldReturnCropRegionOfZero() { final Rect sensorSize = new Rect(0, 0, 0, 0); - final Rect computedZoom = ZoomUtils.computeZoom(18f, sensorSize, 1f, 20f); + final Rect computedZoom = ZoomUtils.computeZoomRect(18f, sensorSize, 1f, 20f); assertNotNull(computedZoom); assertEquals(computedZoom.left, 0); @@ -27,9 +27,9 @@ public void setZoom_whenSensorSizeEqualsZeroShouldReturnCropRegionOfZero() { } @Test - public void setZoom_whenSensorSizeIsValidShouldReturnCropRegion() { + public void setZoomRect_whenSensorSizeIsValidShouldReturnCropRegion() { final Rect sensorSize = new Rect(0, 0, 100, 100); - final Rect computedZoom = ZoomUtils.computeZoom(18f, sensorSize, 1f, 20f); + final Rect computedZoom = ZoomUtils.computeZoomRect(18f, sensorSize, 1f, 20f); assertNotNull(computedZoom); assertEquals(computedZoom.left, 48); @@ -39,9 +39,9 @@ public void setZoom_whenSensorSizeIsValidShouldReturnCropRegion() { } @Test - public void setZoom_whenZoomIsGreaterThenMaxZoomClampToMaxZoom() { + public void setZoomRect_whenZoomIsGreaterThenMaxZoomClampToMaxZoom() { final Rect sensorSize = new Rect(0, 0, 100, 100); - final Rect computedZoom = ZoomUtils.computeZoom(25f, sensorSize, 1f, 10f); + final Rect computedZoom = ZoomUtils.computeZoomRect(25f, sensorSize, 1f, 10f); assertNotNull(computedZoom); assertEquals(computedZoom.left, 45); @@ -51,9 +51,9 @@ public void setZoom_whenZoomIsGreaterThenMaxZoomClampToMaxZoom() { } @Test - public void setZoom_whenZoomIsSmallerThenMinZoomClampToMinZoom() { + public void setZoomRect_whenZoomIsSmallerThenMinZoomClampToMinZoom() { final Rect sensorSize = new Rect(0, 0, 100, 100); - final Rect computedZoom = ZoomUtils.computeZoom(0.5f, sensorSize, 1f, 10f); + final Rect computedZoom = ZoomUtils.computeZoomRect(0.5f, sensorSize, 1f, 10f); assertNotNull(computedZoom); assertEquals(computedZoom.left, 0); @@ -61,4 +61,25 @@ public void setZoom_whenZoomIsSmallerThenMinZoomClampToMinZoom() { assertEquals(computedZoom.right, 100); assertEquals(computedZoom.bottom, 100); } + + @Test + public void setZoomRatio_whenNewZoomGreaterThanMaxZoomClampToMaxZoom() { + final Float computedZoom = ZoomUtils.computeZoomRatio(21f, 1f, 20f); + assertNotNull(computedZoom); + assertEquals(computedZoom, 20f, 0.0f); + } + + @Test + public void setZoomRatio_whenNewZoomLesserThanMinZoomClampToMinZoom() { + final Float computedZoom = ZoomUtils.computeZoomRatio(0.7f, 1f, 20f); + assertNotNull(computedZoom); + assertEquals(computedZoom, 1f, 0.0f); + } + + @Test + public void setZoomRatio_whenNewZoomValidReturnNewZoom() { + final Float computedZoom = ZoomUtils.computeZoomRatio(2.0f, 1f, 20f); + assertNotNull(computedZoom); + assertEquals(computedZoom, 2.0f, 0.0f); + } } From 60cc46521e1c31977773d731416a71d1bdf7ef05 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Wed, 27 Jul 2022 02:07:26 -0400 Subject: [PATCH 02/10] Adding updates to the changelog and pubspec to reflect the zoom and camera updates. --- packages/camera/camera_android/CHANGELOG.md | 4 ++++ packages/camera/camera_android/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index 3a743340dc6e..0d774c65a0dd 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.0+1 + +* Fixes issues with Virtual cameras hiding physical cameras in android 11+. + ## 0.10.0 * **Breaking Change** Updates Android camera access permission error codes to be consistent with other platforms. If your app still handles the legacy `cameraPermission` exception, please update it to handle the new permission exception codes that are noted in the README. diff --git a/packages/camera/camera_android/pubspec.yaml b/packages/camera/camera_android/pubspec.yaml index 581780f0d87b..e7d6aeb51e24 100644 --- a/packages/camera/camera_android/pubspec.yaml +++ b/packages/camera/camera_android/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_android description: Android implementation of the camera plugin. repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.0 +version: 0.10.0+1 environment: sdk: ">=2.14.0 <3.0.0" From 54ec6b47d5d2f451c35913bf22446e4a5c356d74 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Wed, 27 Jul 2022 02:19:45 -0400 Subject: [PATCH 03/10] comment cleanup for min and max zoom ratio functions --- .../io/flutter/plugins/camera/CameraProperties.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java index 6d729e0df0f4..05cfed6d1a4a 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java @@ -155,8 +155,7 @@ public interface CameraProperties { Float getScalerAvailableMaxDigitalZoom(); /** - * Returns the minimum ratio between both active area width and crop region width, and active area - * height and crop region height, for @see android.scaler.cropRegion. + * Returns the minimum ratio between the default camera zoom setting and all of the available zoom * *

By default maps to the @see * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's lower value. @@ -167,13 +166,12 @@ public interface CameraProperties { Float getScalerMinZoomRatio(); /** - * Returns the minimum ratio between both active area width and crop region width, and active area - * height and crop region height, for @see android.scaler.cropRegion. + * Returns the maximum ratio between the default camera zoom setting and all of the available zoom * *

By default maps to the @see - * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's lower value. + * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's upper value. * - * @return Float Minimum ratio between the default zoom ratio and the maximum possible zoom + * @return Float Maximum ratio between the default zoom ratio and the maximum possible zoom */ @RequiresApi(api = VERSION_CODES.R) Float getScalerMaxZoomRatio(); From af4fb8bc261c167ad1234407518984d0d2ea420f Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Fri, 5 Aug 2022 00:01:45 -0400 Subject: [PATCH 04/10] Pull request fixes --- .../camera_android/android/build.gradle | 1 - .../plugins/camera/CameraProperties.java | 2 +- .../features/zoomlevel/ZoomLevelFeature.java | 12 +++-- .../camera/features/zoomlevel/ZoomUtils.java | 5 +- .../zoomlevel/ZoomLevelFeatureTest.java | 53 +++++++++++++++++++ 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/packages/camera/camera_android/android/build.gradle b/packages/camera/camera_android/android/build.gradle index 743e656d1370..1967ebaf0236 100644 --- a/packages/camera/camera_android/android/build.gradle +++ b/packages/camera/camera_android/android/build.gradle @@ -59,7 +59,6 @@ android { } dependencies { - testImplementation project(path: ':camera_android') compileOnly 'androidx.annotation:annotation:1.1.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-inline:4.6.1' diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java index 05cfed6d1a4a..abd996e5e3a1 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java @@ -147,7 +147,7 @@ public interface CameraProperties { * height and crop region height, for @see android.scaler.cropRegion. * *

By default maps to the @see - * android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM key + * android.hardware.camera2.CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM key. * * @return Float Maximum ratio between both active area width and crop region width, and active * area height and crop region height. diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java index b0e991b6bf4f..5a9f828371c6 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java @@ -12,9 +12,10 @@ /** Controls the zoom configuration on the {@link android.hardware.camera2} API. */ public class ZoomLevelFeature extends CameraFeature { + private static final Float defaultZoomLevel = 1.0f; private final boolean hasSupport; private final Rect sensorArraySize; - private Float currentSetting = 1.0f; + private Float currentSetting = defaultZoomLevel; private Float minimumZoomLevel = currentSetting; private Float maximumZoomLevel; @@ -33,12 +34,12 @@ public ZoomLevelFeature(CameraProperties cameraProperties) { hasSupport = false; return; } - - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + // On Android 11+ CONTROL_ZOOM_RATIO_RANGE should be use to get the zoom ratio directly + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { minimumZoomLevel = cameraProperties.getScalerMinZoomRatio(); maximumZoomLevel = cameraProperties.getScalerMaxZoomRatio(); } else { - minimumZoomLevel = 1.0f; + minimumZoomLevel = defaultZoomLevel; Float maxDigitalZoom = cameraProperties.getScalerAvailableMaxDigitalZoom(); maximumZoomLevel = ((maxDigitalZoom == null) || (maxDigitalZoom < minimumZoomLevel)) @@ -74,7 +75,8 @@ public void updateBuilder(CaptureRequest.Builder requestBuilder) { if (!checkIsSupported()) { return; } - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { + // On Android 11+ CONTROL_ZOOM_RATIO should be use to get the zoom ratio directly + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { requestBuilder.set( CaptureRequest.CONTROL_ZOOM_RATIO, ZoomUtils.computeZoomRatio(currentSetting, minimumZoomLevel, maximumZoomLevel)); diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java index cb02d8123579..f5a96a86d1fb 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java @@ -18,7 +18,8 @@ final class ZoomUtils { * Computes an image sensor area based on the supplied zoom settings. * *

The returned image sensor area can be applied to the {@link android.hardware.camera2} API in - * order to control zoom levels. + * order to control zoom levels. This method of zoom should only be used for android versions less + * than than 11 as past that the newer computeZoomRatio functional can be used. * * @param zoom The desired zoom level. * @param sensorArraySize The current area of the image sensor. @@ -28,7 +29,7 @@ final class ZoomUtils { */ static Rect computeZoomRect( float zoom, @NonNull Rect sensorArraySize, float minimumZoomLevel, float maximumZoomLevel) { - final float newZoom = MathUtils.clamp(zoom, minimumZoomLevel, maximumZoomLevel); + final float newZoom = computeZoomRatio(zoom, minimumZoomLevel, maximumZoomLevel); final int centerX = sensorArraySize.width() / 2; final int centerY = sensorArraySize.height() / 2; diff --git a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java index 38564e5622cf..4d5826967009 100644 --- a/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java +++ b/packages/camera/camera_android/android/src/test/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeatureTest.java @@ -18,7 +18,10 @@ import android.graphics.Rect; import android.hardware.camera2.CaptureRequest; +import android.os.Build; import io.flutter.plugins.camera.CameraProperties; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -147,6 +150,22 @@ public void updateBuilder_shouldSetScalarCropRegionWhenCheckIsSupportIsTrue() { verify(mockBuilder, times(1)).set(CaptureRequest.SCALER_CROP_REGION, mockZoomArea); } + @Test + public void updateBuilder_shouldControlZoomRatioWhenCheckIsSupportIsTrue() throws Exception { + setSdkVersion(Build.VERSION_CODES.R); + when(mockCameraProperties.getSensorInfoActiveArraySize()).thenReturn(mockSensorArray); + when(mockCameraProperties.getScalerMaxZoomRatio()).thenReturn(42f); + when(mockCameraProperties.getScalerMinZoomRatio()).thenReturn(1.0f); + + ZoomLevelFeature zoomLevelFeature = new ZoomLevelFeature(mockCameraProperties); + + CaptureRequest.Builder mockBuilder = mock(CaptureRequest.Builder.class); + + zoomLevelFeature.updateBuilder(mockBuilder); + + verify(mockBuilder, times(1)).set(CaptureRequest.CONTROL_ZOOM_RATIO, 0.0f); + } + @Test public void getMinimumZoomLevel() { ZoomLevelFeature zoomLevelFeature = new ZoomLevelFeature(mockCameraProperties); @@ -163,4 +182,38 @@ public void getMaximumZoomLevel() { assertEquals(42f, zoomLevelFeature.getMaximumZoomLevel(), 0); } + + @Test + public void checkZoomLevelFeature_callsMaxDigitalZoomOnAndroidQ() throws Exception { + setSdkVersion(Build.VERSION_CODES.Q); + + when(mockCameraProperties.getSensorInfoActiveArraySize()).thenReturn(mockSensorArray); + + new ZoomLevelFeature(mockCameraProperties); + + verify(mockCameraProperties, times(0)).getScalerMaxZoomRatio(); + verify(mockCameraProperties, times(0)).getScalerMinZoomRatio(); + verify(mockCameraProperties, times(1)).getScalerAvailableMaxDigitalZoom(); + } + + @Test + public void checkZoomLevelFeature_callsScalarMaxZoomRatioOnAndroidR() throws Exception { + setSdkVersion(Build.VERSION_CODES.R); + when(mockCameraProperties.getSensorInfoActiveArraySize()).thenReturn(mockSensorArray); + + new ZoomLevelFeature(mockCameraProperties); + + verify(mockCameraProperties, times(1)).getScalerMaxZoomRatio(); + verify(mockCameraProperties, times(1)).getScalerMinZoomRatio(); + verify(mockCameraProperties, times(0)).getScalerAvailableMaxDigitalZoom(); + } + + static void setSdkVersion(int sdkVersion) throws Exception { + Field sdkInt = Build.VERSION.class.getField("SDK_INT"); + sdkInt.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(sdkInt, sdkInt.getModifiers() & ~Modifier.FINAL); + sdkInt.set(null, sdkVersion); + } } From 90e04fcdb68dbeafebc5548e64c2a60772f97ba5 Mon Sep 17 00:00:00 2001 From: lucasoskorep Date: Thu, 4 Aug 2022 20:47:27 -0400 Subject: [PATCH 05/10] Update packages/camera/camera_android/CHANGELOG.md Co-authored-by: Camille Simon <43054281+camsim99@users.noreply.github.com> --- packages/camera/camera_android/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index 0d774c65a0dd..4567a156d707 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.10.0+1 -* Fixes issues with Virtual cameras hiding physical cameras in android 11+. +* Fixes zoom computation for virtual cameras hiding physical cameras in Android 11+. ## 0.10.0 From ecfb985b98c07fa691cd2d48326442e7e5a01a41 Mon Sep 17 00:00:00 2001 From: lucasoskorep Date: Mon, 8 Aug 2022 18:15:50 -0400 Subject: [PATCH 06/10] Update packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java Co-authored-by: Camille Simon <43054281+camsim99@users.noreply.github.com> --- .../flutter/plugins/camera/features/zoomlevel/ZoomUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java index f5a96a86d1fb..c78420b93d3f 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java @@ -18,8 +18,8 @@ final class ZoomUtils { * Computes an image sensor area based on the supplied zoom settings. * *

The returned image sensor area can be applied to the {@link android.hardware.camera2} API in - * order to control zoom levels. This method of zoom should only be used for android versions less - * than than 11 as past that the newer computeZoomRatio functional can be used. + * order to control zoom levels. This method of zoom should only be used for Android versions + * <= 11 as past that, the newer {@link #computeZoomRatio()} functional can be used. * * @param zoom The desired zoom level. * @param sensorArraySize The current area of the image sensor. From 7a0cb033802965dd2399c75e51e1b5a7134c3ffe Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Mon, 8 Aug 2022 18:29:38 -0400 Subject: [PATCH 07/10] Updating comments from PR --- packages/camera/camera_android/CHANGELOG.md | 1 + .../plugins/camera/features/zoomlevel/ZoomLevelFeature.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index 4567a156d707..3d3cc8415cbe 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.10.0+1 * Fixes zoom computation for virtual cameras hiding physical cameras in Android 11+. +* Removes the unused CameraZoom class from the codebase. ## 0.10.0 diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java index 5a9f828371c6..482c5c693698 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java @@ -34,7 +34,7 @@ public ZoomLevelFeature(CameraProperties cameraProperties) { hasSupport = false; return; } - // On Android 11+ CONTROL_ZOOM_RATIO_RANGE should be use to get the zoom ratio directly + // On Android 11+ CONTROL_ZOOM_RATIO_RANGE should be use to get the zoom ratio directly as minimum zoom does not have to be 1.0f if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { minimumZoomLevel = cameraProperties.getScalerMinZoomRatio(); maximumZoomLevel = cameraProperties.getScalerMaxZoomRatio(); @@ -75,7 +75,9 @@ public void updateBuilder(CaptureRequest.Builder requestBuilder) { if (!checkIsSupported()) { return; } - // On Android 11+ CONTROL_ZOOM_RATIO should be use to get the zoom ratio directly + // On Android 11+ CONTROL_ZOOM_RATIO can be set to a zoom ratio and the camera feed will compute + // how to zoom on its own accounting for multiple logical cameras. + // Prior the image cropping window must be calculated and set manually. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { requestBuilder.set( CaptureRequest.CONTROL_ZOOM_RATIO, From e8285491c767a8988c8bc739b5aaa1234f0e7e63 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Fri, 23 Sep 2022 23:51:13 -0400 Subject: [PATCH 08/10] Fixing variable name formatting, and comment structures --- .../io/flutter/plugins/camera/CameraProperties.java | 8 ++++---- .../camera/features/zoomlevel/ZoomLevelFeature.java | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java index abd996e5e3a1..6902eee1934b 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java @@ -155,23 +155,23 @@ public interface CameraProperties { Float getScalerAvailableMaxDigitalZoom(); /** - * Returns the minimum ratio between the default camera zoom setting and all of the available zoom + * Returns the minimum ratio between the default camera zoom setting and all of the available zoom. * *

By default maps to the @see * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's lower value. * - * @return Float Minimum ratio between the default zoom ratio and the maximum possible zoom + * @return Float Minimum ratio between the default zoom ratio and the minimum possible zoom. */ @RequiresApi(api = VERSION_CODES.R) Float getScalerMinZoomRatio(); /** - * Returns the maximum ratio between the default camera zoom setting and all of the available zoom + * Returns the maximum ratio between the default camera zoom setting and all of the available zoom. * *

By default maps to the @see * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's upper value. * - * @return Float Maximum ratio between the default zoom ratio and the maximum possible zoom + * @return Float Maximum ratio between the default zoom ratio and the maximum possible zoom. */ @RequiresApi(api = VERSION_CODES.R) Float getScalerMaxZoomRatio(); diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java index 482c5c693698..de3799db8f40 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java @@ -11,11 +11,11 @@ import io.flutter.plugins.camera.features.CameraFeature; /** Controls the zoom configuration on the {@link android.hardware.camera2} API. */ -public class ZoomLevelFeature extends CameraFeature { - private static final Float defaultZoomLevel = 1.0f; +public class ZoomLevelFeature extends CameraFeaFture { + private static final Float DEFAULT_ZOOM_LEVEL = 1.0f; private final boolean hasSupport; private final Rect sensorArraySize; - private Float currentSetting = defaultZoomLevel; + private Float currentSetting = DEFAULT_ZOOM_LEVEL; private Float minimumZoomLevel = currentSetting; private Float maximumZoomLevel; @@ -34,12 +34,12 @@ public ZoomLevelFeature(CameraProperties cameraProperties) { hasSupport = false; return; } - // On Android 11+ CONTROL_ZOOM_RATIO_RANGE should be use to get the zoom ratio directly as minimum zoom does not have to be 1.0f + // On Android 11+ CONTROL_ZOOM_RATIO_RANGE should be use to get the zoom ratio directly as minimum zoom does not have to be 1.0f. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { minimumZoomLevel = cameraProperties.getScalerMinZoomRatio(); maximumZoomLevel = cameraProperties.getScalerMaxZoomRatio(); } else { - minimumZoomLevel = defaultZoomLevel; + minimumZoomLevel = DEFAULT_ZOOM_LEVEL; Float maxDigitalZoom = cameraProperties.getScalerAvailableMaxDigitalZoom(); maximumZoomLevel = ((maxDigitalZoom == null) || (maxDigitalZoom < minimumZoomLevel)) From d1826cef13dd99b6c340dc775b369159e0443294 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Sat, 24 Sep 2022 00:03:47 -0400 Subject: [PATCH 09/10] Fixing variable name formatting, and comment structures --- .../plugins/camera/features/zoomlevel/ZoomLevelFeature.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java index de3799db8f40..2ac70822eb77 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomLevelFeature.java @@ -11,7 +11,7 @@ import io.flutter.plugins.camera.features.CameraFeature; /** Controls the zoom configuration on the {@link android.hardware.camera2} API. */ -public class ZoomLevelFeature extends CameraFeaFture { +public class ZoomLevelFeature extends CameraFeature { private static final Float DEFAULT_ZOOM_LEVEL = 1.0f; private final boolean hasSupport; private final Rect sensorArraySize; From 96b3a3f4137f3480cdd5a1d73100431288f1b5b1 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Sat, 24 Sep 2022 00:11:28 -0400 Subject: [PATCH 10/10] Autogormatter updates --- .../java/io/flutter/plugins/camera/CameraProperties.java | 6 ++++-- .../plugins/camera/features/zoomlevel/ZoomUtils.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java index 6902eee1934b..a69bae43ee17 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraProperties.java @@ -155,7 +155,8 @@ public interface CameraProperties { Float getScalerAvailableMaxDigitalZoom(); /** - * Returns the minimum ratio between the default camera zoom setting and all of the available zoom. + * Returns the minimum ratio between the default camera zoom setting and all of the available + * zoom. * *

By default maps to the @see * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's lower value. @@ -166,7 +167,8 @@ public interface CameraProperties { Float getScalerMinZoomRatio(); /** - * Returns the maximum ratio between the default camera zoom setting and all of the available zoom. + * Returns the maximum ratio between the default camera zoom setting and all of the available + * zoom. * *

By default maps to the @see * android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE key's upper value. diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java index c78420b93d3f..af9e48ff135a 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/features/zoomlevel/ZoomUtils.java @@ -18,8 +18,8 @@ final class ZoomUtils { * Computes an image sensor area based on the supplied zoom settings. * *

The returned image sensor area can be applied to the {@link android.hardware.camera2} API in - * order to control zoom levels. This method of zoom should only be used for Android versions - * <= 11 as past that, the newer {@link #computeZoomRatio()} functional can be used. + * order to control zoom levels. This method of zoom should only be used for Android versions <= + * 11 as past that, the newer {@link #computeZoomRatio()} functional can be used. * * @param zoom The desired zoom level. * @param sensorArraySize The current area of the image sensor.