what-the-bank/sources/com/google/firebase/messaging/zzab.java

214 lines
8.2 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.messaging;
import android.content.Context;
import android.util.Log;
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.FirebaseApp;
import com.google.firebase.heartbeatinfo.HeartBeatInfo;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.google.firebase.iid.zzao;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.platforminfo.UserAgentPublisher;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import o.nyh;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class zzab {
private static final long zza = TimeUnit.HOURS.toSeconds(8);
private final FirebaseInstanceId zzb;
private final Context zzc;
private final zzao zzd;
private final com.google.firebase.iid.zzt zze;
private final ScheduledExecutorService zzg;
private final zzy zzi;
private final Map<String, ArrayDeque<TaskCompletionSource<Void>>> zzf = new nyh();
private boolean zzh = false;
/* JADX INFO: Access modifiers changed from: package-private */
public static Task<zzab> zza(FirebaseApp firebaseApp, final FirebaseInstanceId firebaseInstanceId, final zzao zzaoVar, UserAgentPublisher userAgentPublisher, HeartBeatInfo heartBeatInfo, FirebaseInstallationsApi firebaseInstallationsApi, final Context context, Executor executor, final ScheduledExecutorService scheduledExecutorService) {
final com.google.firebase.iid.zzt zztVar = new com.google.firebase.iid.zzt(firebaseApp, zzaoVar, executor, userAgentPublisher, heartBeatInfo, firebaseInstallationsApi);
return Tasks.call(scheduledExecutorService, new Callable(context, scheduledExecutorService, firebaseInstanceId, zzaoVar, zztVar) { // from class: com.google.firebase.messaging.zzaa
private final Context zza;
private final ScheduledExecutorService zzb;
private final FirebaseInstanceId zzc;
private final zzao zzd;
private final com.google.firebase.iid.zzt zze;
@Override // java.util.concurrent.Callable
public final Object call() {
return zzab.zza(this.zza, this.zzb, this.zzc, this.zzd, this.zze);
}
/* JADX INFO: Access modifiers changed from: package-private */
{
this.zza = context;
this.zzb = scheduledExecutorService;
this.zzc = firebaseInstanceId;
this.zzd = zzaoVar;
this.zze = zztVar;
}
});
}
private zzab(FirebaseInstanceId firebaseInstanceId, zzao zzaoVar, zzy zzyVar, com.google.firebase.iid.zzt zztVar, Context context, ScheduledExecutorService scheduledExecutorService) {
this.zzb = firebaseInstanceId;
this.zzd = zzaoVar;
this.zzi = zzyVar;
this.zze = zztVar;
this.zzc = context;
this.zzg = scheduledExecutorService;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void zza() {
if (this.zzi.zza() == null || zzc()) {
return;
}
zza(0L);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void zza(long j) {
zza(new zzad(this, this.zzc, this.zzd, Math.min(Math.max(30L, j << 1), zza)), j);
zza(true);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void zza(Runnable runnable, long j) {
this.zzg.schedule(runnable, j, TimeUnit.SECONDS);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final boolean zzb() throws IOException {
while (true) {
synchronized (this) {
zzz zza2 = this.zzi.zza();
if (zza2 == null) {
zzd();
return true;
}
if (!zzb(zza2)) {
return false;
}
this.zzi.zzb(zza2);
synchronized (this.zzf) {
String zzc = zza2.zzc();
if (this.zzf.containsKey(zzc)) {
ArrayDeque<TaskCompletionSource<Void>> arrayDeque = this.zzf.get(zzc);
TaskCompletionSource<Void> poll = arrayDeque.poll();
if (poll != null) {
poll.setResult(null);
}
if (arrayDeque.isEmpty()) {
this.zzf.remove(zzc);
}
}
}
}
}
}
private final boolean zzb(zzz zzzVar) throws IOException {
char c;
try {
String zzb = zzzVar.zzb();
int hashCode = zzb.hashCode();
if (hashCode != 83) {
if (hashCode == 85 && zzb.equals("U")) {
c = 1;
}
c = 65535;
} else {
if (zzb.equals("S")) {
c = 0;
}
c = 65535;
}
if (c == 0) {
String zza2 = zzzVar.zza();
InstanceIdResult instanceIdResult = (InstanceIdResult) zza(this.zzb.getInstanceId());
zza(this.zze.zzc(instanceIdResult.getId(), instanceIdResult.getToken(), zza2));
if (zzd()) {
zzzVar.zza();
}
} else if (c == 1) {
String zza3 = zzzVar.zza();
InstanceIdResult instanceIdResult2 = (InstanceIdResult) zza(this.zzb.getInstanceId());
zza(this.zze.zzd(instanceIdResult2.getId(), instanceIdResult2.getToken(), zza3));
if (zzd()) {
zzzVar.zza();
}
} else {
zzd();
}
return true;
} catch (IOException e) {
if ("SERVICE_NOT_AVAILABLE".equals(e.getMessage()) || "INTERNAL_SERVER_ERROR".equals(e.getMessage())) {
e.getMessage();
return false;
}
if (e.getMessage() == null) {
return false;
}
throw e;
}
}
private static <T> T zza(Task<T> task) throws IOException {
try {
return (T) Tasks.await(task, 30L, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e = e;
throw new IOException("SERVICE_NOT_AVAILABLE", e);
} catch (ExecutionException e2) {
Throwable cause = e2.getCause();
if (cause instanceof IOException) {
throw ((IOException) cause);
}
if (cause instanceof RuntimeException) {
throw ((RuntimeException) cause);
}
throw new IOException(e2);
} catch (TimeoutException e3) {
e = e3;
throw new IOException("SERVICE_NOT_AVAILABLE", e);
}
}
private final boolean zzc() {
boolean z;
synchronized (this) {
z = this.zzh;
}
return z;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void zza(boolean z) {
synchronized (this) {
this.zzh = z;
}
}
private static boolean zzd() {
return Log.isLoggable("FirebaseMessaging", 3);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static final /* synthetic */ zzab zza(Context context, ScheduledExecutorService scheduledExecutorService, FirebaseInstanceId firebaseInstanceId, zzao zzaoVar, com.google.firebase.iid.zzt zztVar) throws Exception {
return new zzab(firebaseInstanceId, zzaoVar, zzy.zza(context, scheduledExecutorService), zztVar, context, scheduledExecutorService);
}
}