what-the-bank/sources/io/flutter/plugins/camera/CameraUtils.java

157 lines
6.3 KiB
Java

package io.flutter.plugins.camera;
import android.app.Activity;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes6.dex */
public final class CameraUtils {
private CameraUtils() {
}
/* JADX INFO: Access modifiers changed from: package-private */
public static CameraManager getCameraManager(Context context) {
return (CameraManager) context.getSystemService("camera");
}
/* renamed from: io.flutter.plugins.camera.CameraUtils$1, reason: invalid class name */
/* loaded from: classes6.dex */
static /* synthetic */ class AnonymousClass1 {
static final int[] $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$DeviceOrientation;
static {
int[] iArr = new int[PlatformChannel.DeviceOrientation.values().length];
$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$DeviceOrientation = iArr;
try {
iArr[PlatformChannel.DeviceOrientation.PORTRAIT_UP.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$DeviceOrientation[PlatformChannel.DeviceOrientation.PORTRAIT_DOWN.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$DeviceOrientation[PlatformChannel.DeviceOrientation.LANDSCAPE_LEFT.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$DeviceOrientation[PlatformChannel.DeviceOrientation.LANDSCAPE_RIGHT.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static String serializeDeviceOrientation(PlatformChannel.DeviceOrientation deviceOrientation) {
if (deviceOrientation == null) {
throw new UnsupportedOperationException("Could not serialize null device orientation.");
}
int i = AnonymousClass1.$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$DeviceOrientation[deviceOrientation.ordinal()];
if (i == 1) {
return "portraitUp";
}
if (i == 2) {
return "portraitDown";
}
if (i == 3) {
return "landscapeLeft";
}
if (i == 4) {
return "landscapeRight";
}
StringBuilder sb = new StringBuilder("Could not serialize device orientation: ");
sb.append(deviceOrientation.toString());
throw new UnsupportedOperationException(sb.toString());
}
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
public static PlatformChannel.DeviceOrientation deserializeDeviceOrientation(String str) {
char c;
if (str == null) {
throw new UnsupportedOperationException("Could not deserialize null device orientation.");
}
str.hashCode();
switch (str.hashCode()) {
case -2022952606:
if (str.equals("landscapeLeft")) {
c = 0;
break;
}
c = 65535;
break;
case -339013923:
if (str.equals("portraitDown")) {
c = 1;
break;
}
c = 65535;
break;
case 746015638:
if (str.equals("portraitUp")) {
c = 2;
break;
}
c = 65535;
break;
case 1718639649:
if (str.equals("landscapeRight")) {
c = 3;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
if (c == 0) {
return PlatformChannel.DeviceOrientation.LANDSCAPE_LEFT;
}
if (c == 1) {
return PlatformChannel.DeviceOrientation.PORTRAIT_DOWN;
}
if (c == 2) {
return PlatformChannel.DeviceOrientation.PORTRAIT_UP;
}
if (c == 3) {
return PlatformChannel.DeviceOrientation.LANDSCAPE_RIGHT;
}
throw new UnsupportedOperationException("Could not deserialize device orientation: ".concat(String.valueOf(str)));
}
public static List<Map<String, Object>> getAvailableCameras(Activity activity) throws CameraAccessException {
CameraManager cameraManager = (CameraManager) activity.getSystemService("camera");
String[] cameraIdList = cameraManager.getCameraIdList();
ArrayList arrayList = new ArrayList();
for (String str : cameraIdList) {
try {
if (Integer.parseInt(str, 10) >= 0) {
HashMap hashMap = new HashMap();
CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(str);
hashMap.put("name", str);
hashMap.put("sensorOrientation", Integer.valueOf(((Integer) cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION)).intValue()));
int intValue = ((Integer) cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)).intValue();
if (intValue == 0) {
hashMap.put("lensFacing", "front");
} else if (intValue == 1) {
hashMap.put("lensFacing", "back");
} else if (intValue == 2) {
hashMap.put("lensFacing", "external");
}
arrayList.add(hashMap);
}
} catch (NumberFormatException unused) {
}
}
return arrayList;
}
}