package o; import android.content.Context; import android.hardware.Camera; import android.hardware.Sensor; import android.os.Handler; import android.os.Looper; import android.view.SurfaceHolder; import o.C17083tlK; /* renamed from: o.eqo, reason: case insensitive filesystem */ /* loaded from: classes3.dex */ public final class C12047eqo { public C10943eTk a; public C16524oza c; public Handler i; public OTQ j; public Handler k; public RmV n; public boolean g = false; public boolean d = true; public Xad e = new Xad(); public Runnable f = new Runnable(this) { // from class: o.eqo.5 private C12047eqo a; { this.a = this; } @Override // java.lang.Runnable public final void run() { try { C10943eTk c10943eTk = this.a.a; int e = oBF.e(c10943eTk.l.i); Camera open = e == -1 ? null : Camera.open(e); c10943eTk.c = open; if (open == null) { throw new RuntimeException("Failed to open camera"); } int e2 = oBF.e(c10943eTk.l.i); Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); c10943eTk.e = cameraInfo; Camera.getCameraInfo(e2, cameraInfo); } catch (Exception e3) { Handler handler = this.a.k; if (handler != null) { handler.obtainMessage(C17083tlK.LWm.zxing_camera_error, e3).sendToTarget(); } } } }; public Runnable h = new Runnable(this) { // from class: o.eqo.2 private C12047eqo c; { this.c = this; } /* JADX WARN: Removed duplicated region for block: B:17:0x0029 A[Catch: Exception -> 0x0045, TryCatch #3 {Exception -> 0x0045, blocks: (B:6:0x000a, B:15:0x0023, B:17:0x0029, B:18:0x003e, B:43:0x0035), top: B:5:0x000a }] */ /* JADX WARN: Removed duplicated region for block: B:25:0x0058 A[Catch: Exception -> 0x00a9, TryCatch #2 {Exception -> 0x00a9, blocks: (B:2:0x0000, B:23:0x004c, B:25:0x0058, B:26:0x0068, B:28:0x0074, B:31:0x0099, B:34:0x0084, B:36:0x008a, B:37:0x0097, B:39:0x005d, B:48:0x00a1, B:49:0x00a8), top: B:1:0x0000 }] */ /* JADX WARN: Removed duplicated region for block: B:28:0x0074 A[Catch: Exception -> 0x00a9, TryCatch #2 {Exception -> 0x00a9, blocks: (B:2:0x0000, B:23:0x004c, B:25:0x0058, B:26:0x0068, B:28:0x0074, B:31:0x0099, B:34:0x0084, B:36:0x008a, B:37:0x0097, B:39:0x005d, B:48:0x00a1, B:49:0x00a8), top: B:1:0x0000 }] */ /* JADX WARN: Removed duplicated region for block: B:38:? A[RETURN, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:39:0x005d A[Catch: Exception -> 0x00a9, TryCatch #2 {Exception -> 0x00a9, blocks: (B:2:0x0000, B:23:0x004c, B:25:0x0058, B:26:0x0068, B:28:0x0074, B:31:0x0099, B:34:0x0084, B:36:0x008a, B:37:0x0097, B:39:0x005d, B:48:0x00a1, B:49:0x00a8), top: B:1:0x0000 }] */ /* JADX WARN: Removed duplicated region for block: B:43:0x0035 A[Catch: Exception -> 0x0045, TryCatch #3 {Exception -> 0x0045, blocks: (B:6:0x000a, B:15:0x0023, B:17:0x0029, B:18:0x003e, B:43:0x0035), top: B:5:0x000a }] */ @Override // java.lang.Runnable /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final void run() { /* r5 = this; o.eqo r0 = r5.c // Catch: java.lang.Exception -> La9 o.eTk r0 = r0.a // Catch: java.lang.Exception -> La9 android.hardware.Camera r1 = r0.c // Catch: java.lang.Exception -> La9 if (r1 == 0) goto La1 r1 = 1 r2 = 0 o.OTQ r3 = r0.j // Catch: java.lang.Exception -> L45 int r3 = r3.e // Catch: java.lang.Exception -> L45 if (r3 == 0) goto L22 if (r3 == r1) goto L1f r4 = 2 if (r3 == r4) goto L1c r4 = 3 if (r3 == r4) goto L19 goto L22 L19: r3 = 270(0x10e, float:3.78E-43) goto L23 L1c: r3 = 180(0xb4, float:2.52E-43) goto L23 L1f: r3 = 90 goto L23 L22: r3 = r2 L23: android.hardware.Camera$CameraInfo r4 = r0.e // Catch: java.lang.Exception -> L45 int r4 = r4.facing // Catch: java.lang.Exception -> L45 if (r4 != r1) goto L35 android.hardware.Camera$CameraInfo r4 = r0.e // Catch: java.lang.Exception -> L45 int r4 = r4.orientation // Catch: java.lang.Exception -> L45 int r4 = r4 + r3 int r4 = r4 % 360 int r3 = 360 - r4 int r3 = r3 % 360 goto L3e L35: android.hardware.Camera$CameraInfo r4 = r0.e // Catch: java.lang.Exception -> L45 int r4 = r4.orientation // Catch: java.lang.Exception -> L45 int r4 = r4 - r3 int r4 = r4 + 360 int r3 = r4 % 360 L3e: r0.k = r3 // Catch: java.lang.Exception -> L45 android.hardware.Camera r4 = r0.c // Catch: java.lang.Exception -> L45 r4.setDisplayOrientation(r3) // Catch: java.lang.Exception -> L45 L45: r0.d(r2) // Catch: java.lang.Exception -> L49 goto L4c L49: r0.d(r1) // Catch: java.lang.Exception -> L4c L4c: android.hardware.Camera r1 = r0.c // Catch: java.lang.Exception -> La9 android.hardware.Camera$Parameters r1 = r1.getParameters() // Catch: java.lang.Exception -> La9 android.hardware.Camera$Size r1 = r1.getPreviewSize() // Catch: java.lang.Exception -> La9 if (r1 != 0) goto L5d o.VDF r1 = r0.f // Catch: java.lang.Exception -> La9 r0.i = r1 // Catch: java.lang.Exception -> La9 goto L68 L5d: o.VDF r2 = new o.VDF // Catch: java.lang.Exception -> La9 int r3 = r1.width // Catch: java.lang.Exception -> La9 int r1 = r1.height // Catch: java.lang.Exception -> La9 r2.(r3, r1) // Catch: java.lang.Exception -> La9 r0.i = r2 // Catch: java.lang.Exception -> La9 L68: o.eTk$HBt r1 = r0.a // Catch: java.lang.Exception -> La9 o.VDF r0 = r0.i // Catch: java.lang.Exception -> La9 r1.e = r0 // Catch: java.lang.Exception -> La9 o.eqo r0 = r5.c // Catch: java.lang.Exception -> La9 android.os.Handler r0 = r0.k // Catch: java.lang.Exception -> La9 if (r0 == 0) goto Lb9 o.eqo r0 = r5.c // Catch: java.lang.Exception -> La9 android.os.Handler r0 = r0.k // Catch: java.lang.Exception -> La9 int r1 = o.C17083tlK.LWm.zxing_prewiew_size_ready // Catch: java.lang.Exception -> La9 o.eqo r2 = r5.c // Catch: java.lang.Exception -> La9 o.eTk r2 = r2.a // Catch: java.lang.Exception -> La9 o.VDF r3 = r2.i // Catch: java.lang.Exception -> La9 if (r3 != 0) goto L84 r2 = 0 goto L99 L84: boolean r3 = r2.a() // Catch: java.lang.Exception -> La9 if (r3 == 0) goto L97 o.VDF r2 = r2.i // Catch: java.lang.Exception -> La9 o.VDF r3 = new o.VDF // Catch: java.lang.Exception -> La9 int r4 = r2.b // Catch: java.lang.Exception -> La9 int r2 = r2.c // Catch: java.lang.Exception -> La9 r3.(r4, r2) // Catch: java.lang.Exception -> La9 r2 = r3 goto L99 L97: o.VDF r2 = r2.i // Catch: java.lang.Exception -> La9 L99: android.os.Message r0 = r0.obtainMessage(r1, r2) // Catch: java.lang.Exception -> La9 r0.sendToTarget() // Catch: java.lang.Exception -> La9 return La1: java.lang.RuntimeException r0 = new java.lang.RuntimeException // Catch: java.lang.Exception -> La9 java.lang.String r1 = "Camera not open" r0.(r1) // Catch: java.lang.Exception -> La9 throw r0 // Catch: java.lang.Exception -> La9 La9: r0 = move-exception o.eqo r1 = r5.c android.os.Handler r1 = r1.k if (r1 == 0) goto Lb9 int r2 = o.C17083tlK.LWm.zxing_camera_error android.os.Message r0 = r1.obtainMessage(r2, r0) r0.sendToTarget() Lb9: return */ throw new UnsupportedOperationException("Method not decompiled: o.C12047eqo.AnonymousClass2.run():void"); } }; public Runnable l = new Runnable(this) { // from class: o.eqo.3 private C12047eqo a; { this.a = this; } @Override // java.lang.Runnable public final void run() { try { C10943eTk c10943eTk = this.a.a; RmV rmV = this.a.n; Camera camera = c10943eTk.c; SurfaceHolder surfaceHolder = rmV.c; if (surfaceHolder != null) { camera.setPreviewDisplay(surfaceHolder); } else { camera.setPreviewTexture(rmV.b); } C10943eTk c10943eTk2 = this.a.a; Camera camera2 = c10943eTk2.c; if (camera2 == null || c10943eTk2.h) { return; } camera2.startPreview(); c10943eTk2.h = true; c10943eTk2.b = new OVZ(c10943eTk2.c, c10943eTk2.l); tuL tul = new tuL(c10943eTk2.g, c10943eTk2, c10943eTk2.l); c10943eTk2.d = tul; boolean z = tul.c.d; } catch (Exception e) { Handler handler = this.a.k; if (handler != null) { handler.obtainMessage(C17083tlK.LWm.zxing_camera_error, e).sendToTarget(); } } } }; public Runnable b = new Runnable(this) { // from class: o.eqo.4 private C12047eqo b; { this.b = this; } @Override // java.lang.Runnable public final void run() { try { C10943eTk c10943eTk = this.b.a; OVZ ovz = c10943eTk.b; if (ovz != null) { ovz.c(); c10943eTk.b = null; } tuL tul = c10943eTk.d; if (tul != null) { Sensor sensor = tul.b; c10943eTk.d = null; } Camera camera = c10943eTk.c; if (camera != null && c10943eTk.h) { camera.stopPreview(); c10943eTk.a.a = null; c10943eTk.h = false; } C10943eTk c10943eTk2 = this.b.a; Camera camera2 = c10943eTk2.c; if (camera2 != null) { camera2.release(); c10943eTk2.c = null; } } catch (Exception unused) { } this.b.d = true; this.b.k.sendEmptyMessage(C17083tlK.LWm.zxing_camera_closed); C16524oza c16524oza = this.b.c; synchronized (c16524oza.b) { int i = c16524oza.d - 1; c16524oza.d = i; if (i == 0) { synchronized (c16524oza.b) { c16524oza.c.quit(); c16524oza.c = null; c16524oza.e = null; } } } } }; public C12047eqo(Context context) { if (Looper.getMainLooper() == Looper.myLooper()) { if (C16524oza.a == null) { C16524oza.a = new C16524oza(); } this.c = C16524oza.a; C10943eTk c10943eTk = new C10943eTk(context); this.a = c10943eTk; c10943eTk.l = this.e; this.i = new Handler(); return; } throw new IllegalStateException("Must be called from the main thread."); } public final void e(final boolean z) { if (Looper.getMainLooper() != Looper.myLooper()) { throw new IllegalStateException("Must be called from the main thread."); } if (this.g) { C16524oza c16524oza = this.c; Runnable runnable = new Runnable(this, z) { // from class: o.Eis private boolean a; private C12047eqo b; @Override // java.lang.Runnable public final void run() { C12047eqo c12047eqo = this.b; c12047eqo.a.b(this.a); } { this.b = this; this.a = z; } }; synchronized (c16524oza.b) { c16524oza.b(); c16524oza.e.post(runnable); } } } }