正在查看: Aplazo v2.4.68 应用的 SupportedSurfaceCombination.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Aplazo v2.4.68 应用的 SupportedSurfaceCombination.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.veriff.sdk.camera.camera2.internal;
import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.util.Pair;
import android.util.Rational;
import android.util.Size;
import com.veriff.sdk.camera.camera2.internal.compat.CameraAccessExceptionCompat;
import com.veriff.sdk.camera.camera2.internal.compat.CameraCharacteristicsCompat;
import com.veriff.sdk.camera.camera2.internal.compat.CameraManagerCompat;
import com.veriff.sdk.camera.camera2.internal.compat.workaround.ExcludedSupportedSizesContainer;
import com.veriff.sdk.camera.camera2.internal.compat.workaround.ExtraSupportedSurfaceCombinationsContainer;
import com.veriff.sdk.camera.camera2.internal.compat.workaround.ResolutionCorrector;
import com.veriff.sdk.camera.camera2.internal.compat.workaround.TargetAspectRatio;
import com.veriff.sdk.camera.core.CameraUnavailableException;
import com.veriff.sdk.camera.core.Logger;
import com.veriff.sdk.camera.core.impl.ImageOutputConfig;
import com.veriff.sdk.camera.core.impl.SurfaceCombination;
import com.veriff.sdk.camera.core.impl.SurfaceConfig;
import com.veriff.sdk.camera.core.impl.SurfaceSizeDefinition;
import com.veriff.sdk.camera.core.impl.UseCaseConfig;
import com.veriff.sdk.camera.core.impl.utils.CameraOrientationUtil;
import com.veriff.sdk.camera.core.impl.utils.CompareSizesByArea;
import gd.AbstractC0117a;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
final class SupportedSurfaceCombination {
private final CamcorderProfileHelper mCamcorderProfileHelper;
private final String mCameraId;
private final CameraCharacteristicsCompat mCharacteristics;
private final DisplayInfoManager mDisplayInfoManager;
private final ExcludedSupportedSizesContainer mExcludedSupportedSizesContainer;
private final ExtraSupportedSurfaceCombinationsContainer mExtraSupportedSurfaceCombinationsContainer;
private final int mHardwareLevel;
private final boolean mIsSensorLandscapeResolution;
private SurfaceSizeDefinition mSurfaceSizeDefinition;
private static final Size DEFAULT_SIZE = new Size(640, 480);
private static final Size ZERO_SIZE = new Size(0, 0);
private static final Size QUALITY_1080P_SIZE = new Size(1920, 1080);
private static final Size QUALITY_480P_SIZE = new Size(720, 480);
private static final Rational ASPECT_RATIO_4_3 = new Rational(4, 3);
private static final Rational ASPECT_RATIO_3_4 = new Rational(3, 4);
private static final Rational ASPECT_RATIO_16_9 = new Rational(16, 9);
private static final Rational ASPECT_RATIO_9_16 = new Rational(9, 16);
private final List<SurfaceCombination> mSurfaceCombinations = new ArrayList();
private final Map<Integer, Size> mMaxSizeCache = new HashMap();
private final Map<Integer, List<Size>> mExcludedSizeListCache = new HashMap();
private boolean mIsRawSupported = false;
private boolean mIsBurstCaptureSupported = false;
private Map<Integer, Size[]> mOutputSizesCache = new HashMap();
private final ResolutionCorrector mResolutionCorrector = new ResolutionCorrector();
public static final class CompareAspectRatiosByDistanceToTargetRatio implements Comparator<Rational> {
private Rational mTargetRatio;
public CompareAspectRatiosByDistanceToTargetRatio(Rational rational) {
this.mTargetRatio = rational;
}
@Override
public int compare(Rational rational, Rational rational2) {
if (rational.equals(rational2)) {
return 0;
}
return (int) Math.signum(Math.abs(rational.floatValue() - this.mTargetRatio.floatValue()) - Math.abs(rational2.floatValue() - this.mTargetRatio.floatValue()));
}
}
public SupportedSurfaceCombination(Context context, String str, CameraManagerCompat cameraManagerCompat, CamcorderProfileHelper camcorderProfileHelper) throws CameraUnavailableException {
str.getClass();
this.mCameraId = str;
camcorderProfileHelper.getClass();
this.mCamcorderProfileHelper = camcorderProfileHelper;
this.mExcludedSupportedSizesContainer = new ExcludedSupportedSizesContainer(str);
this.mExtraSupportedSurfaceCombinationsContainer = new ExtraSupportedSurfaceCombinationsContainer();
this.mDisplayInfoManager = DisplayInfoManager.getInstance(context);
try {
CameraCharacteristicsCompat cameraCharacteristicsCompat = cameraManagerCompat.getCameraCharacteristicsCompat(str);
this.mCharacteristics = cameraCharacteristicsCompat;
Integer num = (Integer) cameraCharacteristicsCompat.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
this.mHardwareLevel = num != null ? num.intValue() : 2;
this.mIsSensorLandscapeResolution = isSensorLandscapeResolution();
generateSupportedCombinationList();
generateSurfaceSizeDefinition();
checkCustomization();
} catch (CameraAccessExceptionCompat e) {
throw CameraUnavailableExceptionHelper.createFrom(e);
}
}
private void checkCustomization() {
}
private Size[] doGetAllOutputSizesByFormat(int i) {
StreamConfigurationMap streamConfigurationMap = (StreamConfigurationMap) this.mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
if (streamConfigurationMap == null) {
throw new IllegalArgumentException("Can not retrieve SCALER_STREAM_CONFIGURATION_MAP");
}
Size[] outputSizes = streamConfigurationMap.getOutputSizes(i);
if (outputSizes == null) {
throw new IllegalArgumentException(AbstractC0117a.g(i, "Can not get supported output size for the format: "));
}
Size[] excludeProblematicSizes = excludeProblematicSizes(outputSizes, i);
Arrays.sort(excludeProblematicSizes, new CompareSizesByArea(true));
return excludeProblematicSizes;
}
private Size[] excludeProblematicSizes(Size[] sizeArr, int i) {
List<Size> fetchExcludedSizes = fetchExcludedSizes(i);
ArrayList arrayList = new ArrayList(Arrays.asList(sizeArr));
arrayList.removeAll(fetchExcludedSizes);
return (Size[]) arrayList.toArray(new Size[0]);
}
private List<Size> fetchExcludedSizes(int i) {
List<Size> list = this.mExcludedSizeListCache.get(Integer.valueOf(i));
if (list != null) {
return list;
}
List<Size> list2 = this.mExcludedSupportedSizesContainer.get(i);
this.mExcludedSizeListCache.put(Integer.valueOf(i), list2);
return list2;
}
private Size fetchMaxSize(int i) {
Size size = this.mMaxSizeCache.get(Integer.valueOf(i));
if (size != null) {
return size;
}
Size maxOutputSizeByFormat = getMaxOutputSizeByFormat(i);
this.mMaxSizeCache.put(Integer.valueOf(i), maxOutputSizeByFormat);
return maxOutputSizeByFormat;
}
private Size flipSizeByRotation(Size size, int i) {
return (size == null || !isRotationNeeded(i)) ? size : new Size(size.getHeight(), size.getWidth());
}
private void generateSupportedCombinationList() {
this.mSurfaceCombinations.addAll(getLegacySupportedCombinationList());
int i = this.mHardwareLevel;
if (i == 0 || i == 1 || i == 3) {
this.mSurfaceCombinations.addAll(getLimitedSupportedCombinationList());
}
int i2 = this.mHardwareLevel;
if (i2 == 1 || i2 == 3) {
this.mSurfaceCombinations.addAll(getFullSupportedCombinationList());
}
int[] iArr = (int[]) this.mCharacteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
if (iArr != null) {
for (int i3 : iArr) {
if (i3 == 3) {
this.mIsRawSupported = true;
} else if (i3 == 6) {
this.mIsBurstCaptureSupported = true;
}
}
}
if (this.mIsRawSupported) {
this.mSurfaceCombinations.addAll(getRAWSupportedCombinationList());
}
if (this.mIsBurstCaptureSupported && this.mHardwareLevel == 0) {
this.mSurfaceCombinations.addAll(getBurstSupportedCombinationList());
}
if (this.mHardwareLevel == 3) {
this.mSurfaceCombinations.addAll(getLevel3SupportedCombinationList());
}
this.mSurfaceCombinations.addAll(this.mExtraSupportedSurfaceCombinationsContainer.get(this.mCameraId, this.mHardwareLevel));
}
private void generateSurfaceSizeDefinition() {
this.mSurfaceSizeDefinition = SurfaceSizeDefinition.create(new Size(640, 480), this.mDisplayInfoManager.getPreviewSize(), getRecordSize());
}
private Size[] getAllOutputSizesByFormat(int i) {
Size[] sizeArr = this.mOutputSizesCache.get(Integer.valueOf(i));
if (sizeArr != null) {
return sizeArr;
}
Size[] doGetAllOutputSizesByFormat = doGetAllOutputSizesByFormat(i);
this.mOutputSizesCache.put(Integer.valueOf(i), doGetAllOutputSizesByFormat);
return doGetAllOutputSizesByFormat;
}
private List<List<Size>> getAllPossibleSizeArrangements(List<List<Size>> list) {
Iterator<List<Size>> it = list.iterator();
int i = 1;
while (it.hasNext()) {
i *= it.next().size();
}
if (i == 0) {
throw new IllegalArgumentException("Failed to find supported resolutions.");
}
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 < i; i2++) {
arrayList.add(new ArrayList());
}
int size = i / list.get(0).size();
int i3 = i;
for (int i4 = 0; i4 < list.size(); i4++) {
List<Size> list2 = list.get(i4);
for (int i5 = 0; i5 < i; i5++) {
((List) arrayList.get(i5)).add(list2.get((i5 % i3) / size));
}
if (i4 < list.size() - 1) {
i3 = size;
size /= list.get(i4 + 1).size();
}
}
return arrayList;
}
private static int getArea(Size size) {
return size.getHeight() * size.getWidth();
}
private SurfaceConfig.ConfigType getConfigType(int i) {
return i == 35 ? SurfaceConfig.ConfigType.YUV : i == 256 ? SurfaceConfig.ConfigType.JPEG : i == 32 ? SurfaceConfig.ConfigType.RAW : SurfaceConfig.ConfigType.PRIV;
}
private Size[] getCustomizedSupportSizesFromConfig(int i, ImageOutputConfig imageOutputConfig) {
Size[] sizeArr = null;
List<Pair<Integer, Size[]>> supportedResolutions = imageOutputConfig.getSupportedResolutions(null);
if (supportedResolutions != null) {
Iterator<Pair<Integer, Size[]>> it = supportedResolutions.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Pair<Integer, Size[]> next = it.next();
if (((Integer) next.first).intValue() == i) {
sizeArr = (Size[]) next.second;
break;
}
}
}
if (sizeArr == null) {
return sizeArr;
}
Size[] excludeProblematicSizes = excludeProblematicSizes(sizeArr, i);
Arrays.sort(excludeProblematicSizes, new CompareSizesByArea(true));
return excludeProblematicSizes;
}
private Size getRecordSize() {
try {
int parseInt = Integer.parseInt(this.mCameraId);
CamcorderProfile camcorderProfile = this.mCamcorderProfileHelper.hasProfile(parseInt, 1) ? this.mCamcorderProfileHelper.get(parseInt, 1) : null;
return camcorderProfile != null ? new Size(camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight) : getRecordSizeByHasProfile(parseInt);
} catch (NumberFormatException unused) {
return getRecordSizeFromStreamConfigurationMap();
}
}
private Size getRecordSizeByHasProfile(int i) {
Size size = QUALITY_480P_SIZE;
CamcorderProfile camcorderProfile = this.mCamcorderProfileHelper.hasProfile(i, 10) ? this.mCamcorderProfileHelper.get(i, 10) : this.mCamcorderProfileHelper.hasProfile(i, 8) ? this.mCamcorderProfileHelper.get(i, 8) : this.mCamcorderProfileHelper.hasProfile(i, 12) ? this.mCamcorderProfileHelper.get(i, 12) : this.mCamcorderProfileHelper.hasProfile(i, 6) ? this.mCamcorderProfileHelper.get(i, 6) : this.mCamcorderProfileHelper.hasProfile(i, 5) ? this.mCamcorderProfileHelper.get(i, 5) : this.mCamcorderProfileHelper.hasProfile(i, 4) ? this.mCamcorderProfileHelper.get(i, 4) : null;
return camcorderProfile != null ? new Size(camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight) : size;
}
private Size getRecordSizeFromStreamConfigurationMap() {
StreamConfigurationMap streamConfigurationMap = (StreamConfigurationMap) this.mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
if (streamConfigurationMap == null) {
throw new IllegalArgumentException("Can not retrieve SCALER_STREAM_CONFIGURATION_MAP");
}
Size[] outputSizes = streamConfigurationMap.getOutputSizes(MediaRecorder.class);
if (outputSizes == null) {
return QUALITY_480P_SIZE;
}
Arrays.sort(outputSizes, new CompareSizesByArea(true));
for (Size size : outputSizes) {
int width = size.getWidth();
Size size2 = QUALITY_1080P_SIZE;
if (width <= size2.getWidth() && size.getHeight() <= size2.getHeight()) {
return size;
}
}
return QUALITY_480P_SIZE;
}
private Rational getTargetAspectRatio(ImageOutputConfig imageOutputConfig) {
Rational rational;
int i = new TargetAspectRatio().get(this.mCameraId, this.mCharacteristics);
if (i == 0) {
rational = this.mIsSensorLandscapeResolution ? ASPECT_RATIO_4_3 : ASPECT_RATIO_3_4;
} else if (i == 1) {
rational = this.mIsSensorLandscapeResolution ? ASPECT_RATIO_16_9 : ASPECT_RATIO_9_16;
} else {
if (i == 2) {
Size fetchMaxSize = fetchMaxSize(256);
return new Rational(fetchMaxSize.getWidth(), fetchMaxSize.getHeight());
}
if (i != 3) {
return null;
}
Size targetSize = getTargetSize(imageOutputConfig);
if (!imageOutputConfig.hasTargetAspectRatio()) {
if (targetSize != null) {
return new Rational(targetSize.getWidth(), targetSize.getHeight());
}
return null;
}
int targetAspectRatio = imageOutputConfig.getTargetAspectRatio();
if (targetAspectRatio == 0) {
rational = this.mIsSensorLandscapeResolution ? ASPECT_RATIO_4_3 : ASPECT_RATIO_3_4;
} else {
if (targetAspectRatio != 1) {
Logger.e("SupportedSurfaceCombination", "Undefined target aspect ratio: " + targetAspectRatio);
return null;
}
rational = this.mIsSensorLandscapeResolution ? ASPECT_RATIO_16_9 : ASPECT_RATIO_9_16;
}
}
return rational;
}
private Size getTargetSize(ImageOutputConfig imageOutputConfig) {
return flipSizeByRotation(imageOutputConfig.getTargetResolution(null), imageOutputConfig.getTargetRotation(0));
}
private List<Integer> getUseCasesPriorityOrder(List<UseCaseConfig<?>> list) {
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
Iterator<UseCaseConfig<?>> it = list.iterator();
while (it.hasNext()) {
int surfaceOccupancyPriority = it.next().getSurfaceOccupancyPriority(0);
if (!arrayList2.contains(Integer.valueOf(surfaceOccupancyPriority))) {
arrayList2.add(Integer.valueOf(surfaceOccupancyPriority));
}
}
Collections.sort(arrayList2);
Collections.reverse(arrayList2);
Iterator it2 = arrayList2.iterator();
while (it2.hasNext()) {
int intValue = ((Integer) it2.next()).intValue();
for (UseCaseConfig<?> useCaseConfig : list) {
if (intValue == useCaseConfig.getSurfaceOccupancyPriority(0)) {
arrayList.add(Integer.valueOf(list.indexOf(useCaseConfig)));
}
}
}
return arrayList;
}
private Map<Rational, List<Size>> groupSizesByAspectRatio(List<Size> list) {
HashMap hashMap = new HashMap();
hashMap.put(ASPECT_RATIO_4_3, new ArrayList());
hashMap.put(ASPECT_RATIO_16_9, new ArrayList());
for (Size size : list) {
Rational rational = null;
for (Rational rational2 : hashMap.keySet()) {
if (hasMatchingAspectRatio(size, rational2)) {
List list2 = (List) hashMap.get(rational2);
if (!list2.contains(size)) {
list2.add(size);
}
rational = rational2;
}
}
if (rational == null) {
hashMap.put(new Rational(size.getWidth(), size.getHeight()), new ArrayList(Collections.singleton(size)));
}
}
return hashMap;
}
public static boolean hasMatchingAspectRatio(Size size, Rational rational) {
if (rational == null) {
return false;
}
if (rational.equals(new Rational(size.getWidth(), size.getHeight()))) {
return true;
}
if (getArea(size) >= getArea(DEFAULT_SIZE)) {
return isPossibleMod16FromAspectRatio(size, rational);
}
return false;
}
private static boolean isPossibleMod16FromAspectRatio(Size size, Rational rational) {
int width = size.getWidth();
int height = size.getHeight();
Rational rational2 = new Rational(rational.getDenominator(), rational.getNumerator());
int i = width % 16;
if (i == 0 && height % 16 == 0) {
return ratioIntersectsMod16Segment(Math.max(0, height + (-16)), width, rational) || ratioIntersectsMod16Segment(Math.max(0, width + (-16)), height, rational2);
}
if (i == 0) {
return ratioIntersectsMod16Segment(height, width, rational);
}
if (height % 16 == 0) {
return ratioIntersectsMod16Segment(width, height, rational2);
}
return false;
}
private boolean isRotationNeeded(int i) {
Integer num = (Integer) this.mCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
Q1.g.g(num, "Camera HAL in bad state, unable to retrieve the SENSOR_ORIENTATION");
int surfaceRotationToDegrees = CameraOrientationUtil.surfaceRotationToDegrees(i);
Integer num2 = (Integer) this.mCharacteristics.get(CameraCharacteristics.LENS_FACING);
Q1.g.g(num2, "Camera HAL in bad state, unable to retrieve the LENS_FACING");
int relativeImageRotation = CameraOrientationUtil.getRelativeImageRotation(surfaceRotationToDegrees, num.intValue(), 1 == num2.intValue());
return relativeImageRotation == 90 || relativeImageRotation == 270;
}
private boolean isSensorLandscapeResolution() {
Size size = (Size) this.mCharacteristics.get(CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE);
return size == null || size.getWidth() >= size.getHeight();
}
private static boolean ratioIntersectsMod16Segment(int i, int i2, Rational rational) {
Q1.g.c(i2 % 16 == 0);
double numerator = (rational.getNumerator() * i) / rational.getDenominator();
return numerator > ((double) Math.max(0, i2 + (-16))) && numerator < ((double) (i2 + 16));
}
private void refreshPreviewSize() {
this.mDisplayInfoManager.refresh();
if (this.mSurfaceSizeDefinition == null) {
generateSurfaceSizeDefinition();
} else {
this.mSurfaceSizeDefinition = SurfaceSizeDefinition.create(this.mSurfaceSizeDefinition.getAnalysisSize(), this.mDisplayInfoManager.getPreviewSize(), this.mSurfaceSizeDefinition.getRecordSize());
}
}
private void removeSupportedSizesByTargetSize(List<Size> list, Size size) {
if (list == null || list.isEmpty()) {
return;
}
ArrayList arrayList = new ArrayList();
int i = -1;
int i2 = 0;
while (true) {
int i3 = i2;
int i4 = i;
i = i3;
if (i >= list.size()) {
break;
}
Size size2 = list.get(i);
if (size2.getWidth() < size.getWidth() || size2.getHeight() < size.getHeight()) {
break;
}
if (i4 >= 0) {
arrayList.add(list.get(i4));
}
i2 = i + 1;
}
list.removeAll(arrayList);
}
public boolean checkSupported(List<SurfaceConfig> list) {
Iterator<SurfaceCombination> it = this.mSurfaceCombinations.iterator();
boolean z = false;
while (it.hasNext() && !(z = it.next().isSupported(list))) {
}
return z;
}
public List<SurfaceCombination> getBurstSupportedCombinationList() {
ArrayList arrayList = new ArrayList();
SurfaceCombination surfaceCombination = new SurfaceCombination();
SurfaceConfig.ConfigType configType = SurfaceConfig.ConfigType.PRIV;
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.PREVIEW;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigSize configSize2 = SurfaceConfig.ConfigSize.MAXIMUM;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize2));
arrayList.add(surfaceCombination);
SurfaceCombination surfaceCombination2 = new SurfaceCombination();
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigType configType2 = SurfaceConfig.ConfigType.YUV;
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType2, configSize2));
arrayList.add(surfaceCombination2);
SurfaceCombination surfaceCombination3 = new SurfaceCombination();
A2.g.v(configType2, configSize, surfaceCombination3, configType2, configSize2);
arrayList.add(surfaceCombination3);
return arrayList;
}
public List<SurfaceCombination> getFullSupportedCombinationList() {
ArrayList arrayList = new ArrayList();
SurfaceCombination surfaceCombination = new SurfaceCombination();
SurfaceConfig.ConfigType configType = SurfaceConfig.ConfigType.PRIV;
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.PREVIEW;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigSize configSize2 = SurfaceConfig.ConfigSize.MAXIMUM;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize2));
arrayList.add(surfaceCombination);
SurfaceCombination surfaceCombination2 = new SurfaceCombination();
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigType configType2 = SurfaceConfig.ConfigType.YUV;
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType2, configSize2));
arrayList.add(surfaceCombination2);
SurfaceCombination surfaceCombination3 = new SurfaceCombination();
A2.g.v(configType2, configSize, surfaceCombination3, configType2, configSize2);
arrayList.add(surfaceCombination3);
SurfaceCombination surfaceCombination4 = new SurfaceCombination();
A2.g.v(configType, configSize, surfaceCombination4, configType, configSize);
surfaceCombination4.addSurfaceConfig(SurfaceConfig.create(SurfaceConfig.ConfigType.JPEG, configSize2));
arrayList.add(surfaceCombination4);
SurfaceCombination surfaceCombination5 = new SurfaceCombination();
SurfaceConfig.ConfigSize configSize3 = SurfaceConfig.ConfigSize.ANALYSIS;
A2.g.v(configType2, configSize3, surfaceCombination5, configType, configSize);
surfaceCombination5.addSurfaceConfig(SurfaceConfig.create(configType2, configSize2));
arrayList.add(surfaceCombination5);
SurfaceCombination surfaceCombination6 = new SurfaceCombination();
A2.g.v(configType2, configSize3, surfaceCombination6, configType2, configSize);
surfaceCombination6.addSurfaceConfig(SurfaceConfig.create(configType2, configSize2));
arrayList.add(surfaceCombination6);
return arrayList;
}
public List<SurfaceCombination> getLegacySupportedCombinationList() {
ArrayList arrayList = new ArrayList();
SurfaceCombination surfaceCombination = new SurfaceCombination();
SurfaceConfig.ConfigType configType = SurfaceConfig.ConfigType.PRIV;
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.MAXIMUM;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
arrayList.add(surfaceCombination);
SurfaceCombination surfaceCombination2 = new SurfaceCombination();
SurfaceConfig.ConfigType configType2 = SurfaceConfig.ConfigType.JPEG;
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType2, configSize));
arrayList.add(surfaceCombination2);
SurfaceCombination surfaceCombination3 = new SurfaceCombination();
SurfaceConfig.ConfigType configType3 = SurfaceConfig.ConfigType.YUV;
surfaceCombination3.addSurfaceConfig(SurfaceConfig.create(configType3, configSize));
arrayList.add(surfaceCombination3);
SurfaceCombination surfaceCombination4 = new SurfaceCombination();
SurfaceConfig.ConfigSize configSize2 = SurfaceConfig.ConfigSize.PREVIEW;
A2.g.v(configType, configSize2, surfaceCombination4, configType2, configSize);
arrayList.add(surfaceCombination4);
SurfaceCombination surfaceCombination5 = new SurfaceCombination();
A2.g.v(configType3, configSize2, surfaceCombination5, configType2, configSize);
arrayList.add(surfaceCombination5);
SurfaceCombination surfaceCombination6 = new SurfaceCombination();
A2.g.v(configType, configSize2, surfaceCombination6, configType, configSize2);
arrayList.add(surfaceCombination6);
SurfaceCombination surfaceCombination7 = new SurfaceCombination();
A2.g.v(configType, configSize2, surfaceCombination7, configType3, configSize2);
arrayList.add(surfaceCombination7);
SurfaceCombination surfaceCombination8 = new SurfaceCombination();
A2.g.v(configType, configSize2, surfaceCombination8, configType3, configSize2);
surfaceCombination8.addSurfaceConfig(SurfaceConfig.create(configType2, configSize));
arrayList.add(surfaceCombination8);
return arrayList;
}
public List<SurfaceCombination> getLevel3SupportedCombinationList() {
ArrayList arrayList = new ArrayList();
SurfaceCombination surfaceCombination = new SurfaceCombination();
SurfaceConfig.ConfigType configType = SurfaceConfig.ConfigType.PRIV;
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.PREVIEW;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigSize configSize2 = SurfaceConfig.ConfigSize.ANALYSIS;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize2));
SurfaceConfig.ConfigType configType2 = SurfaceConfig.ConfigType.YUV;
SurfaceConfig.ConfigSize configSize3 = SurfaceConfig.ConfigSize.MAXIMUM;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType2, configSize3));
SurfaceConfig.ConfigType configType3 = SurfaceConfig.ConfigType.RAW;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType3, configSize3));
arrayList.add(surfaceCombination);
SurfaceCombination surfaceCombination2 = new SurfaceCombination();
A2.g.v(configType, configSize, surfaceCombination2, configType, configSize2);
A2.g.v(SurfaceConfig.ConfigType.JPEG, configSize3, surfaceCombination2, configType3, configSize3);
arrayList.add(surfaceCombination2);
return arrayList;
}
public List<SurfaceCombination> getLimitedSupportedCombinationList() {
ArrayList arrayList = new ArrayList();
SurfaceCombination surfaceCombination = new SurfaceCombination();
SurfaceConfig.ConfigType configType = SurfaceConfig.ConfigType.PRIV;
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.PREVIEW;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigSize configSize2 = SurfaceConfig.ConfigSize.RECORD;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize2));
arrayList.add(surfaceCombination);
SurfaceCombination surfaceCombination2 = new SurfaceCombination();
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
SurfaceConfig.ConfigType configType2 = SurfaceConfig.ConfigType.YUV;
surfaceCombination2.addSurfaceConfig(SurfaceConfig.create(configType2, configSize2));
arrayList.add(surfaceCombination2);
SurfaceCombination surfaceCombination3 = new SurfaceCombination();
A2.g.v(configType2, configSize, surfaceCombination3, configType2, configSize2);
arrayList.add(surfaceCombination3);
SurfaceCombination surfaceCombination4 = new SurfaceCombination();
A2.g.v(configType, configSize, surfaceCombination4, configType, configSize2);
SurfaceConfig.ConfigType configType3 = SurfaceConfig.ConfigType.JPEG;
surfaceCombination4.addSurfaceConfig(SurfaceConfig.create(configType3, configSize2));
arrayList.add(surfaceCombination4);
SurfaceCombination surfaceCombination5 = new SurfaceCombination();
A2.g.v(configType, configSize, surfaceCombination5, configType2, configSize2);
surfaceCombination5.addSurfaceConfig(SurfaceConfig.create(configType3, configSize2));
arrayList.add(surfaceCombination5);
SurfaceCombination surfaceCombination6 = new SurfaceCombination();
A2.g.v(configType2, configSize, surfaceCombination6, configType2, configSize);
surfaceCombination6.addSurfaceConfig(SurfaceConfig.create(configType3, SurfaceConfig.ConfigSize.MAXIMUM));
arrayList.add(surfaceCombination6);
return arrayList;
}
public Size getMaxOutputSizeByFormat(int i) {
return (Size) Collections.max(Arrays.asList(getAllOutputSizesByFormat(i)), new CompareSizesByArea());
}
public List<SurfaceCombination> getRAWSupportedCombinationList() {
ArrayList arrayList = new ArrayList();
SurfaceCombination surfaceCombination = new SurfaceCombination();
SurfaceConfig.ConfigType configType = SurfaceConfig.ConfigType.RAW;
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.MAXIMUM;
surfaceCombination.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
arrayList.add(surfaceCombination);
SurfaceCombination surfaceCombination2 = new SurfaceCombination();
SurfaceConfig.ConfigType configType2 = SurfaceConfig.ConfigType.PRIV;
SurfaceConfig.ConfigSize configSize2 = SurfaceConfig.ConfigSize.PREVIEW;
A2.g.v(configType2, configSize2, surfaceCombination2, configType, configSize);
arrayList.add(surfaceCombination2);
SurfaceCombination surfaceCombination3 = new SurfaceCombination();
SurfaceConfig.ConfigType configType3 = SurfaceConfig.ConfigType.YUV;
A2.g.v(configType3, configSize2, surfaceCombination3, configType, configSize);
arrayList.add(surfaceCombination3);
SurfaceCombination surfaceCombination4 = new SurfaceCombination();
A2.g.v(configType2, configSize2, surfaceCombination4, configType2, configSize2);
surfaceCombination4.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
arrayList.add(surfaceCombination4);
SurfaceCombination surfaceCombination5 = new SurfaceCombination();
A2.g.v(configType2, configSize2, surfaceCombination5, configType3, configSize2);
surfaceCombination5.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
arrayList.add(surfaceCombination5);
SurfaceCombination surfaceCombination6 = new SurfaceCombination();
A2.g.v(configType3, configSize2, surfaceCombination6, configType3, configSize2);
surfaceCombination6.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
arrayList.add(surfaceCombination6);
SurfaceCombination surfaceCombination7 = new SurfaceCombination();
surfaceCombination7.addSurfaceConfig(SurfaceConfig.create(configType2, configSize2));
SurfaceConfig.ConfigType configType4 = SurfaceConfig.ConfigType.JPEG;
A2.g.v(configType4, configSize, surfaceCombination7, configType, configSize);
arrayList.add(surfaceCombination7);
SurfaceCombination surfaceCombination8 = new SurfaceCombination();
A2.g.v(configType3, configSize2, surfaceCombination8, configType4, configSize);
surfaceCombination8.addSurfaceConfig(SurfaceConfig.create(configType, configSize));
arrayList.add(surfaceCombination8);
return arrayList;
}
public Map<UseCaseConfig<?>, Size> getSuggestedResolutions(List<SurfaceConfig> list, List<UseCaseConfig<?>> list2) {
HashMap hashMap;
refreshPreviewSize();
ArrayList arrayList = new ArrayList(list);
Iterator<UseCaseConfig<?>> it = list2.iterator();
while (it.hasNext()) {
arrayList.add(transformSurfaceConfig(it.next().getInputFormat(), new Size(640, 480)));
}
if (!checkSupported(arrayList)) {
throw new IllegalArgumentException("No supported surface combination is found for camera device - Id : " + this.mCameraId + ". May be attempting to bind too many use cases. Existing surfaces: " + list + " New configs: " + list2);
}
List<Integer> useCasesPriorityOrder = getUseCasesPriorityOrder(list2);
ArrayList arrayList2 = new ArrayList();
Iterator<Integer> it2 = useCasesPriorityOrder.iterator();
while (it2.hasNext()) {
arrayList2.add(getSupportedOutputSizes(list2.get(it2.next().intValue())));
}
Iterator<List<Size>> it3 = getAllPossibleSizeArrangements(arrayList2).iterator();
while (true) {
if (!it3.hasNext()) {
hashMap = null;
break;
}
List<Size> next = it3.next();
ArrayList arrayList3 = new ArrayList(list);
for (int i = 0; i < next.size(); i++) {
arrayList3.add(transformSurfaceConfig(list2.get(useCasesPriorityOrder.get(i).intValue()).getInputFormat(), next.get(i)));
}
if (checkSupported(arrayList3)) {
hashMap = new HashMap();
for (UseCaseConfig<?> useCaseConfig : list2) {
hashMap.put(useCaseConfig, next.get(useCasesPriorityOrder.indexOf(Integer.valueOf(list2.indexOf(useCaseConfig)))));
}
}
}
if (hashMap != null) {
return hashMap;
}
throw new IllegalArgumentException("No supported surface combination is found for camera device - Id : " + this.mCameraId + " and Hardware level: " + this.mHardwareLevel + ". May be the specified resolution is too large and not supported. Existing surfaces: " + list + " New configs: " + list2);
}
public List<Size> getSupportedOutputSizes(UseCaseConfig<?> useCaseConfig) {
int inputFormat = useCaseConfig.getInputFormat();
ImageOutputConfig imageOutputConfig = (ImageOutputConfig) useCaseConfig;
Size[] customizedSupportSizesFromConfig = getCustomizedSupportSizesFromConfig(inputFormat, imageOutputConfig);
if (customizedSupportSizesFromConfig == null) {
customizedSupportSizesFromConfig = getAllOutputSizesByFormat(inputFormat);
}
ArrayList arrayList = new ArrayList();
Size maxResolution = imageOutputConfig.getMaxResolution(null);
Size maxOutputSizeByFormat = getMaxOutputSizeByFormat(inputFormat);
if (maxResolution == null || getArea(maxOutputSizeByFormat) < getArea(maxResolution)) {
maxResolution = maxOutputSizeByFormat;
}
Arrays.sort(customizedSupportSizesFromConfig, new CompareSizesByArea(true));
Size targetSize = getTargetSize(imageOutputConfig);
Size size = DEFAULT_SIZE;
int area = getArea(size);
if (getArea(maxResolution) < area) {
size = ZERO_SIZE;
} else if (targetSize != null && getArea(targetSize) < area) {
size = targetSize;
}
for (Size size2 : customizedSupportSizesFromConfig) {
if (getArea(size2) <= getArea(maxResolution) && getArea(size2) >= getArea(size) && !arrayList.contains(size2)) {
arrayList.add(size2);
}
}
if (arrayList.isEmpty()) {
throw new IllegalArgumentException(AbstractC0117a.g(inputFormat, "Can not get supported output size under supported maximum for the format: "));
}
Rational targetAspectRatio = getTargetAspectRatio(imageOutputConfig);
if (targetSize == null) {
targetSize = imageOutputConfig.getDefaultResolution(null);
}
ArrayList arrayList2 = new ArrayList();
new HashMap();
if (targetAspectRatio == null) {
arrayList2.addAll(arrayList);
if (targetSize != null) {
removeSupportedSizesByTargetSize(arrayList2, targetSize);
}
} else {
Map<Rational, List<Size>> groupSizesByAspectRatio = groupSizesByAspectRatio(arrayList);
if (targetSize != null) {
Iterator<Rational> it = groupSizesByAspectRatio.keySet().iterator();
while (it.hasNext()) {
removeSupportedSizesByTargetSize(groupSizesByAspectRatio.get(it.next()), targetSize);
}
}
ArrayList arrayList3 = new ArrayList(groupSizesByAspectRatio.keySet());
Collections.sort(arrayList3, new CompareAspectRatiosByDistanceToTargetRatio(targetAspectRatio));
Iterator it2 = arrayList3.iterator();
while (it2.hasNext()) {
for (Size size3 : groupSizesByAspectRatio.get((Rational) it2.next())) {
if (!arrayList2.contains(size3)) {
arrayList2.add(size3);
}
}
}
}
return this.mResolutionCorrector.insertOrPrioritize(getConfigType(useCaseConfig.getInputFormat()), arrayList2);
}
public SurfaceConfig transformSurfaceConfig(int i, Size size) {
SurfaceConfig.ConfigType configType = getConfigType(i);
SurfaceConfig.ConfigSize configSize = SurfaceConfig.ConfigSize.NOT_SUPPORT;
Size fetchMaxSize = fetchMaxSize(i);
if (size.getHeight() * size.getWidth() <= this.mSurfaceSizeDefinition.getAnalysisSize().getHeight() * this.mSurfaceSizeDefinition.getAnalysisSize().getWidth()) {
configSize = SurfaceConfig.ConfigSize.ANALYSIS;
} else {
if (size.getHeight() * size.getWidth() <= this.mSurfaceSizeDefinition.getPreviewSize().getHeight() * this.mSurfaceSizeDefinition.getPreviewSize().getWidth()) {
configSize = SurfaceConfig.ConfigSize.PREVIEW;
} else {
if (size.getHeight() * size.getWidth() <= this.mSurfaceSizeDefinition.getRecordSize().getHeight() * this.mSurfaceSizeDefinition.getRecordSize().getWidth()) {
configSize = SurfaceConfig.ConfigSize.RECORD;
} else {
if (size.getHeight() * size.getWidth() <= fetchMaxSize.getHeight() * fetchMaxSize.getWidth()) {
configSize = SurfaceConfig.ConfigSize.MAXIMUM;
}
}
}
}
return SurfaceConfig.create(configType, configSize);
}
}