package com.facetec.sdk; import android.content.Context; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class v { private Context c; private int d = 50; private int a = 3; private ac e = null; private z b = z.INITIALIZED; private C0131r g = new C0131r(); private List f = new ArrayList(); private List j = new ArrayList(); private int i = -1; private int h = 0; private boolean n = false; private boolean k = false; private boolean m = false; /* renamed from: o, reason: collision with root package name */ private int f6458o = 0; /* JADX INFO: Access modifiers changed from: package-private */ public v(Context context) { this.c = context; } /* JADX INFO: Access modifiers changed from: package-private */ public final void b(boolean z) { synchronized (this) { if (this.b != z.STARTED && !this.m) { this.b = z.STARTED; this.n = false; this.k = false; int i = this.i + 1; this.i = i; if (i != 0) { if (!z && i > 0 && this.g.a.size() > 0) { this.h = 0; if (this.f.size() == 50) { this.f.remove(0); } this.g.c = new ArrayList(); this.f.add(this.g); this.g = new C0131r(); } return; } if (this.e == null) { this.e = c.d(this.c); } ArrayList arrayList = new ArrayList(); Iterator it = this.e.c.iterator(); while (it.hasNext()) { arrayList.add(it.next().a); } ArrayList arrayList2 = new ArrayList(); for (int i2 = 0; i2 < arrayList.size(); i2++) { ArrayList arrayList3 = new ArrayList(); C0131r c0131r = new C0131r(); c0131r.a = (List) arrayList.get(i2); for (int i3 = 0; i3 < c0131r.a.size(); i3++) { for (int i4 = 0; i4 < c0131r.a.get(i3).size(); i4++) { ab abVar = new ab(); abVar.a = i3; abVar.e = c0131r.a.get(i3).get(i4).intValue(); arrayList3.add(abVar); } } c0131r.d = arrayList3; arrayList2.add(c0131r); } this.j.addAll(arrayList2); } } } /* JADX INFO: Access modifiers changed from: package-private */ public final void d(boolean z) { synchronized (this) { if (this.b != z.ENDED && !this.m) { this.b = z.ENDED; if (z) { this.f6458o = 0; } else { int i = this.f6458o + 1; this.f6458o = i; if (i > 3) { this.g = new C0131r(); return; } } b(0); ArrayList arrayList = new ArrayList(); int i2 = 0; int i3 = -1; while (i2 < this.g.d.size()) { ab abVar = this.g.d.get(i2); if (i3 == -1 || i3 != abVar.a) { ArrayList arrayList2 = new ArrayList(); int i4 = abVar.a; int i5 = i2; while (i2 < this.g.d.size() && this.g.d.get(i2).a == i4) { arrayList2.add(Integer.valueOf(this.g.d.get(i2).e)); i5 = i2; i2++; } arrayList.add(arrayList2); i3 = i4; i2 = i5; } i2++; } this.g.a = arrayList; w wVar = new w(); C0131r c0131r = this.g; List list = this.f; List list2 = this.j; wVar.e = c0131r; wVar.b = new ArrayList(list2); wVar.a = new ArrayList(list); wVar.a.add(c0131r); wVar.c = w.c(wVar.a); ArrayList arrayList3 = new ArrayList(wVar.e.a); wVar.f = w.c(list).size(); wVar.i = wVar.a(arrayList3, 0, y.INTRA_SESSION); wVar.h = wVar.a(wVar.c, wVar.f, y.INTRA_FACETEC_SESSION); wVar.e.j = wVar.i ? x.DETECTED : x.NOT_DETECTED; wVar.e.i = wVar.h ? x.DETECTED : x.NOT_DETECTED; wVar.d = new ArrayList(); wVar.d.add(wVar.c); for (int i6 = 0; i6 < list2.size(); i6++) { wVar.d.add(list2.get(i6).a); } ArrayList arrayList4 = new ArrayList(); for (int i7 = 0; i7 < wVar.d.size(); i7++) { arrayList4.addAll(wVar.d.get(i7)); } wVar.j = wVar.a(arrayList4, wVar.c.size(), y.INTER_FACETEC_SESSION); wVar.e.f = wVar.j ? x.DETECTED : x.NOT_DETECTED; wVar.a = new ArrayList(); wVar.c = new ArrayList(); wVar.b = new ArrayList(); wVar.d = new ArrayList(); this.g = wVar.e; cy.b(new Runnable(this) { // from class: com.facetec.sdk.v$$ExternalSyntheticLambda0 public final v f$0; @Override // java.lang.Runnable public final void run() { this.f$0.b(); } { this.f$0 = this; } }); } } } /* JADX INFO: Access modifiers changed from: package-private */ public final void c() { synchronized (this) { this.f = null; this.j = null; this.e = null; this.m = true; } } /* JADX INFO: Access modifiers changed from: package-private */ public final C0131r d() { C0131r c0131r; synchronized (this) { c0131r = this.g; } return c0131r; } /* JADX INFO: Access modifiers changed from: package-private */ public final boolean e() { z zVar; z zVar2; synchronized (this) { zVar = this.b; zVar2 = z.STARTED; } return zVar == zVar2; } /* JADX INFO: Access modifiers changed from: package-private */ public final boolean a() { synchronized (this) { if (this.b == z.STARTED) { if (!this.m) { return true; } } return false; } } /* JADX INFO: Access modifiers changed from: package-private */ public final void c(byte[] bArr) { synchronized (this) { if (a() && bArr.length != 0) { ab abVar = new ab(); abVar.c = bArr; abVar.b = this.g.d.size(); abVar.a = this.i; this.g.d.add(abVar); if (this.g.d.size() % 20 == 0) { this.k = true; } if (this.k && !this.n) { b(this.h); } } } } private void b(int i) { if (i == 0 || (!this.n && this.k)) { this.n = true; this.k = false; while (i < this.g.d.size()) { if (this.g.d.get(i).c.length != 0) { this.g.d.get(i).e = Arrays.hashCode(this.g.d.get(i).c); this.g.d.get(i).c = new byte[0]; this.h = i + 1; } i++; } this.n = false; } } /* JADX INFO: Access modifiers changed from: private */ public void b() { synchronized (this) { if (this.m) { t.a(this.c, d.F2F_ERROR, "Error 4472"); return; } ArrayList arrayList = new ArrayList(); if (this.f.size() > 0) { List list = this.f; arrayList = new ArrayList(Arrays.asList(list.get(list.size() - 1))); } arrayList.add(this.g); ArrayList arrayList2 = new ArrayList(Arrays.asList(ad.b(arrayList))); arrayList2.addAll(this.j); ac b = ac.b(this.c, arrayList2); b.b(); this.e = b; c.d(this.c, b); } } }