package o; import android.app.Activity; import android.content.Context; import androidx.window.layout.SidecarCompat; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; import java.util.concurrent.locks.ReentrantLock; import o.gQi; import o.xxy; /* renamed from: o.nkH, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C16366nkH implements InterfaceC0372FdA { private static volatile C16366nkH c; private gQi a; final CopyOnWriteArrayList e = new CopyOnWriteArrayList<>(); public static final IeS b = new IeS(0); private static final ReentrantLock d = new ReentrantLock(); public C16366nkH(gQi gqi) { this.a = gqi; gQi gqi2 = this.a; if (gqi2 != null) { gqi2.b(new RVV(this)); } } @Override // o.InterfaceC0372FdA public final void CW_(Activity activity, Executor executor, QUU quu) { oEt oet; Object obj; C14957gcv.e(activity, ""); C14957gcv.e(executor, ""); C14957gcv.e(quu, ""); ReentrantLock reentrantLock = d; reentrantLock.lock(); try { gQi gqi = this.a; if (gqi == null) { quu.accept(new oEt(C14851gaI.c)); return; } CopyOnWriteArrayList copyOnWriteArrayList = this.e; boolean z = false; if (!(copyOnWriteArrayList instanceof Collection) || !copyOnWriteArrayList.isEmpty()) { Iterator it = copyOnWriteArrayList.iterator(); while (true) { if (!it.hasNext()) { break; } else if (C14957gcv.b(((LWm) it.next()).c, activity)) { z = true; break; } } } LWm lWm = new LWm(activity, executor, quu); this.e.add(lWm); if (!z) { gqi.CP_(activity); } else { Iterator it2 = this.e.iterator(); while (true) { oet = null; if (!it2.hasNext()) { obj = null; break; } else { obj = it2.next(); if (C14957gcv.b(activity, ((LWm) obj).c)) { break; } } } LWm lWm2 = (LWm) obj; if (lWm2 != null) { oet = lWm2.e; } if (oet != null) { C14957gcv.e(oet, ""); lWm.e = oet; lWm.d.execute(new SWJ(lWm, oet)); } } C14866gag c14866gag = C14866gag.c; } finally { reentrantLock.unlock(); } } @Override // o.InterfaceC0372FdA public final void a(QUU quu) { C14957gcv.e(quu, ""); synchronized (d) { if (this.a == null) { return; } ArrayList arrayList = new ArrayList(); Iterator it = this.e.iterator(); while (it.hasNext()) { LWm next = it.next(); if (next.a == quu) { C14957gcv.c(next, ""); arrayList.add(next); } } this.e.removeAll(arrayList); Iterator it2 = arrayList.iterator(); while (it2.hasNext()) { Activity activity = ((LWm) it2.next()).c; CopyOnWriteArrayList copyOnWriteArrayList = this.e; if (!(copyOnWriteArrayList instanceof Collection) || !copyOnWriteArrayList.isEmpty()) { Iterator it3 = copyOnWriteArrayList.iterator(); while (it3.hasNext()) { if (C14957gcv.b(((LWm) it3.next()).c, activity)) { break; } } } gQi gqi = this.a; if (gqi != null) { gqi.CQ_(activity); } } C14866gag c14866gag = C14866gag.c; } } /* renamed from: o.nkH$RVV */ /* loaded from: classes.dex */ public final class RVV implements gQi.Sts { final C16366nkH a; public RVV(C16366nkH c16366nkH) { C14957gcv.e(c16366nkH, ""); this.a = c16366nkH; } @Override // o.gQi.Sts public final void CV_(Activity activity, oEt oet) { C14957gcv.e(activity, ""); C14957gcv.e(oet, ""); Iterator it = this.a.e.iterator(); while (it.hasNext()) { LWm next = it.next(); if (C14957gcv.b(next.c, activity)) { C14957gcv.e(oet, ""); next.e = oet; next.d.execute(new SWJ(next, oet)); } } } } /* renamed from: o.nkH$LWm */ /* loaded from: classes.dex */ public static final class LWm { final QUU a; final Activity c; final Executor d; oEt e; public LWm(Activity activity, Executor executor, QUU quu) { C14957gcv.e(activity, ""); C14957gcv.e(executor, ""); C14957gcv.e(quu, ""); this.c = activity; this.d = executor; this.a = quu; } } /* renamed from: o.nkH$IeS */ /* loaded from: classes.dex */ public static final class IeS { private IeS() { } public static C16366nkH c(Context context) { C14957gcv.e(context, ""); if (C16366nkH.c == null) { ReentrantLock reentrantLock = C16366nkH.d; reentrantLock.lock(); try { if (C16366nkH.c == null) { IeS ieS = C16366nkH.b; gQi b = b(context); IeS ieS2 = C16366nkH.b; C16366nkH.c = new C16366nkH(b); } C14866gag c14866gag = C14866gag.c; } finally { reentrantLock.unlock(); } } C16366nkH c16366nkH = C16366nkH.c; C14957gcv.e(c16366nkH); return c16366nkH; } private static gQi b(Context context) { C14957gcv.e(context, ""); try { xxy d = SidecarCompat.c.d(); if (d == null) { return null; } xxy.IeS ieS = xxy.b; if (d.compareTo(xxy.d()) < 0) { return null; } SidecarCompat sidecarCompat = new SidecarCompat(context); if (sidecarCompat.a()) { return sidecarCompat; } return null; } catch (Throwable unused) { return null; } } public /* synthetic */ IeS(byte b) { this(); } } }