- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
220 lines
7.5 KiB
Java
220 lines
7.5 KiB
Java
package com.google.android.gms.measurement.internal;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.Nullable;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.util.Clock;
|
|
import java.lang.Thread;
|
|
import java.util.concurrent.BlockingQueue;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
import java.util.concurrent.PriorityBlockingQueue;
|
|
import java.util.concurrent.Semaphore;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class zzhg extends zzim {
|
|
private static final AtomicLong zza = new AtomicLong(Long.MIN_VALUE);
|
|
|
|
@Nullable
|
|
private zzhk zzb;
|
|
|
|
@Nullable
|
|
private zzhk zzc;
|
|
private final PriorityBlockingQueue<zzhh<?>> zzd;
|
|
private final BlockingQueue<zzhh<?>> zze;
|
|
private final Thread.UncaughtExceptionHandler zzf;
|
|
private final Thread.UncaughtExceptionHandler zzg;
|
|
private final Object zzh;
|
|
private final Semaphore zzi;
|
|
private volatile boolean zzj;
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij, com.google.android.gms.measurement.internal.zzil
|
|
public final /* bridge */ /* synthetic */ Context zza() {
|
|
return super.zza();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzim
|
|
public final boolean zzo() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij, com.google.android.gms.measurement.internal.zzil
|
|
public final /* bridge */ /* synthetic */ Clock zzb() {
|
|
return super.zzb();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij, com.google.android.gms.measurement.internal.zzil
|
|
public final /* bridge */ /* synthetic */ zzad zzd() {
|
|
return super.zzd();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final /* bridge */ /* synthetic */ zzae zze() {
|
|
return super.zze();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final /* bridge */ /* synthetic */ zzaz zzf() {
|
|
return super.zzf();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final /* bridge */ /* synthetic */ zzfv zzi() {
|
|
return super.zzi();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij, com.google.android.gms.measurement.internal.zzil
|
|
public final /* bridge */ /* synthetic */ zzfw zzj() {
|
|
return super.zzj();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final /* bridge */ /* synthetic */ zzgl zzk() {
|
|
return super.zzk();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij, com.google.android.gms.measurement.internal.zzil
|
|
public final /* bridge */ /* synthetic */ zzhg zzl() {
|
|
return super.zzl();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final /* bridge */ /* synthetic */ zznt zzq() {
|
|
return super.zzq();
|
|
}
|
|
|
|
@Nullable
|
|
public final <T> T zza(AtomicReference<T> atomicReference, long j, String str, Runnable runnable) {
|
|
synchronized (atomicReference) {
|
|
zzl().zzb(runnable);
|
|
try {
|
|
atomicReference.wait(j);
|
|
} catch (InterruptedException unused) {
|
|
zzj().zzu().zza("Interrupted waiting for " + str);
|
|
return null;
|
|
}
|
|
}
|
|
T t = atomicReference.get();
|
|
if (t == null) {
|
|
zzj().zzu().zza("Timed out waiting for " + str);
|
|
}
|
|
return t;
|
|
}
|
|
|
|
public final <V> Future<V> zza(Callable<V> callable) throws IllegalStateException {
|
|
zzac();
|
|
Preconditions.checkNotNull(callable);
|
|
zzhh<?> zzhhVar = new zzhh<>(this, (Callable<?>) callable, false, "Task exception on worker thread");
|
|
if (Thread.currentThread() == this.zzb) {
|
|
if (!this.zzd.isEmpty()) {
|
|
zzj().zzu().zza("Callable skipped the worker queue.");
|
|
}
|
|
zzhhVar.run();
|
|
} else {
|
|
zza(zzhhVar);
|
|
}
|
|
return zzhhVar;
|
|
}
|
|
|
|
public final <V> Future<V> zzb(Callable<V> callable) throws IllegalStateException {
|
|
zzac();
|
|
Preconditions.checkNotNull(callable);
|
|
zzhh<?> zzhhVar = new zzhh<>(this, (Callable<?>) callable, true, "Task exception on worker thread");
|
|
if (Thread.currentThread() == this.zzb) {
|
|
zzhhVar.run();
|
|
} else {
|
|
zza(zzhhVar);
|
|
}
|
|
return zzhhVar;
|
|
}
|
|
|
|
public zzhg(zzhj zzhjVar) {
|
|
super(zzhjVar);
|
|
this.zzh = new Object();
|
|
this.zzi = new Semaphore(2);
|
|
this.zzd = new PriorityBlockingQueue<>();
|
|
this.zze = new LinkedBlockingQueue();
|
|
this.zzf = new zzhi(this, "Thread death: Uncaught exception on worker thread");
|
|
this.zzg = new zzhi(this, "Thread death: Uncaught exception on network thread");
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final void zzr() {
|
|
if (Thread.currentThread() != this.zzc) {
|
|
throw new IllegalStateException("Call expected from network thread");
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final /* bridge */ /* synthetic */ void zzs() {
|
|
super.zzs();
|
|
}
|
|
|
|
@Override // com.google.android.gms.measurement.internal.zzij
|
|
public final void zzt() {
|
|
if (Thread.currentThread() != this.zzb) {
|
|
throw new IllegalStateException("Call expected from worker thread");
|
|
}
|
|
}
|
|
|
|
private final void zza(zzhh<?> zzhhVar) {
|
|
synchronized (this.zzh) {
|
|
try {
|
|
this.zzd.add(zzhhVar);
|
|
zzhk zzhkVar = this.zzb;
|
|
if (zzhkVar == null) {
|
|
zzhk zzhkVar2 = new zzhk(this, "Measurement Worker", this.zzd);
|
|
this.zzb = zzhkVar2;
|
|
zzhkVar2.setUncaughtExceptionHandler(this.zzf);
|
|
this.zzb.start();
|
|
} else {
|
|
zzhkVar.zza();
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void zza(Runnable runnable) throws IllegalStateException {
|
|
zzac();
|
|
Preconditions.checkNotNull(runnable);
|
|
zzhh<?> zzhhVar = new zzhh<>(this, runnable, false, "Task exception on network thread");
|
|
synchronized (this.zzh) {
|
|
try {
|
|
this.zze.add(zzhhVar);
|
|
zzhk zzhkVar = this.zzc;
|
|
if (zzhkVar == null) {
|
|
zzhk zzhkVar2 = new zzhk(this, "Measurement Network", this.zze);
|
|
this.zzc = zzhkVar2;
|
|
zzhkVar2.setUncaughtExceptionHandler(this.zzg);
|
|
this.zzc.start();
|
|
} else {
|
|
zzhkVar.zza();
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void zzb(Runnable runnable) throws IllegalStateException {
|
|
zzac();
|
|
Preconditions.checkNotNull(runnable);
|
|
zza(new zzhh<>(this, runnable, false, "Task exception on worker thread"));
|
|
}
|
|
|
|
public final void zzc(Runnable runnable) throws IllegalStateException {
|
|
zzac();
|
|
Preconditions.checkNotNull(runnable);
|
|
zza(new zzhh<>(this, runnable, true, "Task exception on worker thread"));
|
|
}
|
|
|
|
public final boolean zzg() {
|
|
return Thread.currentThread() == this.zzb;
|
|
}
|
|
}
|