Skip to content

Commit cac8837

Browse files
Treehugger RobotGerrit Code Review
Treehugger Robot
authored and
Gerrit Code Review
committed
Merge "FPS range query API council feedback" into androidx-main
2 parents eb3f64c + 2c825b6 commit cac8837

File tree

10 files changed

+27
-25
lines changed

10 files changed

+27
-25
lines changed

camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/adapter/CameraInfoAdapter.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,9 @@ class CameraInfoAdapter @Inject constructor(
174174
override fun isFocusMeteringSupported(action: FocusMeteringAction) =
175175
focusMeteringControl.isFocusMeteringSupported(action)
176176

177-
override fun getSupportedFrameRateRanges(): List<Range<Int>> {
178-
return cameraProperties
179-
.metadata[CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES]?.toList()
180-
?: listOf()
181-
}
177+
override fun getSupportedFrameRateRanges(): Set<Range<Int>> = cameraProperties
178+
.metadata[CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES]?.toSet()
179+
?: emptySet()
182180

183181
override fun isZslSupported(): Boolean {
184182
Log.warn { "TODO: isZslSupported are not yet supported." }

camera/camera-camera2-pipe-integration/src/test/java/androidx/camera/camera2/pipe/integration/adapter/CameraInfoAdapterTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CameraInfoAdapterTest {
6969
@Test
7070
fun getSupportedFpsRanges() {
7171
// Act.
72-
val ranges: List<Range<Int>> = cameraInfoAdapter.supportedFrameRateRanges
72+
val ranges: Set<Range<Int>> = cameraInfoAdapter.supportedFrameRateRanges
7373

7474
// Assert.
7575
assertThat(ranges).containsExactly(

camera/camera-camera2-pipe-integration/src/test/java/androidx/camera/camera2/pipe/integration/interop/Camera2CameraInfoTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class Camera2CameraInfoTest {
155155
throw NotImplementedError("Not used in testing")
156156
}
157157

158-
override fun getSupportedFrameRateRanges(): MutableList<Range<Int>> {
158+
override fun getSupportedFrameRateRanges(): Set<Range<Int>> {
159159
throw NotImplementedError("Not used in testing")
160160
}
161161

camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraInfoImpl.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import java.util.ArrayList;
7070
import java.util.Arrays;
7171
import java.util.Collections;
72+
import java.util.HashSet;
7273
import java.util.Iterator;
7374
import java.util.LinkedHashMap;
7475
import java.util.List;
@@ -493,14 +494,14 @@ public Quirks getCameraQuirks() {
493494

494495
@NonNull
495496
@Override
496-
public List<Range<Integer>> getSupportedFrameRateRanges() {
497+
public Set<Range<Integer>> getSupportedFrameRateRanges() {
497498
Range<Integer>[] availableTargetFpsRanges =
498499
mCameraCharacteristicsCompat.get(
499500
CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
500501
if (availableTargetFpsRanges != null) {
501-
return Arrays.asList(availableTargetFpsRanges);
502+
return new HashSet<>(Arrays.asList(availableTargetFpsRanges));
502503
} else {
503-
return Collections.emptyList();
504+
return Collections.emptySet();
504505
}
505506
}
506507

camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2CameraInfoImplTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,8 @@ public void cameraInfo_canReturnSupportedFpsRanges() throws CameraAccessExceptio
658658
CameraInfo cameraInfo2 = new Camera2CameraInfoImpl(CAMERA2_ID,
659659
mCameraManagerCompat);
660660

661-
List<Range<Integer>> resultFpsRanges0 = cameraInfo0.getSupportedFrameRateRanges();
662-
List<Range<Integer>> resultFpsRanges2 = cameraInfo2.getSupportedFrameRateRanges();
661+
Set<Range<Integer>> resultFpsRanges0 = cameraInfo0.getSupportedFrameRateRanges();
662+
Set<Range<Integer>> resultFpsRanges2 = cameraInfo2.getSupportedFrameRateRanges();
663663

664664
assertThat(resultFpsRanges0).containsExactly((Object[]) CAMERA0_AE_FPS_RANGES);
665665
assertThat(resultFpsRanges2).containsExactly((Object[]) CAMERA2_AE_FPS_RANGES);
@@ -673,7 +673,7 @@ public void cameraInfo_returnsEmptyFpsRanges_whenNotSupported()
673673
CameraInfo cameraInfo1 = new Camera2CameraInfoImpl(CAMERA1_ID,
674674
mCameraManagerCompat);
675675

676-
List<Range<Integer>> resultFpsRanges1 = cameraInfo1.getSupportedFrameRateRanges();
676+
Set<Range<Integer>> resultFpsRanges1 = cameraInfo1.getSupportedFrameRateRanges();
677677

678678
assertThat(resultFpsRanges1).isEmpty();
679679
}

camera/camera-core/api/current.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ package androidx.camera.core {
4747
method public default int getLensFacing();
4848
method public int getSensorRotationDegrees();
4949
method public int getSensorRotationDegrees(int);
50-
method public default java.util.List<android.util.Range<java.lang.Integer!>!> getSupportedFrameRateRanges();
50+
method public default java.util.Set<android.util.Range<java.lang.Integer!>!> getSupportedFrameRateRanges();
5151
method public androidx.lifecycle.LiveData<java.lang.Integer!> getTorchState();
5252
method public androidx.lifecycle.LiveData<androidx.camera.core.ZoomState!> getZoomState();
5353
method public boolean hasFlashUnit();

camera/camera-core/api/public_plus_experimental_current.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ package androidx.camera.core {
4747
method public default int getLensFacing();
4848
method public int getSensorRotationDegrees();
4949
method public int getSensorRotationDegrees(int);
50-
method public default java.util.List<android.util.Range<java.lang.Integer!>!> getSupportedFrameRateRanges();
50+
method public default java.util.Set<android.util.Range<java.lang.Integer!>!> getSupportedFrameRateRanges();
5151
method public androidx.lifecycle.LiveData<java.lang.Integer!> getTorchState();
5252
method public androidx.lifecycle.LiveData<androidx.camera.core.ZoomState!> getZoomState();
5353
method public boolean hasFlashUnit();

camera/camera-core/api/restricted_current.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ package androidx.camera.core {
4747
method public default int getLensFacing();
4848
method public int getSensorRotationDegrees();
4949
method public int getSensorRotationDegrees(int);
50-
method public default java.util.List<android.util.Range<java.lang.Integer!>!> getSupportedFrameRateRanges();
50+
method public default java.util.Set<android.util.Range<java.lang.Integer!>!> getSupportedFrameRateRanges();
5151
method public androidx.lifecycle.LiveData<java.lang.Integer!> getTorchState();
5252
method public androidx.lifecycle.LiveData<androidx.camera.core.ZoomState!> getZoomState();
5353
method public boolean hasFlashUnit();

camera/camera-core/src/main/java/androidx/camera/core/CameraInfo.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import java.lang.annotation.Retention;
3535
import java.lang.annotation.RetentionPolicy;
3636
import java.util.Collections;
37-
import java.util.List;
37+
import java.util.Set;
3838

3939
/**
4040
* An interface for retrieving camera information.
@@ -271,8 +271,8 @@ default boolean isZslSupported() {
271271
}
272272

273273
/**
274-
* Returns a list of the frame rate ranges, in frames per second, supported by this device's
275-
* AE algorithm.
274+
* Returns an unordered set of the frame rate ranges, in frames per second, supported by this
275+
* device's AE algorithm.
276276
*
277277
* <p>These are the frame rate ranges that the AE algorithm on the device can support. When
278278
* CameraX is configured to run with the camera2 implementation, this list will be derived
@@ -284,12 +284,14 @@ default boolean isZslSupported() {
284284
* combination of use cases. If attempting to run the device using an unsupported range, there
285285
* may be stability issues or the device may quietly choose another frame rate operating range.
286286
*
287-
* @return The list of FPS ranges supported by the device's AE algorithm
287+
* <p>The returned set does not have any ordering guarantees and frame rate ranges may overlap.
288+
*
289+
* @return The set of FPS ranges supported by the device's AE algorithm
288290
* @see androidx.camera.video.VideoCapture.Builder#setTargetFrameRate(Range)
289291
*/
290292
@NonNull
291-
default List<Range<Integer>> getSupportedFrameRateRanges() {
292-
return Collections.emptyList();
293+
default Set<Range<Integer>> getSupportedFrameRateRanges() {
294+
return Collections.emptySet();
293295
}
294296

295297
/**

camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraInfoInternal.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@
6363
*/
6464
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
6565
public final class FakeCameraInfoInternal implements CameraInfoInternal {
66-
private static final List<Range<Integer>> FAKE_FPS_RANGES = Collections.unmodifiableList(
67-
Arrays.asList(
66+
private static final Set<Range<Integer>> FAKE_FPS_RANGES = Collections.unmodifiableSet(
67+
new HashSet<>(Arrays.asList(
6868
new Range<>(12, 30),
6969
new Range<>(30, 30),
7070
new Range<>(60, 60))
71+
)
7172
);
7273
private static final Set<DynamicRange> DEFAULT_DYNAMIC_RANGES = Collections.singleton(SDR);
7374
private final String mCameraId;
@@ -239,7 +240,7 @@ public Quirks getCameraQuirks() {
239240

240241
@NonNull
241242
@Override
242-
public List<Range<Integer>> getSupportedFrameRateRanges() {
243+
public Set<Range<Integer>> getSupportedFrameRateRanges() {
243244
return FAKE_FPS_RANGES;
244245
}
245246

0 commit comments

Comments
 (0)