CAG v5.7.4版本的 MD5 值为:bc57ead76a7a30559f0708e9d60d749f
以下内容为反编译后的 g.java 源代码,内容仅作参考
package i.j.b.t;
import android.net.TrafficStats;
import android.text.TextUtils;
import android.util.Log;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.heartbeatinfo.HeartBeatInfo;
import com.google.firebase.installations.FirebaseInstallationsException;
import com.google.firebase.installations.local.PersistedInstallation;
import com.google.firebase.installations.remote.InstallationResponse;
import com.google.firebase.installations.remote.TokenResult;
import i.j.b.t.p.a;
import i.j.b.t.p.c;
import i.j.b.t.q.b;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
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;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import org.json.JSONException;
import org.json.JSONObject;
public class g implements h {
public static final Object f12867m = new Object();
public static final ThreadFactory f12868n = new a();
public final i.j.b.g a;
public final i.j.b.t.q.c b;
public final PersistedInstallation c;
public final n f12869d;
public final i.j.b.t.p.b f12870e;
public final l f12871f;
public final Object f12872g;
public final ExecutorService f12873h;
public final ExecutorService f12874i;
public String f12875j;
public Set<i.j.b.t.o.a> f12876k;
public final List<m> f12877l;
public class a implements ThreadFactory {
public final AtomicInteger a = new AtomicInteger(1);
@Override
public Thread newThread(Runnable runnable) {
return new Thread(runnable, String.format("firebase-installations-executor-%d", Integer.valueOf(this.a.getAndIncrement())));
}
}
public g(i.j.b.g gVar, i.j.b.s.b<i.j.b.w.h> bVar, i.j.b.s.b<HeartBeatInfo> bVar2) {
TimeUnit timeUnit = TimeUnit.SECONDS;
LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue();
ThreadFactory threadFactory = f12868n;
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, 30L, timeUnit, linkedBlockingQueue, threadFactory);
gVar.a();
i.j.b.t.q.c cVar = new i.j.b.t.q.c(gVar.a, bVar, bVar2);
PersistedInstallation persistedInstallation = new PersistedInstallation(gVar);
n c = n.c();
i.j.b.t.p.b bVar3 = new i.j.b.t.p.b(gVar);
l lVar = new l();
this.f12872g = new Object();
this.f12876k = new HashSet();
this.f12877l = new ArrayList();
this.a = gVar;
this.b = cVar;
this.c = persistedInstallation;
this.f12869d = c;
this.f12870e = bVar3;
this.f12871f = lVar;
this.f12873h = threadPoolExecutor;
this.f12874i = new ThreadPoolExecutor(0, 1, 30L, timeUnit, new LinkedBlockingQueue(), threadFactory);
}
public static g f(i.j.b.g gVar) {
Preconditions.checkArgument(true, "Null is not a valid value of FirebaseApp.");
gVar.a();
return (g) gVar.f12575d.a(h.class);
}
@Override
public Task<k> a(final boolean z) {
h();
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
i iVar = new i(this.f12869d, taskCompletionSource);
synchronized (this.f12872g) {
this.f12877l.add(iVar);
}
Task<k> task = taskCompletionSource.getTask();
this.f12873h.execute(new Runnable() {
@Override
public final void run() {
g.this.b(z);
}
});
return task;
}
public final void b(final boolean z) {
i.j.b.t.p.c b;
synchronized (f12867m) {
i.j.b.g gVar = this.a;
gVar.a();
f a2 = f.a(gVar.a, "generatefid.lock");
b = this.c.b();
if (b.i()) {
String i2 = i(b);
PersistedInstallation persistedInstallation = this.c;
a.b bVar = (a.b) b.k();
bVar.a = i2;
bVar.b(PersistedInstallation.RegistrationStatus.UNREGISTERED);
b = bVar.a();
persistedInstallation.a(b);
}
if (a2 != null) {
a2.b();
}
}
if (z) {
a.b bVar2 = (a.b) b.k();
bVar2.c = null;
b = bVar2.a();
}
l(b);
this.f12874i.execute(new Runnable() {
@Override
public final void run() {
i.j.b.t.p.c b2;
i.j.b.t.p.c j2;
g gVar2 = g.this;
boolean z2 = z;
Objects.requireNonNull(gVar2);
Object obj = g.f12867m;
synchronized (obj) {
i.j.b.g gVar3 = gVar2.a;
gVar3.a();
f a3 = f.a(gVar3.a, "generatefid.lock");
b2 = gVar2.c.b();
if (a3 != null) {
a3.b();
}
}
try {
if (!b2.h()) {
if (!(b2.f() == PersistedInstallation.RegistrationStatus.UNREGISTERED)) {
if (z2 || gVar2.f12869d.d(b2)) {
j2 = gVar2.c(b2);
synchronized (obj) {
i.j.b.g gVar4 = gVar2.a;
gVar4.a();
f a4 = f.a(gVar4.a, "generatefid.lock");
gVar2.c.a(j2);
if (a4 != null) {
a4.b();
}
}
synchronized (gVar2) {
if (gVar2.f12876k.size() != 0 && !b2.c().equals(j2.c())) {
for (i.j.b.t.o.a aVar : gVar2.f12876k) {
aVar.a(j2.c());
}
}
}
if (j2.j()) {
String str = ((i.j.b.t.p.a) j2).b;
synchronized (gVar2) {
gVar2.f12875j = str;
}
}
if (j2.h()) {
gVar2.k(new FirebaseInstallationsException(FirebaseInstallationsException.Status.BAD_CONFIG));
return;
} else if (j2.i()) {
gVar2.k(new IOException("Installation ID could not be validated with the Firebase servers (maybe it was deleted). Firebase Installations will need to create a new Installation ID and auth token. Please retry your last request."));
return;
} else {
gVar2.l(j2);
return;
}
}
return;
}
}
j2 = gVar2.j(b2);
synchronized (obj) {
}
} catch (FirebaseInstallationsException e2) {
gVar2.k(e2);
}
}
});
}
public final i.j.b.t.p.c c(i.j.b.t.p.c cVar) throws FirebaseInstallationsException {
int responseCode;
TokenResult f2;
i.j.b.t.q.c cVar2 = this.b;
String d2 = d();
i.j.b.t.p.a aVar = (i.j.b.t.p.a) cVar;
String str = aVar.b;
String g2 = g();
String str2 = aVar.f12880e;
if (cVar2.f12892d.a()) {
URL a2 = cVar2.a(String.format("projects/%s/installations/%s/authTokens:generate", g2, str));
for (int i2 = 0; i2 <= 1; i2++) {
TrafficStats.setThreadStatsTag(32771);
HttpURLConnection c = cVar2.c(a2, d2);
try {
c.setRequestMethod("POST");
c.addRequestProperty("Authorization", "FIS_v2 " + str2);
c.setDoOutput(true);
cVar2.h(c);
responseCode = c.getResponseCode();
cVar2.f12892d.b(responseCode);
} catch (IOException | AssertionError unused) {
} catch (Throwable th) {
c.disconnect();
TrafficStats.clearThreadStatsTag();
throw th;
}
if (responseCode >= 200 && responseCode < 300) {
f2 = cVar2.f(c);
} else {
i.j.b.t.q.c.b(c, null, d2, g2);
if (responseCode != 401 && responseCode != 404) {
if (responseCode == 429) {
throw new FirebaseInstallationsException("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", FirebaseInstallationsException.Status.TOO_MANY_REQUESTS);
}
if (responseCode < 500 || responseCode >= 600) {
Log.e("Firebase-Installations", "Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.");
b.C0195b c0195b = (b.C0195b) TokenResult.a();
c0195b.c = TokenResult.ResponseCode.BAD_CONFIG;
f2 = c0195b.a();
} else {
c.disconnect();
TrafficStats.clearThreadStatsTag();
}
}
b.C0195b c0195b2 = (b.C0195b) TokenResult.a();
c0195b2.c = TokenResult.ResponseCode.AUTH_ERROR;
f2 = c0195b2.a();
}
c.disconnect();
TrafficStats.clearThreadStatsTag();
i.j.b.t.q.b bVar = (i.j.b.t.q.b) f2;
int ordinal = bVar.c.ordinal();
if (ordinal == 0) {
String str3 = bVar.a;
long j2 = bVar.b;
long b = this.f12869d.b();
a.b bVar2 = (a.b) cVar.k();
bVar2.c = str3;
bVar2.f12885e = Long.valueOf(j2);
bVar2.f12886f = Long.valueOf(b);
return bVar2.a();
} else if (ordinal == 1) {
a.b bVar3 = (a.b) cVar.k();
bVar3.f12887g = "BAD CONFIG";
bVar3.b(PersistedInstallation.RegistrationStatus.REGISTER_ERROR);
return bVar3.a();
} else if (ordinal == 2) {
synchronized (this) {
this.f12875j = null;
}
c.a k2 = cVar.k();
k2.b(PersistedInstallation.RegistrationStatus.NOT_GENERATED);
return k2.a();
} else {
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
public String d() {
i.j.b.g gVar = this.a;
gVar.a();
return gVar.c.a;
}
public String e() {
i.j.b.g gVar = this.a;
gVar.a();
return gVar.c.b;
}
public String g() {
i.j.b.g gVar = this.a;
gVar.a();
return gVar.c.f12584g;
}
@Override
public Task<String> getId() {
String str;
h();
synchronized (this) {
str = this.f12875j;
}
if (str != null) {
return Tasks.forResult(str);
}
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
j jVar = new j(taskCompletionSource);
synchronized (this.f12872g) {
this.f12877l.add(jVar);
}
Task<String> task = taskCompletionSource.getTask();
this.f12873h.execute(new Runnable() {
@Override
public final void run() {
g.this.b(false);
}
});
return task;
}
public final void h() {
Preconditions.checkNotEmpty(e(), "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.");
Preconditions.checkNotEmpty(g(), "Please set your Project ID. A valid Firebase Project 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.");
Preconditions.checkNotEmpty(d(), "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.");
String e2 = e();
Pattern pattern = n.c;
Preconditions.checkArgument(e2.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.");
Preconditions.checkArgument(n.c.matcher(d()).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.");
}
public final String i(i.j.b.t.p.c cVar) {
String string;
i.j.b.g gVar = this.a;
gVar.a();
if (gVar.b.equals("CHIME_ANDROID_SDK") || this.a.h()) {
if (((i.j.b.t.p.a) cVar).c == PersistedInstallation.RegistrationStatus.ATTEMPT_MIGRATION) {
i.j.b.t.p.b bVar = this.f12870e;
synchronized (bVar.a) {
synchronized (bVar.a) {
string = bVar.a.getString("|S|id", null);
}
if (string == null) {
string = bVar.a();
}
}
return TextUtils.isEmpty(string) ? this.f12871f.a() : string;
}
}
return this.f12871f.a();
}
public final i.j.b.t.p.c j(i.j.b.t.p.c cVar) throws FirebaseInstallationsException {
int responseCode;
InstallationResponse e2;
i.j.b.t.p.a aVar = (i.j.b.t.p.a) cVar;
String str = aVar.b;
String str2 = null;
if (str != null && str.length() == 11) {
i.j.b.t.p.b bVar = this.f12870e;
synchronized (bVar.a) {
String[] strArr = i.j.b.t.p.b.c;
int length = strArr.length;
int i2 = 0;
while (true) {
if (i2 >= length) {
break;
}
String str3 = strArr[i2];
String str4 = bVar.b;
String string = bVar.a.getString("|T|" + str4 + "|" + str3, null);
if (string == null || string.isEmpty()) {
i2++;
} else if (string.startsWith("{")) {
try {
str2 = new JSONObject(string).getString("token");
} catch (JSONException unused) {
}
} else {
str2 = string;
}
}
}
}
i.j.b.t.q.c cVar2 = this.b;
String d2 = d();
String str5 = aVar.b;
String g2 = g();
String e3 = e();
if (cVar2.f12892d.a()) {
URL a2 = cVar2.a(String.format("projects/%s/installations", g2));
for (int i3 = 0; i3 <= 1; i3++) {
TrafficStats.setThreadStatsTag(32769);
HttpURLConnection c = cVar2.c(a2, d2);
try {
c.setRequestMethod("POST");
c.setDoOutput(true);
if (str2 != null) {
c.addRequestProperty("x-goog-fis-android-iid-migration-auth", str2);
}
cVar2.g(c, str5, e3);
responseCode = c.getResponseCode();
cVar2.f12892d.b(responseCode);
} catch (IOException | AssertionError unused2) {
} catch (Throwable th) {
c.disconnect();
TrafficStats.clearThreadStatsTag();
throw th;
}
if (responseCode >= 200 && responseCode < 300) {
e2 = cVar2.e(c);
c.disconnect();
TrafficStats.clearThreadStatsTag();
} else {
i.j.b.t.q.c.b(c, e3, d2, g2);
if (responseCode == 429) {
throw new FirebaseInstallationsException("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", FirebaseInstallationsException.Status.TOO_MANY_REQUESTS);
}
if (responseCode < 500 || responseCode >= 600) {
Log.e("Firebase-Installations", "Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.");
i.j.b.t.q.a aVar2 = new i.j.b.t.q.a(null, null, null, null, InstallationResponse.ResponseCode.BAD_CONFIG, null);
c.disconnect();
TrafficStats.clearThreadStatsTag();
e2 = aVar2;
} else {
c.disconnect();
TrafficStats.clearThreadStatsTag();
}
}
i.j.b.t.q.a aVar3 = (i.j.b.t.q.a) e2;
int ordinal = aVar3.f12889e.ordinal();
if (ordinal != 0) {
if (ordinal == 1) {
a.b bVar2 = (a.b) cVar.k();
bVar2.f12887g = "BAD CONFIG";
bVar2.b(PersistedInstallation.RegistrationStatus.REGISTER_ERROR);
return bVar2.a();
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
String str6 = aVar3.b;
String str7 = aVar3.c;
long b = this.f12869d.b();
String c2 = aVar3.f12888d.c();
long d3 = aVar3.f12888d.d();
a.b bVar3 = (a.b) cVar.k();
bVar3.a = str6;
bVar3.b(PersistedInstallation.RegistrationStatus.REGISTERED);
bVar3.c = c2;
bVar3.f12884d = str7;
bVar3.f12885e = Long.valueOf(d3);
bVar3.f12886f = Long.valueOf(b);
return bVar3.a();
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
public final void k(Exception exc) {
synchronized (this.f12872g) {
Iterator<m> it = this.f12877l.iterator();
while (it.hasNext()) {
if (it.next().a(exc)) {
it.remove();
}
}
}
}
public final void l(i.j.b.t.p.c cVar) {
synchronized (this.f12872g) {
Iterator<m> it = this.f12877l.iterator();
while (it.hasNext()) {
if (it.next().b(cVar)) {
it.remove();
}
}
}
}
}