package com.facetec.sdk; import android.app.Activity; import android.graphics.Rect; import android.hardware.Camera; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.view.SurfaceHolder; import android.view.View; import android.view.ViewGroup; import com.facetec.sdk.ah; import com.kofax.kmc.kut.utilities.IpLibUtil; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class an extends ah implements Camera.AutoFocusCallback, Camera.ErrorCallback, Camera.PreviewCallback, SurfaceHolder.Callback { private static boolean A = true; private static String[] n = {"ZTE B2017G"}; private final WeakReference m; /* renamed from: o, reason: collision with root package name */ private final Handler f6405o; private int q; private final j r; private SurfaceHolder s; private boolean t; private boolean l = false; private Camera k = null; private boolean p = false; aj f = null; private boolean u = false; private boolean x = false; private boolean v = false; private boolean y = false; private final Handler w = new Handler(Looper.getMainLooper()); private String z = ""; private long D = -1; private final Camera.AutoFocusMoveCallback C = new Camera.AutoFocusMoveCallback(this) { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda2 public final an f$0; @Override // android.hardware.Camera.AutoFocusMoveCallback public final void onAutoFocusMoving(boolean z, Camera camera) { this.f$0.c(z, camera); } { this.f$0 = this; } }; private final Camera.AutoFocusCallback B = new Camera.AutoFocusCallback(this) { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda3 public final an f$0; @Override // android.hardware.Camera.AutoFocusCallback public final void onAutoFocus(boolean z, Camera camera) { this.f$0.b(z, camera); } { this.f$0 = this; } }; @Override // android.hardware.Camera.AutoFocusCallback public final void onAutoFocus(boolean z, Camera camera) { } @Override // android.view.SurfaceHolder.Callback public final void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) { } private an(Activity activity, boolean z) { this.m = new WeakReference<>((be) activity); ah.d = z; HandlerThread handlerThread = new HandlerThread("CameraHandlerThread"); handlerThread.start(); this.f6405o = new Handler(handlerThread.getLooper()); this.r = new j(activity); } /* JADX INFO: Access modifiers changed from: package-private */ public static an d(Activity activity, boolean z) { an anVar = new an(activity, z); anVar.r.getHolder().addCallback(anVar); anVar.t = true; return anVar; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.facetec.sdk.ah public final void b() { if (ah.d) { e(true); e(false); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.facetec.sdk.ah public final void e(boolean z) { Camera camera = this.k; if (camera == null || this.u == (!z)) { return; } if (z) { camera.stopPreview(); this.u = false; return; } try { camera.setPreviewCallback(this); this.k.startPreview(); this.u = true; } catch (Exception e) { be beVar = this.m.get(); d dVar = d.STARTPREVIEW_EXCEPTION; StringBuilder sb = new StringBuilder("EXCEPTION: startPreview failed -- "); sb.append(e.getMessage()); sb.append(" "); sb.append(t.e((Activity) this.m.get())); t.a(beVar, dVar, sb.toString()); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.facetec.sdk.ah public final void b(boolean z, final ViewGroup viewGroup) { if (z) { this.p = true; } if (this.y) { return; } if (this.v) { new Handler(Looper.getMainLooper()).postDelayed(new Runnable(this, viewGroup) { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda0 public final an f$0; public final ViewGroup f$1; @Override // java.lang.Runnable public final void run() { this.f$0.e(this.f$1); } { this.f$0 = this; this.f$1 = viewGroup; } }, m()); return; } d(viewGroup); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void e(ViewGroup viewGroup) { if (m() > 0) { return; } d(viewGroup); } @Override // com.facetec.sdk.ah public final void a() { n(); } @Override // android.view.SurfaceHolder.Callback public final void surfaceCreated(SurfaceHolder surfaceHolder) { this.s = surfaceHolder; this.f6405o.post(new Runnable(this) { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda6 public final an f$0; @Override // java.lang.Runnable public final void run() { this.f$0.t(); } { this.f$0 = this; } }); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void t() { try { k(); } catch (Exception e) { k.a(e); av.e(e.getMessage()); e(e.getMessage()); } } @Override // android.view.SurfaceHolder.Callback public final void surfaceDestroyed(SurfaceHolder surfaceHolder) { n(); if (surfaceHolder == null || surfaceHolder.getSurface() == null) { return; } surfaceHolder.removeCallback(this); surfaceHolder.getSurface().release(); this.t = false; } /* JADX INFO: Access modifiers changed from: package-private */ public final void g() { if (this.t) { return; } this.r.getHolder().addCallback(this); this.t = true; } private void n() { synchronized (this) { Camera camera = this.k; if (camera != null) { try { try { camera.cancelAutoFocus(); this.k.stopPreview(); this.k.setPreviewCallback(null); this.k.release(); } catch (Exception e) { av.e(e.getMessage()); } this.k = null; } catch (Throwable th) { this.k = null; throw th; } } Handler handler = this.f6405o; if (handler != null) { handler.removeCallbacksAndMessages(null); } } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.facetec.sdk.ah public final void d(boolean z) { Camera camera = this.k; if (camera == null) { return; } Camera.Parameters parameters = camera.getParameters(); List supportedFlashModes = parameters.getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.size() > 0) { if (z && supportedFlashModes.contains("torch")) { parameters.setFlashMode("torch"); } else if (!z && supportedFlashModes.contains("off")) { parameters.setFlashMode("off"); } } this.k.setParameters(parameters); e(false); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.facetec.sdk.ah public final void a(ViewGroup viewGroup) { if (this.m.get() == null || this.k == null || !this.u) { return; } this.y = true; this.w.removeCallbacksAndMessages(null); this.w.postDelayed(new Runnable(this) { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda7 public final an f$0; @Override // java.lang.Runnable public final void run() { this.f$0.r(); } { this.f$0 = this; } }, 6000L); final Rect c = c(ah.h, ah.i, viewGroup); this.f6405o.post(new Runnable(this, c) { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda8 public final an f$0; public final Rect f$1; @Override // java.lang.Runnable public final void run() { this.f$0.a(this.f$1); } { this.f$0 = this; this.f$1 = c; } }); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(Rect rect) { try { o(); d(rect); } catch (Exception unused) { o(); } } private long m() { if (this.D != -1) { long nanoTime = (System.nanoTime() / 1000000) - this.D; if (nanoTime < 8000) { return 8000 - nanoTime; } } return 0L; } private void d(ViewGroup viewGroup) { if (this.k == null || this.l) { return; } d(c(ah.h, ah.i, viewGroup)); } private void d(Rect rect) { if (this.l || this.k == null || !this.u) { return; } this.l = true; this.D = System.nanoTime() / 1000000; try { this.k.cancelAutoFocus(); Camera.Parameters parameters = this.k.getParameters(); if (parameters.getSupportedFocusModes().contains("auto")) { parameters.setFocusMode("auto"); } ArrayList arrayList = new ArrayList(); arrayList.add(new Camera.Area(rect, 1000)); if (parameters.getMaxNumFocusAreas() > 0) { parameters.setFocusAreas(arrayList); } this.k.setParameters(parameters); e(false); this.k.autoFocus(this.B); } catch (Exception e) { e.getMessage(); o(); l(); } } private static int b(int i) { int round = Math.round(150.0f); return Math.abs(i) + round > 1000 ? i > 0 ? 1000 - round : round + IpLibUtil.KIPP_IP_LICENSING_FAILURE : i - round; } private static Rect c(float f, float f2, ViewGroup viewGroup) { int b = b(Float.valueOf(((f / viewGroup.getWidth()) * 2000.0f) - 1000.0f).intValue()); int b2 = b(Float.valueOf(((f2 / viewGroup.getHeight()) * 2000.0f) - 1000.0f).intValue()); return new Rect(b, b2, b + 300, b2 + 300); } private void o() { this.l = false; Camera camera = this.k; if (camera == null) { return; } try { camera.cancelAutoFocus(); } catch (Exception unused) { } } private void l() { if (this.k == null || this.z.isEmpty()) { return; } try { Camera.Parameters parameters = this.k.getParameters(); parameters.setFocusMode(this.z); if (parameters.getMaxNumFocusAreas() > 0) { parameters.setFocusAreas(null); } if (parameters.getMaxNumMeteringAreas() > 0) { parameters.setMeteringAreas(null); } this.k.setParameters(parameters); e(false); } catch (Exception e) { e.getMessage(); } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void c(boolean z, Camera camera) { this.v = !z; this.l = z; this.D = System.nanoTime() / 1000000; boolean z2 = this.v; if (this.p && z2) { cg.k(true); this.p = false; } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void b(boolean z, Camera camera) { this.v = z; this.D = System.nanoTime() / 1000000; o(); if (s()) { l(); } if (this.p && z) { cg.k(true); this.p = false; } } @Override // android.hardware.Camera.PreviewCallback public final void onPreviewFrame(byte[] bArr, Camera camera) { if (this.g && !d) { aw.e("CLFFT"); } this.e = true; bg bgVar = (bg) this.m.get(); if (bgVar == null || bgVar.b == null) { return; } if (d && bgVar.m != null && bgVar.m.f6413o) { bgVar.b.b(bArr, this.f.e, this.f.c, this.q, Boolean.FALSE); return; } if (!d) { bgVar.b.b(bArr, this.f.e, this.f.c, this.q, Boolean.FALSE); } this.g = false; } private static Camera e(Camera.CameraInfo cameraInfo) { int i = 0; try { Camera.getCameraInfo(0, cameraInfo); } catch (RuntimeException unused) { i = 1; } return Camera.open(i); } private static Camera a(Camera.CameraInfo cameraInfo) throws Exception { int i; try { Camera.getCameraInfo(1, cameraInfo); i = 1; } catch (RuntimeException unused) { i = 0; Camera.getCameraInfo(0, cameraInfo); } aw.c("CLOT"); aw.c("CLFFT"); if (cameraInfo.facing == 1) { Camera open = Camera.open(i); aw.e("CLOT"); return open; } throw new ar("Front facing camera not available"); } /* JADX WARN: Removed duplicated region for block: B:101:0x0207 A[Catch: all -> 0x0221, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:107:0x014a */ /* JADX WARN: Removed duplicated region for block: B:108:0x014d A[Catch: all -> 0x0221, TRY_ENTER, TRY_LEAVE, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:35:0x0085 */ /* JADX WARN: Removed duplicated region for block: B:44:0x00a9 A[Catch: all -> 0x0221, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:48:0x00c1 A[ADDED_TO_REGION] */ /* JADX WARN: Removed duplicated region for block: B:52:0x00dc A[Catch: all -> 0x0221, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:65:0x0137 A[Catch: all -> 0x0221, TRY_LEAVE, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:69:0x0166 A[Catch: all -> 0x0221, TRY_ENTER, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:76:0x0182 A[Catch: all -> 0x0221, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:79:0x018b A[Catch: all -> 0x0221, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* JADX WARN: Removed duplicated region for block: B:82:0x01a7 A[Catch: all -> 0x0221, TryCatch #0 {, blocks: (B:3:0x0001, B:9:0x000e, B:13:0x001a, B:15:0x0023, B:18:0x0028, B:19:0x0035, B:21:0x003e, B:24:0x0043, B:26:0x004f, B:28:0x0059, B:31:0x0064, B:32:0x0069, B:33:0x0072, B:42:0x0096, B:44:0x00a9, B:46:0x00b4, B:49:0x00c3, B:50:0x00d6, B:52:0x00dc, B:53:0x00ec, B:55:0x00f2, B:59:0x010b, B:62:0x0104, B:63:0x0112, B:65:0x0137, B:69:0x0166, B:71:0x016f, B:73:0x0175, B:74:0x017c, B:76:0x0182, B:77:0x0185, B:79:0x018b, B:80:0x018e, B:82:0x01a7, B:84:0x01ac, B:88:0x01b6, B:90:0x01bc, B:92:0x01c4, B:93:0x01c9, B:95:0x01cf, B:97:0x01d7, B:86:0x01dd, B:99:0x01e0, B:101:0x0207, B:102:0x020c, B:105:0x0142, B:108:0x014d, B:111:0x0158, B:115:0x00cd, B:116:0x00ad, B:120:0x006a, B:121:0x002f), top: B:2:0x0001 }] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void k() throws java.lang.Exception { /* Method dump skipped, instructions count: 548 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.facetec.sdk.an.k():void"); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void q() { this.r.setAspectRatio(this.f.c, this.f.e); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void p() { if (this.y) { this.x = true; return; } o(); l(); this.x = true; } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ int e(Camera.Size size, Camera.Size size2) { return (size2.width * size2.height) - (size.width * size.height); } /* JADX INFO: Access modifiers changed from: package-private */ public static aj i() throws Exception { aj a; synchronized (an.class) { Camera a2 = a(new Camera.CameraInfo()); a = a(a2); a2.stopPreview(); a2.release(); } return a; } private static aj a(Camera camera) { Camera.Size preferredPreviewSizeForVideo; synchronized (an.class) { if (ah.d.e(ah.d.b) && (preferredPreviewSizeForVideo = camera.getParameters().getPreferredPreviewSizeForVideo()) != null) { return new aj(preferredPreviewSizeForVideo.width, preferredPreviewSizeForVideo.height); } float[] fArr = {1.7f, 1.6f, 1.5f, 1.4f, 1.3f}; ArrayList arrayList = new ArrayList(); List supportedPreviewSizes = camera.getParameters().getSupportedPreviewSizes(); Collections.sort(supportedPreviewSizes, new Comparator() { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda4 @Override // java.util.Comparator public final int compare(Object obj, Object obj2) { int a; a = an.a((Camera.Size) obj, (Camera.Size) obj2); return a; } }); StringBuilder sb = new StringBuilder(); sb.append(supportedPreviewSizes.get(0).width); sb.append("x"); sb.append(supportedPreviewSizes.get(0).height); ah.c = sb.toString(); m.e(supportedPreviewSizes); for (int i = 0; i < 5; i++) { float f = fArr[i]; for (Camera.Size size : supportedPreviewSizes) { float f2 = size.width; float f3 = f2 / size.height; if (f3 >= f && f3 <= 1.9f && f2 >= 640.0f && f2 <= 1920.0f) { arrayList.add(size); } } if (arrayList.size() > 0) { break; } } Camera.Size size2 = (Camera.Size) arrayList.get(0); List supportedVideoSizes = camera.getParameters().getSupportedVideoSizes(); if (supportedVideoSizes != null && !supportedVideoSizes.contains(size2)) { m.a = true; } return new aj(((Camera.Size) arrayList.get(0)).width, ((Camera.Size) arrayList.get(0)).height); } } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ int a(Camera.Size size, Camera.Size size2) { return (size2.width * size2.height) - (size.width * size.height); } /* JADX INFO: Access modifiers changed from: package-private */ public static aj j() throws Exception { aj d; synchronized (an.class) { Camera e = e(new Camera.CameraInfo()); d = d(e); e.stopPreview(); e.release(); } return d; } private static aj d(Camera camera) throws Exception { aj ajVar; synchronized (an.class) { ArrayList arrayList = new ArrayList(); List supportedPreviewSizes = camera.getParameters().getSupportedPreviewSizes(); float e = e(); Collections.sort(supportedPreviewSizes, new Comparator() { // from class: com.facetec.sdk.an$$ExternalSyntheticLambda5 @Override // java.util.Comparator public final int compare(Object obj, Object obj2) { int c; c = an.c((Camera.Size) obj, (Camera.Size) obj2); return c; } }); StringBuilder sb = new StringBuilder(); sb.append(supportedPreviewSizes.get(0).width); sb.append("x"); sb.append(supportedPreviewSizes.get(0).height); ah.c = sb.toString(); for (Camera.Size size : supportedPreviewSizes) { float f = size.width; if (f / size.height == e && f <= 1920.0f) { arrayList.add(size); } } ajVar = new aj(((Camera.Size) arrayList.get(0)).width, ((Camera.Size) arrayList.get(0)).height); } return ajVar; } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ int c(Camera.Size size, Camera.Size size2) { return (size2.width * size2.height) - (size.width * size.height); } @Override // android.hardware.Camera.ErrorCallback public final void onError(int i, Camera camera) { if (i == 100) { try { n(); k(); return; } catch (Exception e) { k.a(e); StringBuilder sb = new StringBuilder("Legacy camera error during cleanup and setup camera: "); sb.append(e.getMessage()); e(sb.toString()); return; } } bg bgVar = (bg) this.m.get(); if (bgVar.y() && i == 2) { t.a(bgVar, d.CAMERA_EVICTED_CONTEXT_SWITCH, (String) null); return; } try { throw new RuntimeException("Legacy camera error: ".concat(String.valueOf(i))); } catch (Exception e2) { k.a(e2); e("Legacy camera error with code: ".concat(String.valueOf(i))); } } private void e(String str) { be beVar = this.m.get(); if (beVar != null) { d dVar = d.CAMERA_LEGACY_ERROR; StringBuilder sb = new StringBuilder("CameraLegacy error: "); sb.append(str); sb.append(t.e((Activity) beVar)); t.a(beVar, dVar, sb.toString()); beVar.e(str); } } /* JADX INFO: Access modifiers changed from: package-private */ public final boolean f() { return this.x; } @Override // com.facetec.sdk.ah public final View d() { return this.r; } private boolean s() { String str = this.z; return str == "continuous-picture" || str == "continuous-video"; } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void r() { this.y = false; } }