MD5 校验值:63f8e52e07318fa084f03ba71262387f
n.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package a6; import a6.b; import a6.d; import a6.h; import b6.a; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; public class n implements b.a, a6.h { private static long H; private String A; private long F; private boolean G; private final h.a f187a; private final a6.f f188b; private String f189c; private long f192f; private a6.b f193g; private Map<Long, j> f198l; private List<l> f199m; private Map<Long, o> f200n; private Map<Long, m> f201o; private Map<p, C0005n> f202p; private String f203q; private boolean f204r; private String f205s; private boolean f206t; private final a6.c f207u; private final a6.d f208v; private final a6.d f209w; private final ScheduledExecutorService f210x; private final j6.c f211y; private final b6.a f212z; private HashSet<String> f190d = new HashSet<>(); private boolean f191e = true; private k f194h = k.Disconnected; private long f195i = 0; private long f196j = 0; private long f197k = 0; private long B = 0; private int C = 0; private int D = 0; private ScheduledFuture<?> E = null; public class a implements d.a { final u4.m f213a; a(u4.m mVar) { this.f213a = mVar; } @Override public void a(String str) { this.f213a.c(str); } @Override public void onError(String str) { this.f213a.b(new Exception(str)); } } public class b implements d.a { final u4.m f215a; b(u4.m mVar) { this.f215a = mVar; } @Override public void a(String str) { this.f215a.c(str); } @Override public void onError(String str) { this.f215a.b(new Exception(str)); } } public class c implements j { final a6.p f217a; c(a6.p pVar) { this.f217a = pVar; } @Override public void a(Map<String, Object> map) { String str = (String) map.get("s"); String str2 = null; if (str.equals("ok")) { str = null; } else { str2 = (String) map.get("d"); } a6.p pVar = this.f217a; if (pVar != null) { pVar.a(str, str2); } } } public class d implements j { final boolean f219a; d(boolean z10) { this.f219a = z10; } @Override public void a(Map<String, Object> map) { String str = (String) map.get("s"); if (str.equals("ok")) { n.this.f194h = k.Connected; n.this.C = 0; n.this.t0(this.f219a); return; } n.this.f203q = null; n.this.f204r = true; n.this.f187a.b(false); String str2 = (String) map.get("d"); n.this.f211y.b("Authentication failed: " + str + " (" + str2 + ")", new Object[0]); n.this.f193g.c(); if (str.equals("invalid_token")) { n.y(n.this); if (n.this.C >= 3) { n.this.f212z.d(); n.this.f211y.i("Provided authentication credentials are invalid. This usually indicates your FirebaseApp instance was not initialized correctly. Make sure your google-services.json file has the correct firebase_url and api_key. You can re-download google-services.json from https://console.firebase.google.com/."); } } } } public class e implements j { final String f221a; final long f222b; final o f223c; final a6.p f224d; e(String str, long j10, o oVar, a6.p pVar) { this.f221a = str; this.f222b = j10; this.f223c = oVar; this.f224d = pVar; } @Override public void a(Map<String, Object> map) { if (n.this.f211y.f()) { n.this.f211y.b(this.f221a + " response: " + map, new Object[0]); } if (((o) n.this.f200n.get(Long.valueOf(this.f222b))) == this.f223c) { n.this.f200n.remove(Long.valueOf(this.f222b)); if (this.f224d != null) { String str = (String) map.get("s"); if (str.equals("ok")) { this.f224d.a(null, null); } else { this.f224d.a(str, (String) map.get("d")); } } } else if (n.this.f211y.f()) { n.this.f211y.b("Ignoring on complete for put " + this.f222b + " because it was removed already.", new Object[0]); } n.this.T(); } } public class f implements j { final Long f226a; final m f227b; f(Long l10, m mVar) { this.f226a = l10; this.f227b = mVar; } @Override public void a(Map<String, Object> map) { if (((m) n.this.f201o.get(this.f226a)) == this.f227b) { n.this.f201o.remove(this.f226a); this.f227b.d().a(map); } else if (n.this.f211y.f()) { n.this.f211y.b("Ignoring on complete for get " + this.f226a + " because it was removed already.", new Object[0]); } } } public class g implements j { final C0005n f229a; g(C0005n c0005n) { this.f229a = c0005n; } @Override public void a(Map<String, Object> map) { String str = (String) map.get("s"); if (str.equals("ok")) { Map map2 = (Map) map.get("d"); if (map2.containsKey("w")) { n.this.G0((List) map2.get("w"), this.f229a.f247b); } } if (((C0005n) n.this.f202p.get(this.f229a.d())) == this.f229a) { if (str.equals("ok")) { this.f229a.f246a.a(null, null); return; } n.this.o0(this.f229a.d()); this.f229a.f246a.a(str, (String) map.get("d")); } } } public class h implements j { h() { } @Override public void a(Map<String, Object> map) { String str = (String) map.get("s"); if (str.equals("ok")) { return; } String str2 = (String) map.get("d"); if (n.this.f211y.f()) { n.this.f211y.b("Failed to send stats: " + str + " (message: " + str2 + ")", new Object[0]); } } } public class i implements Runnable { i() { } @Override public void run() { n.this.E = null; if (n.this.Y()) { n.this.c("connection_idle"); } else { n.this.T(); } } } public interface j { void a(Map<String, Object> map); } public enum k { Disconnected, GettingToken, Connecting, Authenticating, Connected } public static class l { private final String f239a; private final List<String> f240b; private final Object f241c; private final a6.p f242d; private l(String str, List<String> list, Object obj, a6.p pVar) { this.f239a = str; this.f240b = list; this.f241c = obj; this.f242d = pVar; } l(String str, List list, Object obj, a6.p pVar, a aVar) { this(str, list, obj, pVar); } public String b() { return this.f239a; } public Object c() { return this.f241c; } public a6.p d() { return this.f242d; } public List<String> e() { return this.f240b; } } public static class m { private final Map<String, Object> f243a; private final j f244b; private boolean f245c; private m(String str, Map<String, Object> map, j jVar) { this.f243a = map; this.f244b = jVar; this.f245c = false; } m(String str, Map map, j jVar, a aVar) { this(str, map, jVar); } public j d() { return this.f244b; } public Map<String, Object> e() { return this.f243a; } public boolean f() { if (this.f245c) { return false; } this.f245c = true; return true; } } public static class C0005n { private final a6.p f246a; private final p f247b; private final a6.g f248c; private final Long f249d; private C0005n(a6.p pVar, p pVar2, Long l10, a6.g gVar) { this.f246a = pVar; this.f247b = pVar2; this.f248c = gVar; this.f249d = l10; } C0005n(a6.p pVar, p pVar2, Long l10, a6.g gVar, a aVar) { this(pVar, pVar2, l10, gVar); } public a6.g c() { return this.f248c; } public p d() { return this.f247b; } public Long e() { return this.f249d; } public String toString() { return this.f247b.toString() + " (Tag: " + this.f249d + ")"; } } public static class o { private String f250a; private Map<String, Object> f251b; private a6.p f252c; private boolean f253d; private o(String str, Map<String, Object> map, a6.p pVar) { this.f250a = str; this.f251b = map; this.f252c = pVar; } o(String str, Map map, a6.p pVar, a aVar) { this(str, map, pVar); } public String b() { return this.f250a; } public a6.p c() { return this.f252c; } public Map<String, Object> d() { return this.f251b; } public void e() { this.f253d = true; } public boolean f() { return this.f253d; } } public static class p { private final List<String> f254a; private final Map<String, Object> f255b; public p(List<String> list, Map<String, Object> map) { this.f254a = list; this.f255b = map; } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof p)) { return false; } p pVar = (p) obj; if (this.f254a.equals(pVar.f254a)) { return this.f255b.equals(pVar.f255b); } return false; } public int hashCode() { return (this.f254a.hashCode() * 31) + this.f255b.hashCode(); } public String toString() { return a6.e.d(this.f254a) + " (params: " + this.f255b + ")"; } } public n(a6.c cVar, a6.f fVar, h.a aVar) { this.f187a = aVar; this.f207u = cVar; ScheduledExecutorService e10 = cVar.e(); this.f210x = e10; this.f208v = cVar.c(); this.f209w = cVar.a(); this.f188b = fVar; this.f202p = new HashMap(); this.f198l = new HashMap(); this.f200n = new HashMap(); this.f201o = new ConcurrentHashMap(); this.f199m = new ArrayList(); this.f212z = new a.b(e10, cVar.f(), "ConnectionRetryHelper").d(1000L).e(1.3d).c(30000L).b(0.7d).a(); long j10 = H; H = 1 + j10; this.f211y = new j6.c(cVar.f(), "PersistentConnection", "pc_" + j10); this.A = null; T(); } private void A0(long j10) { a6.e.b(Q(), "sendPut called when we can't send writes (we're disconnected or writes are paused).", new Object[0]); o oVar = this.f200n.get(Long.valueOf(j10)); a6.p c10 = oVar.c(); String b10 = oVar.b(); oVar.e(); s0(b10, oVar.d(), new e(b10, j10, oVar, c10)); } private void B0(String str, boolean z10, Map<String, Object> map, j jVar) { long g02 = g0(); HashMap hashMap = new HashMap(); hashMap.put("r", Long.valueOf(g02)); hashMap.put("a", str); hashMap.put("b", map); this.f193g.m(hashMap, z10); this.f198l.put(Long.valueOf(g02), jVar); } private void C0(Map<String, Integer> map) { if (map.isEmpty()) { if (this.f211y.f()) { this.f211y.b("Not sending stats because stats are empty", new Object[0]); } } else { HashMap hashMap = new HashMap(); hashMap.put("c", map); s0("s", hashMap, new h()); } } private void D0(C0005n c0005n) { HashMap hashMap = new HashMap(); hashMap.put("p", a6.e.d(c0005n.f247b.f254a)); Long e10 = c0005n.e(); if (e10 != null) { hashMap.put("q", c0005n.d().f255b); hashMap.put("t", e10); } s0("n", hashMap, null); } private void F0() { if (E0()) { k kVar = this.f194h; a6.e.b(kVar == k.Disconnected, "Not in disconnected state: %s", kVar); final boolean z10 = this.f204r; final boolean z11 = this.f206t; this.f211y.b("Scheduling connection attempt", new Object[0]); this.f204r = false; this.f206t = false; this.f212z.c(new Runnable() { @Override public final void run() { n.this.f0(z10, z11); } }); } } public void G0(List<String> list, p pVar) { if (list.contains("no_index")) { String str = "\".indexOn\": \"" + pVar.f255b.get("i") + '\"'; this.f211y.i("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '" + str + "' at " + a6.e.d(pVar.f254a) + " to your security and Firebase Database rules for better performance"); } } private boolean P() { return this.f194h == k.Connected; } private boolean Q() { return this.f194h == k.Connected; } private void R() { ArrayList arrayList = new ArrayList(); Iterator<Map.Entry<Long, o>> it = this.f200n.entrySet().iterator(); while (it.hasNext()) { o value = it.next().getValue(); if (value.d().containsKey("h") && value.f()) { arrayList.add(value); it.remove(); } } Iterator it2 = arrayList.iterator(); while (it2.hasNext()) { ((o) it2.next()).c().a("disconnected", null); } } private boolean S() { k kVar = this.f194h; return kVar == k.Authenticating || kVar == k.Connected; } public void T() { if (Z()) { ScheduledFuture<?> scheduledFuture = this.E; if (scheduledFuture != null) { scheduledFuture.cancel(false); } this.E = this.f210x.schedule(new i(), 60000L, TimeUnit.MILLISECONDS); return; } if (a0("connection_idle")) { a6.e.a(!Z()); f("connection_idle"); } } private u4.l<String> U(boolean z10) { u4.m mVar = new u4.m(); this.f211y.b("Trying to fetch app check token", new Object[0]); this.f209w.a(z10, new b(mVar)); return mVar.a(); } private u4.l<String> V(boolean z10) { u4.m mVar = new u4.m(); this.f211y.b("Trying to fetch auth token", new Object[0]); this.f208v.a(z10, new a(mVar)); return mVar.a(); } private Map<String, Object> W(List<String> list, Object obj, String str) { HashMap hashMap = new HashMap(); hashMap.put("p", a6.e.d(list)); hashMap.put("d", obj); if (str != null) { hashMap.put("h", str); } return hashMap; } private void X(long j10) { if (this.f211y.f()) { this.f211y.b("handling timestamp", new Object[0]); } long currentTimeMillis = j10 - System.currentTimeMillis(); HashMap hashMap = new HashMap(); hashMap.put("serverTimeOffset", Long.valueOf(currentTimeMillis)); this.f187a.d(hashMap); } public boolean Y() { return Z() && System.currentTimeMillis() > this.F + 60000; } private boolean Z() { return this.f202p.isEmpty() && this.f201o.isEmpty() && this.f198l.isEmpty() && !this.G && this.f200n.isEmpty(); } public static void b0(u4.m mVar, Map map) { if (((String) map.get("s")).equals("ok")) { mVar.c(map.get("d")); } else { mVar.b(new Exception((String) map.get("d"))); } } public void c0(boolean z10, Map map) { String str = (String) map.get("s"); if (str.equals("ok")) { this.D = 0; } else { this.f205s = null; this.f206t = true; String str2 = (String) map.get("d"); this.f211y.b("App check failed: " + str + " (" + str2 + ")", new Object[0]); } if (z10) { q0(); } } public void d0(long j10, u4.l lVar, u4.l lVar2, Void r72) { if (j10 != this.B) { this.f211y.b("Ignoring getToken result, because this was not the latest attempt.", new Object[0]); return; } k kVar = this.f194h; if (kVar == k.GettingToken) { this.f211y.b("Successfully fetched token, opening connection", new Object[0]); m0((String) lVar.m(), (String) lVar2.m()); } else if (kVar == k.Disconnected) { this.f211y.b("Not opening connection after token refresh, because connection was set to disconnected", new Object[0]); } } public void e0(long j10, Exception exc) { if (j10 != this.B) { this.f211y.b("Ignoring getToken error, because this was not the latest attempt.", new Object[0]); return; } this.f194h = k.Disconnected; this.f211y.b("Error fetching token: " + exc, new Object[0]); F0(); } public void f0(boolean z10, boolean z11) { k kVar = this.f194h; a6.e.b(kVar == k.Disconnected, "Not in disconnected state: %s", kVar); this.f194h = k.GettingToken; final long j10 = this.B + 1; this.B = j10; final u4.l<String> V = V(z10); final u4.l<String> U = U(z11); u4.o.h(V, U).f(this.f210x, new u4.h() { @Override public final void a(Object obj) { n.this.d0(j10, V, U, (Void) obj); } }).d(this.f210x, new u4.g() { @Override public final void b(Exception exc) { n.this.e0(j10, exc); } }); } private long g0() { long j10 = this.f197k; this.f197k = 1 + j10; return j10; } private void h0(String str, String str2) { this.f211y.b("App check token revoked: " + str + " (" + str2 + ")", new Object[0]); this.f205s = null; this.f206t = true; } private void i0(String str, String str2) { this.f211y.b("Auth token revoked: " + str + " (" + str2 + ")", new Object[0]); this.f203q = null; this.f204r = true; this.f187a.b(false); this.f193g.c(); } private void j0(String str, Map<String, Object> map) { if (this.f211y.f()) { this.f211y.b("handleServerMessage: " + str + " " + map, new Object[0]); } if (str.equals("d") || str.equals("m")) { boolean equals = str.equals("m"); String str2 = (String) map.get("p"); Object obj = map.get("d"); Long c10 = a6.e.c(map.get("t")); if (!equals || !(obj instanceof Map) || ((Map) obj).size() != 0) { this.f187a.a(a6.e.e(str2), obj, equals, c10); return; } if (this.f211y.f()) { this.f211y.b("ignoring empty merge for path " + str2, new Object[0]); return; } return; } if (!str.equals("rm")) { if (str.equals("c")) { k0(a6.e.e((String) map.get("p"))); return; } if (str.equals("ac")) { i0((String) map.get("s"), (String) map.get("d")); return; } if (str.equals("apc")) { h0((String) map.get("s"), (String) map.get("d")); return; } if (str.equals("sd")) { l0(map); return; } if (this.f211y.f()) { this.f211y.b("Unrecognized action from server: " + str, new Object[0]); return; } return; } String str3 = (String) map.get("p"); List<String> e10 = a6.e.e(str3); Object obj2 = map.get("d"); Long c11 = a6.e.c(map.get("t")); ArrayList arrayList = new ArrayList(); for (Map map2 : (List) obj2) { String str4 = (String) map2.get("s"); String str5 = (String) map2.get("e"); List<String> list = null; List<String> e11 = str4 != null ? a6.e.e(str4) : null; if (str5 != null) { list = a6.e.e(str5); } arrayList.add(new a6.o(e11, list, map2.get("m"))); } if (!arrayList.isEmpty()) { this.f187a.f(e10, arrayList, c11); return; } if (this.f211y.f()) { this.f211y.b("Ignoring empty range merge for path " + str3, new Object[0]); } } private void k0(List<String> list) { Collection<C0005n> p02 = p0(list); if (p02 != null) { Iterator<C0005n> it = p02.iterator(); while (it.hasNext()) { it.next().f246a.a("permission_denied", null); } } } private void l0(Map<String, Object> map) { this.f211y.e((String) map.get("msg")); } private void n0(String str, List<String> list, Object obj, String str2, a6.p pVar) { Map<String, Object> W = W(list, obj, str2); long j10 = this.f195i; this.f195i = 1 + j10; this.f200n.put(Long.valueOf(j10), new o(str, W, pVar, null)); if (Q()) { A0(j10); } this.F = System.currentTimeMillis(); T(); } public C0005n o0(p pVar) { if (this.f211y.f()) { this.f211y.b("removing query " + pVar, new Object[0]); } if (this.f202p.containsKey(pVar)) { C0005n c0005n = this.f202p.get(pVar); this.f202p.remove(pVar); T(); return c0005n; } if (!this.f211y.f()) { return null; } this.f211y.b("Trying to remove listener for QuerySpec " + pVar + " but no listener exists.", new Object[0]); return null; } private Collection<C0005n> p0(List<String> list) { if (this.f211y.f()) { this.f211y.b("removing all listens at path " + list, new Object[0]); } ArrayList arrayList = new ArrayList(); for (Map.Entry<p, C0005n> entry : this.f202p.entrySet()) { p key = entry.getKey(); C0005n value = entry.getValue(); if (key.f254a.equals(list)) { arrayList.add(value); } } Iterator it = arrayList.iterator(); while (it.hasNext()) { this.f202p.remove(((C0005n) it.next()).d()); } T(); return arrayList; } private void q0() { k kVar = this.f194h; a6.e.b(kVar == k.Connected, "Should be connected if we're restoring state, but we are: %s", kVar); if (this.f211y.f()) { this.f211y.b("Restoring outstanding listens", new Object[0]); } for (C0005n c0005n : this.f202p.values()) { if (this.f211y.f()) { this.f211y.b("Restoring listen " + c0005n.d(), new Object[0]); } y0(c0005n); } if (this.f211y.f()) { this.f211y.b("Restoring writes.", new Object[0]); } ArrayList arrayList = new ArrayList(this.f200n.keySet()); Collections.sort(arrayList); Iterator it = arrayList.iterator(); while (it.hasNext()) { A0(((Long) it.next()).longValue()); } for (l lVar : this.f199m) { z0(lVar.b(), lVar.e(), lVar.c(), lVar.d()); } this.f199m.clear(); if (this.f211y.f()) { this.f211y.b("Restoring reads.", new Object[0]); } ArrayList arrayList2 = new ArrayList(this.f201o.keySet()); Collections.sort(arrayList2); Iterator it2 = arrayList2.iterator(); while (it2.hasNext()) { x0((Long) it2.next()); } } private void r0() { if (this.f211y.f()) { this.f211y.b("calling restore tokens", new Object[0]); } k kVar = this.f194h; a6.e.b(kVar == k.Connecting, "Wanted to restore tokens, but was in wrong state: %s", kVar); if (this.f203q != null) { if (this.f211y.f()) { this.f211y.b("Restoring auth.", new Object[0]); } this.f194h = k.Authenticating; u0(); return; } if (this.f211y.f()) { this.f211y.b("Not restoring auth because auth token is null.", new Object[0]); } this.f194h = k.Connected; t0(true); } private void s0(String str, Map<String, Object> map, j jVar) { B0(str, false, map, jVar); } public void t0(final boolean z10) { if (this.f205s == null) { q0(); return; } a6.e.b(S(), "Must be connected to send auth, but was: %s", this.f194h); if (this.f211y.f()) { this.f211y.b("Sending app check.", new Object[0]); } j jVar = new j() { @Override public final void a(Map map) { n.this.c0(z10, map); } }; HashMap hashMap = new HashMap(); a6.e.b(this.f205s != null, "App check token must be set!", new Object[0]); hashMap.put("token", this.f205s); B0("appcheck", true, hashMap, jVar); } private void u0() { v0(true); } private void v0(boolean z10) { String str; a6.e.b(S(), "Must be connected to send auth, but was: %s", this.f194h); if (this.f211y.f()) { this.f211y.b("Sending auth.", new Object[0]); } d dVar = new d(z10); HashMap hashMap = new HashMap(); m6.a c10 = m6.a.c(this.f203q); if (c10 != null) { hashMap.put("cred", c10.b()); if (c10.a() != null) { hashMap.put("authvar", c10.a()); } str = "gauth"; } else { hashMap.put("cred", this.f203q); str = "auth"; } B0(str, true, hashMap, dVar); } private void w0() { HashMap hashMap = new HashMap(); if (this.f207u.i()) { hashMap.put("persistence.android.enabled", 1); } hashMap.put("sdk.android." + this.f207u.d().replace('.', '-'), 1); if (this.f211y.f()) { this.f211y.b("Sending first connection stats", new Object[0]); } C0(hashMap); } private void x0(Long l10) { a6.e.b(P(), "sendGet called when we can't send gets", new Object[0]); m mVar = this.f201o.get(l10); if (mVar.f() || !this.f211y.f()) { s0("g", mVar.e(), new f(l10, mVar)); return; } this.f211y.b("get" + l10 + " cancelled, ignoring.", new Object[0]); } static int y(n nVar) { int i10 = nVar.C; nVar.C = i10 + 1; return i10; } private void y0(C0005n c0005n) { Map<String, Object> hashMap = new HashMap<>(); hashMap.put("p", a6.e.d(c0005n.d().f254a)); Object e10 = c0005n.e(); if (e10 != null) { hashMap.put("q", c0005n.f247b.f255b); hashMap.put("t", e10); } a6.g c10 = c0005n.c(); hashMap.put("h", c10.d()); if (c10.b()) { a6.a a10 = c10.a(); ArrayList arrayList = new ArrayList(); Iterator<List<String>> it = a10.b().iterator(); while (it.hasNext()) { arrayList.add(a6.e.d(it.next())); } HashMap hashMap2 = new HashMap(); hashMap2.put("hs", a10.a()); hashMap2.put("ps", arrayList); hashMap.put("ch", hashMap2); } s0("q", hashMap, new g(c0005n)); } private void z0(String str, List<String> list, Object obj, a6.p pVar) { HashMap hashMap = new HashMap(); hashMap.put("p", a6.e.d(list)); hashMap.put("d", obj); s0(str, hashMap, new c(pVar)); } boolean E0() { return this.f190d.size() == 0; } @Override public u4.l<Object> a(List<String> list, Map<String, Object> map) { p pVar = new p(list, map); final u4.m mVar = new u4.m(); long j10 = this.f196j; this.f196j = 1 + j10; HashMap hashMap = new HashMap(); hashMap.put("p", a6.e.d(pVar.f254a)); hashMap.put("q", pVar.f255b); this.f201o.put(Long.valueOf(j10), new m("g", hashMap, new j() { @Override public final void a(Map map2) { n.b0(u4.m.this, map2); } }, null)); if (P()) { x0(Long.valueOf(j10)); } T(); return mVar.a(); } public boolean a0(String str) { return this.f190d.contains(str); } @Override public void b() { for (o oVar : this.f200n.values()) { if (oVar.f252c != null) { oVar.f252c.a("write_canceled", null); } } for (l lVar : this.f199m) { if (lVar.f242d != null) { lVar.f242d.a("write_canceled", null); } } this.f200n.clear(); this.f199m.clear(); if (!S()) { this.G = false; } T(); } @Override public void c(String str) { if (this.f211y.f()) { this.f211y.b("Connection interrupted for: " + str, new Object[0]); } this.f190d.add(str); a6.b bVar = this.f193g; if (bVar != null) { bVar.c(); this.f193g = null; } else { this.f212z.b(); this.f194h = k.Disconnected; } this.f212z.e(); } @Override public void d(List<String> list, a6.p pVar) { if (Q()) { z0("oc", list, null, pVar); } else { this.f199m.add(new l("oc", list, null, pVar, null)); } T(); } @Override public void e(String str) { this.f189c = str; } @Override public void f(String str) { if (this.f211y.f()) { this.f211y.b("Connection no longer interrupted for: " + str, new Object[0]); } this.f190d.remove(str); if (E0() && this.f194h == k.Disconnected) { F0(); } } @Override public void g(String str) { if (str.equals("Invalid appcheck token")) { int i10 = this.D; if (i10 < 3) { this.D = i10 + 1; this.f211y.i("Detected invalid AppCheck token. Reconnecting (" + (3 - this.D) + " attempts remaining)"); return; } } this.f211y.i("Firebase Database connection was forcefully killed by the server. Will not attempt reconnect. Reason: " + str); c("server_kill"); } @Override public void h(List<String> list, Map<String, Object> map, a6.p pVar) { n0("m", list, map, null, pVar); } @Override public void i(long j10, String str) { if (this.f211y.f()) { this.f211y.b("onReady", new Object[0]); } this.f192f = System.currentTimeMillis(); X(j10); if (this.f191e) { w0(); } r0(); this.f191e = false; this.A = str; this.f187a.c(); } @Override public void initialize() { F0(); } @Override public void j(b.EnumC0004b enumC0004b) { boolean z10 = false; if (this.f211y.f()) { this.f211y.b("Got on disconnect due to " + enumC0004b.name(), new Object[0]); } this.f194h = k.Disconnected; this.f193g = null; this.G = false; this.f198l.clear(); R(); if (E0()) { long currentTimeMillis = System.currentTimeMillis(); long j10 = this.f192f; long j11 = currentTimeMillis - j10; if (j10 > 0 && j11 > 30000) { z10 = true; } if (enumC0004b == b.EnumC0004b.SERVER_RESET || z10) { this.f212z.e(); } F0(); } this.f192f = 0L; this.f187a.e(); } @Override public void k(Map<String, Object> map) { if (map.containsKey("r")) { j remove = this.f198l.remove(Long.valueOf(((Integer) map.get("r")).intValue())); if (remove != null) { remove.a((Map) map.get("b")); return; } return; } if (map.containsKey("error")) { return; } if (map.containsKey("a")) { j0((String) map.get("a"), (Map) map.get("b")); return; } if (this.f211y.f()) { this.f211y.b("Ignoring unknown message: " + map, new Object[0]); } } @Override public void l(List<String> list, Map<String, Object> map, a6.g gVar, Long l10, a6.p pVar) { p pVar2 = new p(list, map); if (this.f211y.f()) { this.f211y.b("Listening on " + pVar2, new Object[0]); } a6.e.b(!this.f202p.containsKey(pVar2), "listen() called twice for same QuerySpec.", new Object[0]); if (this.f211y.f()) { this.f211y.b("Adding listen query: " + pVar2, new Object[0]); } C0005n c0005n = new C0005n(pVar, pVar2, l10, gVar, null); this.f202p.put(pVar2, c0005n); if (S()) { y0(c0005n); } T(); } @Override public void m(List<String> list, Object obj, a6.p pVar) { this.G = true; if (Q()) { z0("o", list, obj, pVar); } else { this.f199m.add(new l("o", list, obj, pVar, null)); } T(); } public void m0(String str, String str2) { k kVar = this.f194h; a6.e.b(kVar == k.GettingToken, "Trying to open network connection while in the wrong state: %s", kVar); if (str == null) { this.f187a.b(false); } this.f203q = str; this.f205s = str2; this.f194h = k.Connecting; a6.b bVar = new a6.b(this.f207u, this.f188b, this.f189c, this, this.A, str2); this.f193g = bVar; bVar.k(); } @Override public void n(List<String> list, Object obj, a6.p pVar) { n0("p", list, obj, null, pVar); } @Override public void o(List<String> list, Map<String, Object> map, a6.p pVar) { this.G = true; if (Q()) { z0("om", list, map, pVar); } else { this.f199m.add(new l("om", list, map, pVar, null)); } T(); } @Override public void p(List<String> list, Object obj, String str, a6.p pVar) { n0("p", list, obj, str, pVar); } @Override public void q(List<String> list, Map<String, Object> map) { p pVar = new p(list, map); if (this.f211y.f()) { this.f211y.b("unlistening on " + pVar, new Object[0]); } C0005n o02 = o0(pVar); if (o02 != null && S()) { D0(o02); } T(); } }