138 lines
5.1 KiB
Java
138 lines
5.1 KiB
Java
package com.google.android.gms.internal.firebase_ml;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.os.SystemClock;
|
|
import com.google.android.gms.clearcut.ClearcutLogger;
|
|
import com.google.android.gms.common.internal.GmsLogger;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.internal.firebase_ml.zzmd;
|
|
import com.google.firebase.FirebaseApp;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.TimeUnit;
|
|
import o.Plu;
|
|
import o.bBI;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class zznu {
|
|
private static List<String> zzapn;
|
|
private final FirebaseApp zzapo;
|
|
private final String zzapp;
|
|
private final String zzapq;
|
|
private final String zzapr;
|
|
private final String zzaps;
|
|
private final String zzapt;
|
|
private final ClearcutLogger zzapu;
|
|
private final Map<zzmn, Long> zzapv = new HashMap();
|
|
private final int zzapw;
|
|
private static final GmsLogger zzaoz = new GmsLogger("MlStatsLogger", "");
|
|
private static final Map<String, zznu> zzax = new HashMap();
|
|
|
|
private zznu(FirebaseApp firebaseApp, int i) {
|
|
this.zzapo = firebaseApp;
|
|
this.zzapw = i;
|
|
String projectId = firebaseApp.getOptions().getProjectId();
|
|
this.zzapr = projectId == null ? "" : projectId;
|
|
String gcmSenderId = firebaseApp.getOptions().getGcmSenderId();
|
|
this.zzaps = gcmSenderId == null ? "" : gcmSenderId;
|
|
String apiKey = firebaseApp.getOptions().getApiKey();
|
|
this.zzapt = apiKey != null ? apiKey : "";
|
|
Context applicationContext = firebaseApp.getApplicationContext();
|
|
this.zzapu = ClearcutLogger.anonymousLogger(applicationContext, "FIREBASE_ML_SDK");
|
|
this.zzapp = applicationContext.getPackageName();
|
|
this.zzapq = zznk.zza(applicationContext);
|
|
}
|
|
|
|
public static zznu zza(FirebaseApp firebaseApp, int i) {
|
|
zznu zznuVar;
|
|
synchronized (zznu.class) {
|
|
Preconditions.checkNotNull(firebaseApp);
|
|
String str = "";
|
|
if (i == 1) {
|
|
str = "_vision";
|
|
} else if (i == 2) {
|
|
str = "_model";
|
|
} else if (i == 3) {
|
|
str = "_natural_language";
|
|
} else if (i == 4) {
|
|
str = "_model_download";
|
|
}
|
|
String valueOf = String.valueOf(firebaseApp.getPersistenceKey());
|
|
String concat = str.length() != 0 ? valueOf.concat(str) : new String(valueOf);
|
|
Map<String, zznu> map = zzax;
|
|
zznuVar = map.get(concat);
|
|
if (zznuVar == null) {
|
|
zznuVar = new zznu(firebaseApp, i);
|
|
map.put(concat, zznuVar);
|
|
}
|
|
}
|
|
return zznuVar;
|
|
}
|
|
|
|
public final void zza(zzmd.zzq.zza zzaVar, zzmn zzmnVar) {
|
|
synchronized (this) {
|
|
if (!zzfd()) {
|
|
zzaoz.d("MlStatsLogger", "Logging is disabled.");
|
|
return;
|
|
}
|
|
String zzlh = zzaVar.zzjw().zzlh();
|
|
if ("NA".equals(zzlh) || "".equals(zzlh)) {
|
|
zzlh = "NA";
|
|
}
|
|
zzaVar.zzb(zzmnVar).zzb(zzmd.zzac.zzli().zzbq(this.zzapp).zzbr(this.zzapq).zzbs(this.zzapr).zzbv(this.zzaps).zzbw(this.zzapt).zzbu(zzlh).zzn(zzlo()).zzbt(zznl.zzll().getVersion("firebase-ml-common")));
|
|
zzmd.zzq zzqVar = (zzmd.zzq) ((zzue) zzaVar.zzrj());
|
|
GmsLogger gmsLogger = zzaoz;
|
|
String valueOf = String.valueOf(zzqVar);
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 30);
|
|
sb.append("Logging FirebaseMlSdkLogEvent ");
|
|
sb.append(valueOf);
|
|
gmsLogger.d("MlStatsLogger", sb.toString());
|
|
this.zzapu.newEvent(zzqVar.toByteArray()).log();
|
|
}
|
|
}
|
|
|
|
public final void zza(zznv zznvVar, zzmn zzmnVar) {
|
|
synchronized (this) {
|
|
if (zzfd()) {
|
|
long elapsedRealtime = SystemClock.elapsedRealtime();
|
|
if (this.zzapv.get(zzmnVar) != null) {
|
|
if (elapsedRealtime - this.zzapv.get(zzmnVar).longValue() <= TimeUnit.SECONDS.toMillis(30L)) {
|
|
return;
|
|
}
|
|
}
|
|
this.zzapv.put(zzmnVar, Long.valueOf(elapsedRealtime));
|
|
zza(zznvVar.zzm(), zzmnVar);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static List<String> zzlo() {
|
|
synchronized (zznu.class) {
|
|
List<String> list = zzapn;
|
|
if (list != null) {
|
|
return list;
|
|
}
|
|
Plu qs_ = bBI.qs_(Resources.getSystem().getConfiguration());
|
|
zzapn = new ArrayList(qs_.b());
|
|
for (int i = 0; i < qs_.b(); i++) {
|
|
zzapn.add(zznk.zza(qs_.c(i)));
|
|
}
|
|
return zzapn;
|
|
}
|
|
}
|
|
|
|
private final boolean zzfd() {
|
|
int i = this.zzapw;
|
|
if (i == 1) {
|
|
return zzoa.zzc(this.zzapo);
|
|
}
|
|
if (i != 2) {
|
|
return i == 3 || i == 4;
|
|
}
|
|
return zzoa.zzd(this.zzapo);
|
|
}
|
|
}
|