forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[camera_android] Fix camera android deprecation warning for Camcorder…
…Profile.get() (flutter#3273) [camera_android] Fix camera android deprecation warning for CamcorderProfile.get()
- Loading branch information
1 parent
1a1a619
commit 463be34
Showing
14 changed files
with
218 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...a/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraDeviceWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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.annotation.TargetApi; | ||
import android.hardware.camera2.CameraAccessException; | ||
import android.hardware.camera2.CameraCaptureSession; | ||
import android.hardware.camera2.CaptureRequest; | ||
import android.hardware.camera2.params.SessionConfiguration; | ||
import android.os.Build; | ||
import android.os.Handler; | ||
import android.view.Surface; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import java.util.List; | ||
|
||
/** A mockable wrapper for CameraDevice calls. */ | ||
interface CameraDeviceWrapper { | ||
@NonNull | ||
CaptureRequest.Builder createCaptureRequest(int templateType) throws CameraAccessException; | ||
|
||
@TargetApi(Build.VERSION_CODES.P) | ||
void createCaptureSession(SessionConfiguration config) throws CameraAccessException; | ||
|
||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
void createCaptureSession( | ||
@NonNull List<Surface> outputs, | ||
@NonNull CameraCaptureSession.StateCallback callback, | ||
@Nullable Handler handler) | ||
throws CameraAccessException; | ||
|
||
void close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
.../camera_android/android/src/main/java/io/flutter/plugins/camera/CameraPropertiesImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// 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 android.hardware.camera2.CameraAccessException; | ||
import android.hardware.camera2.CameraCharacteristics; | ||
import android.hardware.camera2.CameraManager; | ||
import android.os.Build.VERSION_CODES; | ||
import android.util.Range; | ||
import android.util.Rational; | ||
import android.util.Size; | ||
import androidx.annotation.RequiresApi; | ||
|
||
/** | ||
* Implementation of the @see CameraProperties interface using the @see | ||
* android.hardware.camera2.CameraCharacteristics class to access the different characteristics. | ||
*/ | ||
public class CameraPropertiesImpl implements CameraProperties { | ||
private final CameraCharacteristics cameraCharacteristics; | ||
private final String cameraName; | ||
|
||
public CameraPropertiesImpl(String cameraName, CameraManager cameraManager) | ||
throws CameraAccessException { | ||
this.cameraName = cameraName; | ||
this.cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraName); | ||
} | ||
|
||
@Override | ||
public String getCameraName() { | ||
return cameraName; | ||
} | ||
|
||
@Override | ||
public Range<Integer>[] getControlAutoExposureAvailableTargetFpsRanges() { | ||
return cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); | ||
} | ||
|
||
@Override | ||
public Range<Integer> getControlAutoExposureCompensationRange() { | ||
return cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE); | ||
} | ||
|
||
@Override | ||
public double getControlAutoExposureCompensationStep() { | ||
Rational rational = | ||
cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP); | ||
|
||
return rational == null ? 0.0 : rational.doubleValue(); | ||
} | ||
|
||
@Override | ||
public int[] getControlAutoFocusAvailableModes() { | ||
return cameraCharacteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES); | ||
} | ||
|
||
@Override | ||
public Integer getControlMaxRegionsAutoExposure() { | ||
return cameraCharacteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AE); | ||
} | ||
|
||
@Override | ||
public Integer getControlMaxRegionsAutoFocus() { | ||
return cameraCharacteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF); | ||
} | ||
|
||
@RequiresApi(api = VERSION_CODES.P) | ||
@Override | ||
public int[] getDistortionCorrectionAvailableModes() { | ||
return cameraCharacteristics.get(CameraCharacteristics.DISTORTION_CORRECTION_AVAILABLE_MODES); | ||
} | ||
|
||
@Override | ||
public Boolean getFlashInfoAvailable() { | ||
return cameraCharacteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE); | ||
} | ||
|
||
@Override | ||
public int getLensFacing() { | ||
return cameraCharacteristics.get(CameraCharacteristics.LENS_FACING); | ||
} | ||
|
||
@Override | ||
public Float getLensInfoMinimumFocusDistance() { | ||
return cameraCharacteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE); | ||
} | ||
|
||
@Override | ||
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); | ||
} | ||
|
||
@Override | ||
public Size getSensorInfoPixelArraySize() { | ||
return cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE); | ||
} | ||
|
||
@RequiresApi(api = VERSION_CODES.M) | ||
@Override | ||
public Rect getSensorInfoPreCorrectionActiveArraySize() { | ||
return cameraCharacteristics.get( | ||
CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE); | ||
} | ||
|
||
@Override | ||
public int getSensorOrientation() { | ||
return cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); | ||
} | ||
|
||
@Override | ||
public int getHardwareLevel() { | ||
return cameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL); | ||
} | ||
|
||
@Override | ||
public int[] getAvailableNoiseReductionModes() { | ||
return cameraCharacteristics.get( | ||
CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES); | ||
} | ||
} |
Oops, something went wrong.