package X; import android.text.TextUtils; import com.bytedance.covode.number.Covode; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public final class FQL implements F5T { public static final Object LJIIJJI = new Object(); public static final ThreadFactory LJIIL = new ThreadFactoryC175626vH(); public final ExecutorService LIZ; public final FER LIZIZ; public final FQF LIZJ; public final FQM LIZLLL; public final FQT LJ; public final C37995Ew4 LJFF; public final C1809879j LJI; public final Object LJII; public final ExecutorService LJIIIIZZ; public String LJIIIZ; public final List<AbstractC38924FQj> LJIIJ; static { Covode.recordClassIndex(38745); } public FQL(FER fer, F5X f5x, AbstractC37497Eo2 eo2) { this(new ThreadPoolExecutor(0, 1, 30, TimeUnit.SECONDS, new LinkedBlockingQueue(), LJIIL), fer, new FQF(fer.LIZ(), f5x, eo2), new FQM(fer), new FQT(), new C37995Ew4(fer), new C1809879j()); } public FQL(ExecutorService executorService, FER fer, FQF fqf, FQM fqm, FQT fqt, C37995Ew4 ew4, C1809879j r17) { this.LJII = new Object(); this.LJIIIZ = null; this.LJIIJ = new ArrayList(); this.LIZIZ = fer; this.LIZJ = fqf; this.LIZLLL = fqm; this.LJ = fqt; this.LJFF = ew4; this.LJI = r17; this.LJIIIIZZ = executorService; this.LIZ = new ThreadPoolExecutor(0, 1, 30, TimeUnit.SECONDS, new LinkedBlockingQueue(), LJIIL); } public static FQN LIZ(FQL fql, FQN fqn) { String str = null; try { if (fqn.LIZ().length() == 11) { str = fql.LJFF.LIZ(); } AbstractC38916FQb LIZ2 = fql.LIZJ.LIZ(fql.LJI(), fqn.LIZ(), fql.LJ(), fql.LJFF(), str); int i2 = FQK.LIZ[LIZ2.LJ().ordinal()]; if (i2 == 1) { String LIZIZ2 = LIZ2.LIZIZ(); String LIZJ2 = LIZ2.LIZJ(); long LIZ3 = fql.LJ.LIZ(); String LIZ4 = LIZ2.LIZLLL().LIZ(); return fqn.LJII().LIZ(LIZIZ2).LIZ(FQW.REGISTERED).LIZIZ(LIZ4).LIZJ(LIZJ2).LIZ(LIZ2.LIZLLL().LIZIZ()).LIZIZ(LIZ3).LIZ(); } else if (i2 == 2) { return fqn.LIZ("BAD CONFIG"); } else { throw new IOException(); } } catch (NullPointerException e) { e.printStackTrace(); return fqn.LIZ("BAD CONFIG"); } } private void LIZ(FQN fqn, Exception exc) { synchronized (this.LJII) { try { Iterator<AbstractC38924FQj> it = this.LJIIJ.iterator(); while (it.hasNext()) { if (it.next().LIZ(fqn, exc)) { it.remove(); } } } finally { } } } private void LIZLLL() { F6B.LIZ(LJFF()); F6B.LIZ(LJ()); F6B.LIZ(LJI()); F6B.LIZIZ(LJFF().contains(":"), "Please set your Application ID. A valid Firebase App ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options."); F6B.LIZIZ(FQT.LIZIZ.matcher(LJI()).matches(), "Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.Please refer to https://firebase.google.com/support/privacy/init-options."); } private String LJ() { return this.LIZIZ.LIZJ().LJI; } private String LJFF() { return this.LIZIZ.LIZJ().LIZIZ; } private String LJI() { return this.LIZIZ.LIZJ().LIZ; } private F6D<AbstractC38921FQg> LJII() { F69 f69 = new F69(); FQR fqr = new FQR(this.LJ, f69); synchronized (this.LJII) { try { this.LJIIJ.add(fqr); } catch (Throwable th) { throw th; } } return f69.LIZ; } private String LJIIIIZZ() { String str = this.LJIIIZ; if (str != null) { return str; } FQN LIZJ2 = LIZJ(); this.LIZ.execute(RunnableC38922FQh.LIZ(this)); return LIZJ2.LIZ(); } private FQN LJIIIZ() { FQN LIZ2; synchronized (LJIIJJI) { try { C58542Sl LIZ3 = C58542Sl.LIZ(this.LIZIZ.LIZ(), "generatefid.lock"); try { LIZ2 = this.LIZLLL.LIZ(); if (LIZ3 != null) { LIZ3.LIZ(); } } catch (Throwable th) { if (LIZ3 != null) { LIZ3.LIZ(); } throw th; } } finally { } } return LIZ2; } @Override // X.F5T public final F6D<String> LIZ() { LIZLLL(); F69 f69 = new F69(); f69.LIZIZ(LJIIIIZZ()); return f69.LIZ; } public final void LIZ(FQN fqn) { synchronized (this.LJII) { try { Iterator<AbstractC38924FQj> it = this.LJIIJ.iterator(); while (it.hasNext()) { if (it.next().LIZ(fqn)) { it.remove(); } } } finally { } } } public final void LIZ(boolean z) { FQN fqn; FQN LJIIIZ2 = LJIIIZ(); try { if (LJIIIZ2.LJIIIZ() || LJIIIZ2.LJIIJ()) { fqn = LIZ(this, LJIIIZ2); } else if (z || this.LJ.LIZ(LJIIIZ2)) { AbstractC38915FQa LIZ2 = this.LIZJ.LIZ(LJI(), LJIIIZ2.LIZ(), LJ(), LJIIIZ2.LIZLLL()); int i2 = FQK.LIZIZ[LIZ2.LIZJ().ordinal()]; if (i2 == 1) { String LIZ3 = LIZ2.LIZ(); long LIZIZ2 = LIZ2.LIZIZ(); fqn = LJIIIZ2.LJII().LIZIZ(LIZ3).LIZ(LIZIZ2).LIZIZ(this.LJ.LIZ()).LIZ(); } else if (i2 == 2) { fqn = LJIIIZ2.LIZ("BAD CONFIG"); } else if (i2 == 3) { this.LJIIIZ = null; fqn = LJIIIZ2.LJII().LIZ(FQW.NOT_GENERATED).LIZ(); } else { throw new IOException(); } } else { return; } synchronized (LJIIJJI) { try { C58542Sl LIZ4 = C58542Sl.LIZ(this.LIZIZ.LIZ(), "generatefid.lock"); try { this.LIZLLL.LIZ(fqn); if (LIZ4 != null) { LIZ4.LIZ(); } } catch (Throwable th) { if (LIZ4 != null) { LIZ4.LIZ(); } throw th; } } finally { } } if (fqn.LJIIIIZZ()) { this.LJIIIZ = fqn.LIZ(); } if (fqn.LJIIIZ()) { LIZ(fqn, new FHI(FHJ.BAD_CONFIG)); } else if (fqn.LJIIJJI()) { LIZ(fqn, new IOException("cleared fid due to auth error")); } else { LIZ(fqn); } } catch (IOException e) { LIZ(LJIIIZ2, e); } } @Override // X.F5T public final F6D<AbstractC38921FQg> LIZIZ() { LIZLLL(); F6D<AbstractC38921FQg> LJII2 = LJII(); this.LJIIIIZZ.execute(new FQY(this)); return LJII2; } public final FQN LIZJ() { FQN LIZ2; String LIZ3; synchronized (LJIIJJI) { try { C58542Sl LIZ4 = C58542Sl.LIZ(this.LIZIZ.LIZ(), "generatefid.lock"); try { LIZ2 = this.LIZLLL.LIZ(); if (LIZ2.LJIIJJI()) { if ((this.LIZIZ.LIZIZ().equals("CHIME_ANDROID_SDK") || this.LIZIZ.LJFF()) && LIZ2.LIZIZ() == FQW.ATTEMPT_MIGRATION) { LIZ3 = this.LJFF.LIZIZ(); if (TextUtils.isEmpty(LIZ3)) { LIZ3 = this.LJI.LIZ(); } } else { LIZ3 = this.LJI.LIZ(); } LIZ2 = this.LIZLLL.LIZ(LIZ2.LJII().LIZ(LIZ3).LIZ(FQW.UNREGISTERED).LIZ()); } if (LIZ4 != null) { LIZ4.LIZ(); } } catch (Throwable th) { if (LIZ4 != null) { LIZ4.LIZ(); } throw th; } } finally { } } return LIZ2; } }