what-the-bank/sources/com/scb/phone/view/camera/CameraApi2.java

164 lines
6.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.camera;
import android.app.Activity;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.media.ImageReader;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.DisplayMetrics;
import android.util.Size;
import android.util.SparseArray;
import android.view.Surface;
import android.view.TextureView;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.scb.phone.view.camera.CameraApi2;
import java.util.Arrays;
import o.InterfaceC10306eAb;
/* loaded from: classes5.dex */
public final class CameraApi2 {
public CameraCharacteristics a;
public Handler b;
public HandlerThread c;
public CameraCaptureSession d;
public InterfaceC10306eAb e;
public CaptureRequest.Builder f;
public CameraDevice g;
public SparseArray<String> h;
public CameraManager i;
public CaptureRequest.Builder j;
public Context k;
public String l;
public ImageReader m;
public ImageReader.OnImageAvailableListener n = new ImageReader.OnImageAvailableListener(this) { // from class: o.eAa
private CameraApi2 d;
@Override // android.media.ImageReader.OnImageAvailableListener
public final void onImageAvailable(ImageReader imageReader) {
CameraApi2 cameraApi2 = this.d;
InterfaceC10306eAb interfaceC10306eAb = cameraApi2.e;
if (interfaceC10306eAb != null) {
interfaceC10306eAb.aob_(cameraApi2.m.acquireLatestImage());
}
}
{
this.d = this;
}
};
/* renamed from: o, reason: collision with root package name */
public Size f8012o;
public int p;
public int t;
public CameraApi2(Context context) {
this.k = context;
this.i = (CameraManager) context.getSystemService("camera");
}
public final SparseArray<String> aoa_() {
if (this.i == null) {
return null;
}
this.h = new SparseArray<>();
try {
for (String str : this.i.getCameraIdList()) {
Integer num = (Integer) this.i.getCameraCharacteristics(str).get(CameraCharacteristics.LENS_FACING);
if (num != null) {
int intValue = num.intValue();
if (intValue == 0) {
this.h.put(0, str);
} else if (intValue != 1) {
if (intValue == 2) {
this.h.put(2, str);
}
} else if (this.h.get(1) == null) {
this.h.put(1, str);
}
}
}
return this.h;
} catch (CameraAccessException e) {
e.getMessage();
return null;
}
}
/* loaded from: classes5.dex */
public class CameraHardwareNotSupportException extends RuntimeException {
private CameraApi2 e;
public CameraHardwareNotSupportException(CameraApi2 cameraApi2) {
this.e = cameraApi2;
}
}
final void anZ_(TextureView textureView) {
if (this.g == null || this.m == null) {
return;
}
Surface surface = new Surface(textureView.getSurfaceTexture());
try {
CaptureRequest.Builder createCaptureRequest = this.g.createCaptureRequest(1);
this.f = createCaptureRequest;
createCaptureRequest.addTarget(surface);
CaptureRequest.Builder createCaptureRequest2 = this.g.createCaptureRequest(2);
this.j = createCaptureRequest2;
createCaptureRequest2.addTarget(this.m.getSurface());
this.g.createCaptureSession(Arrays.asList(surface, this.m.getSurface()), new CameraCaptureSession.StateCallback(this) { // from class: com.scb.phone.view.camera.CameraApi2.5
private CameraApi2 e;
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
public final void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
}
{
this.e = this;
}
@Override // android.hardware.camera2.CameraCaptureSession.StateCallback
public final void onConfigured(CameraCaptureSession cameraCaptureSession) {
this.e.d = cameraCaptureSession;
if (this.e.e != null) {
this.e.e.j();
}
}
}, this.b);
} catch (CameraAccessException e) {
e.getMessage();
}
}
static /* synthetic */ void anY_(CameraApi2 cameraApi2, TextureView textureView, int i, int i2) {
if (cameraApi2.f8012o != null) {
int rotation = ((Activity) cameraApi2.k).getWindowManager().getDefaultDisplay().getRotation();
((Activity) cameraApi2.k).getWindowManager().getDefaultDisplay().getMetrics(new DisplayMetrics());
Matrix matrix = new Matrix();
float f = i;
float f2 = i2;
RectF rectF = new RectF(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, f, f2);
RectF rectF2 = new RectF(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, cameraApi2.f8012o.getHeight(), cameraApi2.f8012o.getWidth());
float centerX = rectF.centerX();
float centerY = rectF.centerY();
if (1 == rotation || 3 == rotation) {
rectF2.offset(centerX - rectF2.centerX(), centerY - rectF2.centerY());
matrix.setRectToRect(rectF, rectF2, Matrix.ScaleToFit.FILL);
float max = Math.max(f2 / cameraApi2.f8012o.getHeight(), f / cameraApi2.f8012o.getWidth());
matrix.postScale(max, max, centerX, centerY);
matrix.postRotate((rotation - 2.0f) * 90.0f, centerX, centerY);
}
textureView.getSurfaceTexture().setDefaultBufferSize(cameraApi2.f8012o.getWidth(), cameraApi2.f8012o.getHeight());
textureView.setTransform(matrix);
}
}
}