discord-jadx/app/src/main/java/com/google/firebase/iid/FirebaseInstanceId.java
2021-07-13 22:23:20 +02:00

286 lines
9.8 KiB
Java

package com.google.firebase.iid;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import android.util.Pair;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import c.i.c.c;
import c.i.c.r.d;
import c.i.c.s.i;
import c.i.c.s.j;
import c.i.c.s.k;
import c.i.c.s.l;
import c.i.c.s.n;
import c.i.c.s.o;
import c.i.c.s.p;
import c.i.c.s.q;
import c.i.c.s.t;
import c.i.c.s.u;
import c.i.c.s.w;
import c.i.c.s.x;
import c.i.c.t.a;
import c.i.c.u.g;
import c.i.c.x.h;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.google.android.gms.tasks.Task;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.regex.Pattern;
/* compiled from: com.google.firebase:firebase-iid@@21.0.0 */
@Deprecated
public class FirebaseInstanceId {
public static final long a = TimeUnit.HOURS.toSeconds(8);
public static w b;
/* renamed from: c reason: collision with root package name */
public static final Pattern f2366c = Pattern.compile("\\AA[\\w-]{38}\\z");
public static ScheduledExecutorService d;
public final Executor e;
public final c f;
public final q g;
public final n h;
public final u i;
public final g j;
public boolean k = false;
public FirebaseInstanceId(c cVar, a<h> aVar, a<d> aVar2, g gVar) {
cVar.a();
q qVar = new q(cVar.d);
ExecutorService a2 = c.i.c.s.h.a();
ExecutorService a3 = c.i.c.s.h.a();
if (q.b(cVar) != null) {
synchronized (FirebaseInstanceId.class) {
if (b == null) {
cVar.a();
b = new w(cVar.d);
}
}
this.f = cVar;
this.g = qVar;
this.h = new n(cVar, qVar, aVar, aVar2, gVar);
this.e = a3;
this.i = new u(a2);
this.j = gVar;
return;
}
throw new IllegalStateException("FirebaseInstanceId failed to initialize, FirebaseApp is missing project ID");
}
public static <T> T a(@NonNull Task<T> task) throws InterruptedException {
AnimatableValueParser.z(task, "Task must not be null");
CountDownLatch countDownLatch = new CountDownLatch(1);
task.c(j.i, new k(countDownLatch));
countDownLatch.await(30000, TimeUnit.MILLISECONDS);
if (task.p()) {
return task.l();
}
if (task.n()) {
throw new CancellationException("Task is already canceled");
} else if (task.o()) {
throw new IllegalStateException(task.k());
} else {
throw new IllegalThreadStateException("Firebase Installations getId Task has timed out.");
}
}
public static void c(@NonNull c cVar) {
cVar.a();
AnimatableValueParser.v(cVar.f.g, "Please set your project ID. A valid Firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Google.");
cVar.a();
AnimatableValueParser.v(cVar.f.b, "Please set your Application ID. A valid Firebase App ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.");
cVar.a();
AnimatableValueParser.v(cVar.f.a, "Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.");
cVar.a();
AnimatableValueParser.p(cVar.f.b.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.");
cVar.a();
AnimatableValueParser.p(f2366c.matcher(cVar.f.a).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.");
}
@NonNull
@Keep
public static FirebaseInstanceId getInstance(@NonNull c cVar) {
c(cVar);
cVar.a();
FirebaseInstanceId firebaseInstanceId = (FirebaseInstanceId) cVar.g.a(FirebaseInstanceId.class);
AnimatableValueParser.z(firebaseInstanceId, "Firebase Instance ID component is not present");
return firebaseInstanceId;
}
public static boolean l() {
if (!Log.isLoggable("FirebaseInstanceId", 3)) {
return Build.VERSION.SDK_INT == 23 && Log.isLoggable("FirebaseInstanceId", 3);
}
return true;
}
public String b() throws IOException {
String b2 = q.b(this.f);
c(this.f);
if (Looper.getMainLooper() != Looper.myLooper()) {
try {
return ((o) c.i.a.f.e.o.c.d(g(b2, "*"), 30000, TimeUnit.MILLISECONDS)).a();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof IOException) {
if ("INSTANCE_ID_RESET".equals(cause.getMessage())) {
synchronized (this) {
b.c();
}
}
throw ((IOException) cause);
} else if (cause instanceof RuntimeException) {
throw ((RuntimeException) cause);
} else {
throw new IOException(e);
}
} catch (InterruptedException | TimeoutException unused) {
throw new IOException("SERVICE_NOT_AVAILABLE");
}
} else {
throw new IOException("MAIN_THREAD");
}
}
public void d(Runnable runnable, long j) {
synchronized (FirebaseInstanceId.class) {
if (d == null) {
d = new ScheduledThreadPoolExecutor(1, new c.i.a.f.e.o.j.a("FirebaseInstanceId"));
}
d.schedule(runnable, j, TimeUnit.SECONDS);
}
}
public String e() {
try {
w wVar = b;
String c2 = this.f.c();
synchronized (wVar) {
wVar.f1364c.put(c2, Long.valueOf(wVar.d(c2)));
}
return (String) a(this.j.getId());
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
}
@NonNull
@Deprecated
public Task<o> f() {
c(this.f);
return g(q.b(this.f), "*");
}
public final Task<o> g(String str, String str2) {
if (str2.isEmpty() || str2.equalsIgnoreCase("fcm") || str2.equalsIgnoreCase("gcm")) {
str2 = "*";
}
return c.i.a.f.e.o.c.F(null).j(this.e, new i(this, str, str2));
}
public final String h() {
c cVar = this.f;
cVar.a();
return "[DEFAULT]".equals(cVar.e) ? "" : this.f.c();
}
@Nullable
@Deprecated
public String i() {
c(this.f);
w.a j = j();
if (p(j)) {
synchronized (this) {
if (!this.k) {
o(0);
}
}
}
int i = w.a.b;
if (j == null) {
return null;
}
return j.f1365c;
}
@Nullable
public w.a j() {
return k(q.b(this.f), "*");
}
@Nullable
public w.a k(String str, String str2) {
w.a b2;
w wVar = b;
String h = h();
synchronized (wVar) {
b2 = w.a.b(wVar.a.getString(wVar.b(h, str, str2), null));
}
return b2;
}
public final Task m(String str, String str2) throws Exception {
Task<o> task;
String e = e();
w.a k = k(str, str2);
if (!p(k)) {
return c.i.a.f.e.o.c.F(new p(e, k.f1365c));
}
u uVar = this.i;
synchronized (uVar) {
Pair<String, String> pair = new Pair<>(str, str2);
task = uVar.b.get(pair);
if (task == null) {
if (Log.isLoggable("FirebaseInstanceId", 3)) {
String valueOf = String.valueOf(pair);
StringBuilder sb = new StringBuilder(valueOf.length() + 24);
sb.append("Making new request for: ");
sb.append(valueOf);
Log.d("FirebaseInstanceId", sb.toString());
}
n nVar = this.h;
Objects.requireNonNull(nVar);
task = nVar.a(nVar.b(e, str, str2, new Bundle())).r(this.e, new l(this, str, str2, e)).j(uVar.a, new t(uVar, pair));
uVar.b.put(pair, task);
} else if (Log.isLoggable("FirebaseInstanceId", 3)) {
String valueOf2 = String.valueOf(pair);
StringBuilder sb2 = new StringBuilder(valueOf2.length() + 29);
sb2.append("Joining ongoing request for: ");
sb2.append(valueOf2);
Log.d("FirebaseInstanceId", sb2.toString());
}
}
return task;
}
public synchronized void n(boolean z2) {
this.k = z2;
}
public synchronized void o(long j) {
d(new x(this, Math.min(Math.max(30L, j << 1), a)), j);
this.k = true;
}
public boolean p(@Nullable w.a aVar) {
if (aVar != null) {
if (!(System.currentTimeMillis() > aVar.e + w.a.a || !this.g.a().equals(aVar.d))) {
return false;
}
}
return true;
}
}