package io.beid.beidk.c; import android.app.Activity; import android.app.AlertDialog; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.hardware.Camera; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.speech.tts.TextToSpeech; import android.util.Base64; import android.util.SparseArray; import android.view.SurfaceHolder; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import androidx.constraintlayout.widget.ConstraintLayout; import com.google.android.gms.common.GoogleApiAvailability; import com.google.firebase.ml.vision.face.FirebaseVisionFace; import com.huawei.hms.api.ConnectionResult; import io.beid.beidk.activity.FaceCaptureActivity; import io.beid.beidk.ui.camera.CameraSourcePreview; import io.beid.beidk.ui.camera.GraphicOverlay; import io.beid.beidk.view.JHFaceMaskView; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.util.Locale; import o.C13106fQt; import o.C13120fRb; import o.C13121fRc; import o.InterfaceC13104fQr; import o.InterfaceC13107fQu; import o.InterfaceC13108fQv; import o.fPZ; import o.fQE; import o.fQG; import o.fQP; import o.fQS; import o.fQT; import o.fQX; /* loaded from: classes5.dex */ public class b extends Fragment implements TextToSpeech.OnInitListener, InterfaceC13108fQv, fQE { private static int O = 0; private static byte R = 6; private static int S = 1; private static final String d = "io.beid.beidk.c.b"; private int D; private SharedPreferences F; private GraphicOverlay G; private CameraSourcePreview H; private TextView I; private TextToSpeech J; private ImageView L; private Context M; private AlertDialog Q; C13121fRc a; public InterfaceC13104fQr b; public Button c; public InterfaceC13107fQu e; private SparseArray j; private TextView k; private fQG l; private int p; private ConstraintLayout q; private fQX s; private View t; private JHFaceMaskView w; private ImageView x; private Activity z; private Camera y = null; private SurfaceHolder u = null; private boolean v = false; private boolean C = false; private String B = "off"; private C13120fRb A = null; private boolean E = false; private int N = fQP.b().i; private String K = ""; private int h = -1; private boolean g = false; private boolean f = false; private boolean i = false; private boolean n = false; /* renamed from: o, reason: collision with root package name */ private int f8092o = 10; private Integer m = 0; private ServiceConnection r = new ServiceConnection(this) { // from class: io.beid.beidk.c.b.5 private b e; @Override // android.content.ServiceConnection public final void onServiceDisconnected(ComponentName componentName) { this.e.s = null; } @Override // android.content.ServiceConnection public final void onServiceConnected(ComponentName componentName, IBinder iBinder) { this.e.s = fQX.RVV.aCu_(iBinder); } { this.e = this; } }; private void P(String str, Object[] objArr) { byte[] decode = Base64.decode(str, 0); byte[] bArr = new byte[decode.length]; for (int i = 0; i < decode.length; i++) { bArr[i] = (byte) (decode[(decode.length - i) - 1] ^ R); } objArr[0] = new String(bArr, StandardCharsets.UTF_8); } private void e(int i) { if (getActivity() == null || !fQP.b().j) { return; } String obj = fQP.b().k.get(i).toString(); this.J.speak(e(obj, obj), 0, null); } static /* synthetic */ void b(b bVar, Runnable runnable) { Long l = 2000L; bVar.I.setText(bVar.e("action_timeout", "Action Timeout")); if (l != null) { new Handler().postDelayed(runnable, l.longValue()); } } static /* synthetic */ void c(b bVar, String str, Long l, Runnable runnable) { bVar.I.setText(str); if (l != null) { new Handler().postDelayed(runnable, l.longValue()); } } /* JADX INFO: Access modifiers changed from: private */ public void i() { Context applicationContext = this.z.getApplicationContext(); C13121fRc c13121fRc = new C13121fRc(); this.a = c13121fRc; this.a.b = new fQS(c13121fRc, new C13106fQt(this, this.G)); this.z.getApplicationContext().getResources().getDisplayMetrics(); this.H.getWidth(); this.H.getHeight(); this.H.getWidth(); this.H.getHeight(); C13120fRb.LWm b = new C13120fRb.LWm(applicationContext, this.a).b(this.H.getWidth(), this.H.getHeight()); b.a.n = "auto"; b.a.j = "continuous-picture"; C13120fRb.LWm c = b.c(1).c(30.0f); c.a.f9108o = new C13120fRb.Sts(c.a, c.e); this.A = c.a; } static /* synthetic */ void c(b bVar) { String str = d; int i = bVar.f8092o; int i2 = bVar.D; boolean z = bVar.i; PrintStream printStream = System.out; StringBuilder sb = new StringBuilder(); sb.append(str); sb.append("statusChallenge1 = "); sb.append(bVar.i); printStream.println(sb.toString()); PrintStream printStream2 = System.out; StringBuilder sb2 = new StringBuilder(); sb2.append(str); sb2.append("statusChallenge2 = "); sb2.append(bVar.n); printStream2.println(sb2.toString()); bVar.f = false; if (!bVar.i) { bVar.i = true; if (fQP.b().j) { bVar.J.speak("OK", 0, null); } bVar.g = false; } else if (!bVar.n) { bVar.n = true; if (fQP.b().j) { bVar.J.speak("OK", 0, null); } } PrintStream printStream3 = System.out; StringBuilder sb3 = new StringBuilder(); sb3.append(str); sb3.append("statusChallenge1 = "); sb3.append(bVar.i); printStream3.println(sb3.toString()); PrintStream printStream4 = System.out; StringBuilder sb4 = new StringBuilder(); sb4.append(str); sb4.append("statusChallenge2 = "); sb4.append(bVar.n); printStream4.println(sb4.toString()); boolean z2 = bVar.g; } /* JADX INFO: Access modifiers changed from: private */ public void h() { synchronized (this) { this.D = 0; int size = fQP.b().r.size(); this.l = null; int i = this.h + 1; this.h = i; if (i >= size) { this.z.runOnUiThread(new Runnable(this) { // from class: io.beid.beidk.c.b.6 private b b; @Override // java.lang.Runnable public final void run() { if (this.b.getActivity() != null) { FaceCaptureActivity faceCaptureActivity = (FaceCaptureActivity) this.b.getActivity(); this.b.b.aCj_(this.b.j); FaceCaptureActivity.Sts sts = FaceCaptureActivity.c; try { a aVar = new a(); faceCaptureActivity.a = aVar; aVar.a = true; b bVar = faceCaptureActivity.b; FragmentTransaction beginTransaction = faceCaptureActivity.getFragmentManager().beginTransaction(); beginTransaction.remove(faceCaptureActivity.b); b bVar2 = faceCaptureActivity.b; faceCaptureActivity.b = null; a aVar2 = faceCaptureActivity.a; beginTransaction.add(fPZ.LWm.container, faceCaptureActivity.a, "confirmationFragment"); a aVar3 = faceCaptureActivity.a; beginTransaction.show(faceCaptureActivity.a); beginTransaction.commit(); faceCaptureActivity.d = FaceCaptureActivity.IeS.CONFIRM; } catch (Exception unused) { faceCaptureActivity.getLocalClassName(); } } } { this.b = this; } }); return; } if (i >= 0) { fQG fqg = fQP.b().r.get(this.h); this.l = fqg; if (fqg == null) { h(); return; } this.I.setText(e(fqg.a(), this.l.a())); if (fQP.b().d) { try { this.x.setVisibility(0); this.x.setImageDrawable(aCc_(this.l.a())); } catch (Exception e) { e.getMessage(); } } this.l.e(this); this.l.b(); } int i2 = this.h; this.g = true; e(i2); } } /* JADX INFO: Access modifiers changed from: private */ public void f() { int isGooglePlayServicesAvailable = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(fQP.b().c); if (isGooglePlayServicesAvailable != 0) { GoogleApiAvailability.getInstance().getErrorDialog(this.z, isGooglePlayServicesAvailable, ConnectionResult.RESOLUTION_REQUIRED).show(); } C13120fRb c13120fRb = this.A; if (c13120fRb != null) { try { this.H.e(c13120fRb); } catch (IOException unused) { this.A.b(); this.A = null; } } } @Override // o.fQE public final void b() { try { Runtime.getRuntime().gc(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); C13121fRc.e().getBitmapForDebugging().compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); int b = this.s.b(byteArrayInputStream.available()); byte[] bArr = new byte[4096]; while (byteArrayInputStream.read(bArr) != -1) { this.s.a(b, bArr); } this.s.e(b); byteArrayInputStream.close(); this.b.e(b); this.z.runOnUiThread(new AnonymousClass9(this)); } catch (Exception unused) { } } @Override // o.InterfaceC13108fQv public final void c() { if (this.g) { return; } this.z.runOnUiThread(new Runnable(this) { // from class: io.beid.beidk.c.b.2 private b e; @Override // java.lang.Runnable public final void run() { this.e.c.setVisibility(0); } { this.e = this; } }); } @Override // o.InterfaceC13108fQv public final void j() { if (this.g) { this.e.c(); } } @Override // android.app.Fragment public void onCreate(Bundle bundle) { super.onCreate(bundle); Intent intent = new Intent(getActivity(), (Class) fQT.class); intent.setAction(fQX.class.getName()); getActivity().startService(intent); getActivity().bindService(intent, this.r, 1); } /* JADX WARN: Code restructure failed: missing block: B:14:0x010d, code lost: if (o.fQP.b().m == o.fQP.Sts.challenge_first) goto L20; */ /* JADX WARN: Code restructure failed: missing block: B:16:0x011a, code lost: r12 = io.beid.beidk.c.b.O + 101; io.beid.beidk.c.b.S = r12 % 128; */ /* JADX WARN: Code restructure failed: missing block: B:17:0x0123, code lost: if ((r12 % 2) == 0) goto L25; */ /* JADX WARN: Code restructure failed: missing block: B:19:0x012b, code lost: if (o.fQP.b().b != false) goto L34; */ /* JADX WARN: Code restructure failed: missing block: B:20:0x012e, code lost: r12 = o.fQP.b().b; r14.hashCode(); */ /* JADX WARN: Code restructure failed: missing block: B:21:0x0137, code lost: throw null; */ /* JADX WARN: Code restructure failed: missing block: B:24:0x0118, code lost: if (o.fQP.b().m == o.fQP.Sts.challenge_first) goto L20; */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v7, types: [android.text.SpannableString, android.text.Spannable] */ @Override // android.app.Fragment /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public android.view.View onCreateView(android.view.LayoutInflater r12, android.view.ViewGroup r13, android.os.Bundle r14) { /* Method dump skipped, instructions count: 504 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: io.beid.beidk.c.b.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle):android.view.View"); } @Override // android.speech.tts.TextToSpeech.OnInitListener public void onInit(int i) { this.J.setLanguage(Locale.UK); if ((fQP.b().m == fQP.Sts.face_first || (fQP.b().m == fQP.Sts.challenge_first && !fQP.b().b)) && fQP.b().j) { this.J.speak(getString(fPZ.Sts.look_at_the_camera), 0, null); } } @Override // android.app.Fragment, android.content.ComponentCallbacks public void onLowMemory() { super.onLowMemory(); Runtime.getRuntime().gc(); } @Override // android.app.Fragment public void onPause() { C13120fRb c13120fRb; TextToSpeech textToSpeech = this.J; if (textToSpeech != null) { textToSpeech.stop(); this.J.shutdown(); } super.onPause(); this.z.setRequestedOrientation(10); CameraSourcePreview cameraSourcePreview = this.H; if (cameraSourcePreview == null || (c13120fRb = cameraSourcePreview.d) == null) { return; } c13120fRb.a(); } @Override // android.app.Fragment public void onResume() { this.z.setRequestedOrientation(1); super.onResume(); f(); } @Override // android.app.Fragment public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) { if (i != 2) { super.onRequestPermissionsResult(i, strArr, iArr); return; } if (iArr.length != 0 && iArr[0] == 0) { i(); return; } int length = iArr.length; if (iArr.length > 0) { int i2 = iArr[0]; } new AlertDialog.Builder(getActivity()).setTitle("ePID Client Demo").setMessage(fPZ.Sts.beid_camera_permission).setPositiveButton(fPZ.Sts.ok, new DialogInterface.OnClickListener(this) { // from class: io.beid.beidk.c.b.8 private b a; @Override // android.content.DialogInterface.OnClickListener public final void onClick(DialogInterface dialogInterface, int i3) { this.a.getActivity().finish(); } { this.a = this; } }).show(); } @Override // android.app.Fragment public void onDestroy() { super.onDestroy(); TextToSpeech textToSpeech = this.J; if (textToSpeech != null) { textToSpeech.shutdown(); } AlertDialog alertDialog = this.Q; if (alertDialog != null) { alertDialog.dismiss(); } C13120fRb c13120fRb = this.A; if (c13120fRb != null) { c13120fRb.b(); this.A = null; } getActivity().unbindService(this.r); } @Override // android.app.Fragment public void onAttach(Activity activity) { super.onAttach(activity); this.z = activity; } @Override // o.InterfaceC13108fQv public final fQG g() { return this.l; } @Override // o.InterfaceC13108fQv public final int a() { return this.h; } @Override // o.InterfaceC13108fQv public final boolean d() { return this.g; } @Override // o.fQE public final void b(Throwable th) { th.getMessage(); if ("timeout".equals(th.getMessage())) { b((Long) 200L, (Runnable) new AnonymousClass3(this)); } } /* JADX INFO: Access modifiers changed from: private */ public void b(Long l, Runnable runnable) { this.q.setVisibility(0); new Handler().postDelayed(new Runnable(this, runnable) { // from class: io.beid.beidk.c.b.4 private Runnable d; private b e; @Override // java.lang.Runnable public final void run() { this.e.q.setVisibility(4); this.d.run(); } { this.e = this; this.d = runnable; } }, l.longValue()); } final void aCe_(FirebaseVisionFace firebaseVisionFace, Bitmap bitmap) throws IOException, RemoteException { Rect boundingBox = firebaseVisionFace.getBoundingBox(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); this.p = this.s.b(byteArrayInputStream.available()); byte[] bArr = new byte[4096]; while (byteArrayInputStream.read(bArr) != -1) { this.s.a(this.p, bArr); } this.s.e(this.p); byteArrayInputStream.close(); this.b.aCi_(this.p, boundingBox); fQP.b(); h(); this.g = true; } private String e(String str, String str2) { int i = 2 % 2; int i2 = O + 23; S = i2 % 128; int i3 = i2 % 2; try { Resources resources = this.z.getResources(); String string = resources.getString(resources.getIdentifier(str, "string", this.z.getPackageName())); if (string.startsWith(",*,)")) { Object[] objArr = new Object[1]; P(string.substring(4), objArr); string = ((String) objArr[0]).intern(); int i4 = S + 65; O = i4 % 128; int i5 = i4 % 2; } return string; } catch (Resources.NotFoundException | Exception unused) { return str2; } } /* renamed from: io.beid.beidk.c.b$3, reason: invalid class name */ /* loaded from: classes5.dex */ final class AnonymousClass3 implements Runnable { final b e; /* renamed from: io.beid.beidk.c.b$3$2, reason: invalid class name */ /* loaded from: classes5.dex */ final class AnonymousClass2 implements Runnable { final AnonymousClass3 d; @Override // java.lang.Runnable public final void run() { this.d.e.z.runOnUiThread(new Runnable(this) { // from class: io.beid.beidk.c.b.3.2.3 private AnonymousClass2 a; @Override // java.lang.Runnable public final void run() { b bVar = this.a.d.e; int unused = this.a.d.e.h; b.c(bVar); this.a.d.e.h(); } { this.a = this; } }); } AnonymousClass2(AnonymousClass3 anonymousClass3) { this.d = anonymousClass3; } } @Override // java.lang.Runnable public final void run() { this.e.x.setVisibility(4); b.b(this.e, new AnonymousClass2(this)); } AnonymousClass3(b bVar) { this.e = bVar; } } /* renamed from: io.beid.beidk.c.b$9, reason: invalid class name */ /* loaded from: classes5.dex */ final class AnonymousClass9 implements Runnable { final b d; /* renamed from: io.beid.beidk.c.b$9$5, reason: invalid class name */ /* loaded from: classes5.dex */ final class AnonymousClass5 implements Runnable { final AnonymousClass9 d; @Override // java.lang.Runnable public final void run() { this.d.d.x.setVisibility(4); b.c(this.d.d, "", 2000L, new Runnable(this) { // from class: io.beid.beidk.c.b.9.5.3 private AnonymousClass5 d; @Override // java.lang.Runnable public final void run() { this.d.d.d.m = Integer.valueOf(this.d.d.d.m.intValue() + 1); b bVar = this.d.d.d; int unused = this.d.d.d.h; b.c(bVar); this.d.d.d.h(); } { this.d = this; } }); } AnonymousClass5(AnonymousClass9 anonymousClass9) { this.d = anonymousClass9; } } @Override // java.lang.Runnable public final void run() { this.d.b((Long) 200L, (Runnable) new AnonymousClass5(this)); } AnonymousClass9(b bVar) { this.d = bVar; } } private Drawable aCc_(String str) { try { Resources resources = this.z.getResources(); return resources.getDrawable(resources.getIdentifier(str, "drawable", this.z.getPackageName())); } catch (Resources.NotFoundException | Exception unused) { return null; } } }