fix: blind cam2api changes

This commit is contained in:
cnwxu3ea 2024-07-30 22:44:00 +08:00
parent 7ac553ce9d
commit b35feb64ad

View file

@ -480,8 +480,8 @@ public class Camera2Session {
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<Integer>(30, 60)); captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<Integer>(30, 60));
captureRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD); captureRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD);
isStabilizationAvailable(builder); isStabilizationAvailable(captureRequestBuilder);
isAutoFocusAvailable(builder); isAutoFocusAvailable(captureRequestBuilder);
} }
if (sensorSize != null && Math.abs(currentZoom - 1f) >= 0.01f) { if (sensorSize != null && Math.abs(currentZoom - 1f) >= 0.01f) {
@ -507,22 +507,22 @@ public class Camera2Session {
private void isStabilizationAvailable(CaptureRequest.Builder builder) { private void isStabilizationAvailable(CaptureRequest.Builder builder) {
if (setModeIfAvailable( if (setModeIfAvailable(
builder,
CameraCharacteristics.LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, CameraCharacteristics.LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON, CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON,
builder,
CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE)) { CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE)) {
builder.set( builder.set(
CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE,
CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_OFF); CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_OFF);
FileLog.d("Camera2Sessions use OpticalImageStabilization"); FileLog.d("Camera2Sessions use OpticalImageStabilization");
} else if (setModeIfAvailable( } else if (setModeIfAvailable(
builder, CameraCharacteristics.CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
CameraCharacteristics.CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_ON,
CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_ON, builder,
CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE)) { CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE)) {
builder.set( builder.set(
CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE,
CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_OFF); CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_OFF);
FileLog.d("Camera2Sessions use ElectronicImageStabilization"); FileLog.d("Camera2Sessions use ElectronicImageStabilization");
} else { } else {
FileLog.d("Camera2Sessions stabilization is not available"); FileLog.d("Camera2Sessions stabilization is not available");
@ -531,9 +531,9 @@ public class Camera2Session {
private void isAutoFocusAvailable(CaptureRequest.Builder builder) { private void isAutoFocusAvailable(CaptureRequest.Builder builder) {
if (setModeIfAvailable( if (setModeIfAvailable(
builder,
CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES, CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO,
builder,
CaptureRequest.CONTROL_AF_MODE)) { CaptureRequest.CONTROL_AF_MODE)) {
FileLog.d("Camera2Sessions use continuous AF"); FileLog.d("Camera2Sessions use continuous AF");
} else { } else {
@ -542,8 +542,10 @@ public class Camera2Session {
} }
private boolean setModeIfAvailable( private boolean setModeIfAvailable(
CameraCharacteristics.Key<int[]> key, int desiredMode, CameraCharacteristics.Key<int[]> key,
CaptureRequest.Builder builder, CaptureRequest.Key<Integer> requestKey) { int desiredMode,
CaptureRequest.Builder builder,
CaptureRequest.Key<Integer> requestKey) {
int[] availableModes = cameraCharacteristics.get(key); int[] availableModes = cameraCharacteristics.get(key);
if (availableModes != null && Arrays.stream(availableModes).anyMatch(mode -> mode == desiredMode)) { if (availableModes != null && Arrays.stream(availableModes).anyMatch(mode -> mode == desiredMode)) {
builder.set(requestKey, desiredMode); builder.set(requestKey, desiredMode);