jimu-decompiled/sources/com/google/android/gms/measurement/internal/zzda.java
2025-05-13 19:24:51 +02:00

655 lines
24 KiB
Java

package com.google.android.gms.measurement.internal;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.collection.ArrayMap;
import com.google.android.gms.common.api.internal.GoogleServices;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.util.CollectionUtils;
import com.google.android.gms.measurement.AppMeasurement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes.dex */
public final class zzda extends zzf {
protected zzdu c;
private zzcx d;
private final Set<zzcy> e;
private boolean f;
private final AtomicReference<String> g;
protected boolean h;
protected zzda(zzbw zzbwVar) {
super(zzbwVar);
this.e = new CopyOnWriteArraySet();
this.h = true;
this.g = new AtomicReference<>();
}
/* JADX INFO: Access modifiers changed from: private */
public final void G() {
if (m().i(q().C()) && this.a.f() && this.h) {
e().A().a("Recording app launch after enabling measurement for the first time (FE)");
F();
} else {
e().A().a("Updating Scion state (FE)");
r().F();
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void c(boolean z) {
f();
g();
w();
e().A().a("Setting app measurement enabled (FE)", Boolean.valueOf(z));
l().a(z);
G();
}
/* JADX INFO: Access modifiers changed from: private */
public final void d(AppMeasurement.ConditionalUserProperty conditionalUserProperty) {
f();
w();
Preconditions.a(conditionalUserProperty);
Preconditions.b(conditionalUserProperty.mName);
Preconditions.b(conditionalUserProperty.mOrigin);
Preconditions.a(conditionalUserProperty.mValue);
if (!this.a.f()) {
e().A().a("Conditional property not sent since collection is disabled");
return;
}
zzfv zzfvVar = new zzfv(conditionalUserProperty.mName, conditionalUserProperty.mTriggeredTimestamp, conditionalUserProperty.mValue, conditionalUserProperty.mOrigin);
try {
zzag a = k().a(conditionalUserProperty.mAppId, conditionalUserProperty.mTriggeredEventName, conditionalUserProperty.mTriggeredEventParams, conditionalUserProperty.mOrigin, 0L, true, false);
r().a(new zzo(conditionalUserProperty.mAppId, conditionalUserProperty.mOrigin, zzfvVar, conditionalUserProperty.mCreationTimestamp, false, conditionalUserProperty.mTriggerEventName, k().a(conditionalUserProperty.mAppId, conditionalUserProperty.mTimedOutEventName, conditionalUserProperty.mTimedOutEventParams, conditionalUserProperty.mOrigin, 0L, true, false), conditionalUserProperty.mTriggerTimeout, a, conditionalUserProperty.mTimeToLive, k().a(conditionalUserProperty.mAppId, conditionalUserProperty.mExpiredEventName, conditionalUserProperty.mExpiredEventParams, conditionalUserProperty.mOrigin, 0L, true, false)));
} catch (IllegalArgumentException unused) {
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void e(AppMeasurement.ConditionalUserProperty conditionalUserProperty) {
f();
w();
Preconditions.a(conditionalUserProperty);
Preconditions.b(conditionalUserProperty.mName);
if (!this.a.f()) {
e().A().a("Conditional property not cleared since collection is disabled");
return;
}
try {
r().a(new zzo(conditionalUserProperty.mAppId, conditionalUserProperty.mOrigin, new zzfv(conditionalUserProperty.mName, 0L, null, null), conditionalUserProperty.mCreationTimestamp, conditionalUserProperty.mActive, conditionalUserProperty.mTriggerEventName, null, conditionalUserProperty.mTriggerTimeout, null, conditionalUserProperty.mTimeToLive, k().a(conditionalUserProperty.mAppId, conditionalUserProperty.mExpiredEventName, conditionalUserProperty.mExpiredEventParams, conditionalUserProperty.mOrigin, conditionalUserProperty.mCreationTimestamp, true, false)));
} catch (IllegalArgumentException unused) {
}
}
public final String B() {
zzdx C = this.a.n().C();
if (C != null) {
return C.b;
}
return null;
}
public final String C() {
zzdx C = this.a.n().C();
if (C != null) {
return C.a;
}
return null;
}
public final String D() {
if (this.a.A() != null) {
return this.a.A();
}
try {
return GoogleServices.a();
} catch (IllegalStateException e) {
this.a.e().t().a("getGoogleAppId failed with exception", e);
return null;
}
}
public final String E() {
g();
return this.g.get();
}
public final void F() {
f();
g();
w();
if (this.a.H()) {
r().E();
this.h = false;
String y = l().y();
if (TextUtils.isEmpty(y)) {
return;
}
i().o();
if (y.equals(Build.VERSION.RELEASE)) {
return;
}
Bundle bundle = new Bundle();
bundle.putString("_po", y);
b("auto", "_ou", bundle);
}
}
public final void a(boolean z) {
w();
g();
a().a(new zzdq(this, z));
}
public final void b(boolean z) {
w();
g();
a().a(new zzdr(this, z));
}
@Override // com.google.android.gms.measurement.internal.zzf
protected final boolean y() {
return false;
}
public final void a(String str, String str2, Bundle bundle, boolean z) {
a(str, str2, bundle, false, true, d().a());
}
public final void b(String str, String str2, Bundle bundle) {
a(str, str2, bundle, true, true, d().a());
}
private final void b(String str, String str2, long j, Bundle bundle, boolean z, boolean z2, boolean z3, String str3) {
a().a(new zzdc(this, str, str2, j, zzfy.b(bundle), z, z2, z3, str3));
}
final void a(String str, String str2, long j, Bundle bundle) {
g();
f();
a(str, str2, j, bundle, true, this.d == null || zzfy.h(str2), false, null);
}
final void c(String str, String str2, Bundle bundle) {
g();
f();
a(str, str2, d().a(), bundle);
}
public final void b(AppMeasurement.ConditionalUserProperty conditionalUserProperty) {
Preconditions.a(conditionalUserProperty);
Preconditions.b(conditionalUserProperty.mAppId);
n();
throw null;
}
/* JADX INFO: Access modifiers changed from: private */
public final void a(String str, String str2, long j, Bundle bundle, boolean z, boolean z2, boolean z3, String str3) {
zzdx zzdxVar;
int i;
Bundle bundle2;
ArrayList arrayList;
long j2;
String str4 = str2;
Preconditions.b(str);
if (!m().d(str3, zzai.q0)) {
Preconditions.b(str2);
}
Preconditions.a(bundle);
f();
w();
if (!this.a.f()) {
e().A().a("Event not sent since app measurement is disabled");
return;
}
if (!this.f) {
this.f = true;
try {
try {
Class.forName("com.google.android.gms.tagmanager.TagManagerService").getDeclaredMethod("initialize", Context.class).invoke(null, b());
} catch (Exception e) {
e().w().a("Failed to invoke Tag Manager's initialize() method", e);
}
} catch (ClassNotFoundException unused) {
e().z().a("Tag Manager is not found and thus will not be used");
}
}
if (z3) {
c();
if (!"_iap".equals(str4)) {
zzfy s = this.a.s();
int i2 = 2;
if (s.b("event", str4)) {
if (!s.a("event", zzcu.a, str4)) {
i2 = 13;
} else if (s.a("event", 40, str4)) {
i2 = 0;
}
}
if (i2 != 0) {
e().v().a("Invalid public event name. Event will not be logged (FE)", j().a(str4));
this.a.s();
this.a.s().a(i2, "_ev", zzfy.a(str4, 40, true), str4 != null ? str2.length() : 0);
return;
}
}
}
c();
zzdx B = s().B();
if (B != null && !bundle.containsKey("_sc")) {
B.d = true;
}
zzdy.a(B, bundle, z && z3);
boolean equals = "am".equals(str);
boolean h = zzfy.h(str2);
if (z && this.d != null && !h && !equals) {
e().A().a("Passing event to registered event handler (FE)", j().a(str4), j().a(bundle));
this.d.a(str, str2, bundle, j);
return;
}
if (this.a.H()) {
int a = k().a(str4);
if (a != 0) {
e().v().a("Invalid event name. Event will not be logged (FE)", j().a(str4));
k();
this.a.s().a(str3, a, "_ev", zzfy.a(str4, 40, true), str4 != null ? str2.length() : 0);
return;
}
List<String> a2 = CollectionUtils.a((Object[]) new String[]{"_o", "_sn", "_sc", "_si"});
String str5 = "_o";
Bundle a3 = k().a(str3, str2, bundle, a2, z3, true);
zzdx zzdxVar2 = (a3 != null && a3.containsKey("_sc") && a3.containsKey("_si")) ? new zzdx(a3.getString("_sn"), a3.getString("_sc"), Long.valueOf(a3.getLong("_si")).longValue()) : null;
if (zzdxVar2 != null) {
B = zzdxVar2;
}
if (m().s(str3)) {
c();
if (s().B() != null && "_ae".equals(str4)) {
long C = u().C();
if (C > 0) {
k().a(a3, C);
}
}
}
ArrayList arrayList2 = new ArrayList();
arrayList2.add(a3);
long nextLong = k().u().nextLong();
if (m().r(q().C()) && a3.getLong("extend_session", 0L) == 1) {
e().B().a("EXTEND_SESSION param attached: initiate a new session or extend the current active session");
this.a.p().a(j, true);
}
String[] strArr = (String[]) a3.keySet().toArray(new String[bundle.size()]);
Arrays.sort(strArr);
int length = strArr.length;
String str6 = "_ae";
int i3 = 0;
int i4 = 0;
while (i4 < length) {
int i5 = length;
String str7 = strArr[i4];
Object obj = a3.get(str7);
k();
String[] strArr2 = strArr;
Bundle[] a4 = zzfy.a(obj);
if (a4 != null) {
a3.putInt(str7, a4.length);
int i6 = i3;
int i7 = 0;
while (i7 < a4.length) {
Bundle bundle3 = a4[i7];
zzdy.a(B, bundle3, true);
int i8 = i6;
ArrayList arrayList3 = arrayList2;
long j3 = nextLong;
Bundle a5 = k().a(str3, "_ep", bundle3, a2, z3, false);
a5.putString("_en", str4);
a5.putLong("_eid", j3);
a5.putString("_gn", str7);
a5.putInt("_ll", a4.length);
a5.putInt("_i", i7);
arrayList3.add(a5);
i7++;
nextLong = j3;
a3 = a3;
arrayList2 = arrayList3;
i4 = i4;
B = B;
i6 = i8;
}
zzdxVar = B;
i = i4;
bundle2 = a3;
arrayList = arrayList2;
j2 = nextLong;
i3 = i6 + a4.length;
} else {
zzdxVar = B;
i = i4;
bundle2 = a3;
arrayList = arrayList2;
j2 = nextLong;
}
nextLong = j2;
a3 = bundle2;
arrayList2 = arrayList;
length = i5;
B = zzdxVar;
i4 = i + 1;
strArr = strArr2;
}
ArrayList arrayList4 = arrayList2;
int i9 = i3;
long j4 = nextLong;
Bundle bundle4 = a3;
if (i9 != 0) {
bundle4.putLong("_eid", j4);
bundle4.putInt("_epc", i9);
}
int i10 = 0;
while (i10 < arrayList4.size()) {
Bundle bundle5 = (Bundle) arrayList4.get(i10);
String str8 = i10 != 0 ? "_ep" : str4;
String str9 = str5;
bundle5.putString(str9, str);
if (z2) {
bundle5 = k().a(bundle5);
}
e().A().a("Logging event (FE)", j().a(str4), j().a(bundle5));
String str10 = str6;
String str11 = str4;
r().a(new zzag(str8, new zzad(bundle5), str, j), str3);
if (!equals) {
Iterator<zzcy> it = this.e.iterator();
while (it.hasNext()) {
it.next().a(str, str2, new Bundle(bundle5), j);
}
}
i10++;
str5 = str9;
str6 = str10;
str4 = str11;
}
String str12 = str6;
String str13 = str4;
c();
if (s().B() == null || !str12.equals(str13)) {
return;
}
u().a(true, true);
}
}
private final void c(AppMeasurement.ConditionalUserProperty conditionalUserProperty) {
long a = d().a();
Preconditions.a(conditionalUserProperty);
Preconditions.b(conditionalUserProperty.mName);
Preconditions.b(conditionalUserProperty.mOrigin);
Preconditions.a(conditionalUserProperty.mValue);
conditionalUserProperty.mCreationTimestamp = a;
String str = conditionalUserProperty.mName;
Object obj = conditionalUserProperty.mValue;
if (k().b(str) != 0) {
e().t().a("Invalid conditional user property name", j().c(str));
return;
}
if (k().b(str, obj) != 0) {
e().t().a("Invalid conditional user property value", j().c(str), obj);
return;
}
Object c = k().c(str, obj);
if (c == null) {
e().t().a("Unable to normalize conditional user property value", j().c(str), obj);
return;
}
conditionalUserProperty.mValue = c;
long j = conditionalUserProperty.mTriggerTimeout;
if (!TextUtils.isEmpty(conditionalUserProperty.mTriggerEventName) && (j > 15552000000L || j < 1)) {
e().t().a("Invalid conditional user property timeout", j().c(str), Long.valueOf(j));
return;
}
long j2 = conditionalUserProperty.mTimeToLive;
if (j2 <= 15552000000L && j2 >= 1) {
a().a(new zzdi(this, conditionalUserProperty));
} else {
e().t().a("Invalid conditional user property time to live", j().c(str), Long.valueOf(j2));
}
}
private final void b(String str, String str2, String str3, Bundle bundle) {
long a = d().a();
Preconditions.b(str2);
AppMeasurement.ConditionalUserProperty conditionalUserProperty = new AppMeasurement.ConditionalUserProperty();
conditionalUserProperty.mAppId = str;
conditionalUserProperty.mName = str2;
conditionalUserProperty.mCreationTimestamp = a;
if (str3 != null) {
conditionalUserProperty.mExpiredEventName = str3;
conditionalUserProperty.mExpiredEventParams = bundle;
}
a().a(new zzdj(this, conditionalUserProperty));
}
public final List<AppMeasurement.ConditionalUserProperty> b(String str, String str2) {
g();
return b((String) null, str, str2);
}
private final List<AppMeasurement.ConditionalUserProperty> b(String str, String str2, String str3) {
if (a().t()) {
e().t().a("Cannot get conditional user properties from analytics worker thread");
return Collections.emptyList();
}
if (zzn.a()) {
e().t().a("Cannot get conditional user properties from main thread");
return Collections.emptyList();
}
AtomicReference atomicReference = new AtomicReference();
synchronized (atomicReference) {
this.a.a().a(new zzdk(this, atomicReference, str, str2, str3));
try {
atomicReference.wait(5000L);
} catch (InterruptedException e) {
e().w().a("Interrupted waiting for get conditional user properties", str, e);
}
}
List<zzo> list = (List) atomicReference.get();
if (list == null) {
e().w().a("Timed out waiting for get conditional user properties", str);
return Collections.emptyList();
}
ArrayList arrayList = new ArrayList(list.size());
for (zzo zzoVar : list) {
AppMeasurement.ConditionalUserProperty conditionalUserProperty = new AppMeasurement.ConditionalUserProperty();
conditionalUserProperty.mAppId = zzoVar.packageName;
conditionalUserProperty.mOrigin = zzoVar.origin;
conditionalUserProperty.mCreationTimestamp = zzoVar.creationTimestamp;
zzfv zzfvVar = zzoVar.zzags;
conditionalUserProperty.mName = zzfvVar.name;
conditionalUserProperty.mValue = zzfvVar.getValue();
conditionalUserProperty.mActive = zzoVar.active;
conditionalUserProperty.mTriggerEventName = zzoVar.triggerEventName;
zzag zzagVar = zzoVar.zzagt;
if (zzagVar != null) {
conditionalUserProperty.mTimedOutEventName = zzagVar.name;
zzad zzadVar = zzagVar.zzahu;
if (zzadVar != null) {
conditionalUserProperty.mTimedOutEventParams = zzadVar.zziy();
}
}
conditionalUserProperty.mTriggerTimeout = zzoVar.triggerTimeout;
zzag zzagVar2 = zzoVar.zzagu;
if (zzagVar2 != null) {
conditionalUserProperty.mTriggeredEventName = zzagVar2.name;
zzad zzadVar2 = zzagVar2.zzahu;
if (zzadVar2 != null) {
conditionalUserProperty.mTriggeredEventParams = zzadVar2.zziy();
}
}
conditionalUserProperty.mTriggeredTimestamp = zzoVar.zzags.zzauk;
conditionalUserProperty.mTimeToLive = zzoVar.timeToLive;
zzag zzagVar3 = zzoVar.zzagv;
if (zzagVar3 != null) {
conditionalUserProperty.mExpiredEventName = zzagVar3.name;
zzad zzadVar3 = zzagVar3.zzahu;
if (zzadVar3 != null) {
conditionalUserProperty.mExpiredEventParams = zzadVar3.zziy();
}
}
arrayList.add(conditionalUserProperty);
}
return arrayList;
}
private final Map<String, Object> b(String str, String str2, String str3, boolean z) {
if (a().t()) {
e().t().a("Cannot get user properties from analytics worker thread");
return Collections.emptyMap();
}
if (zzn.a()) {
e().t().a("Cannot get user properties from main thread");
return Collections.emptyMap();
}
AtomicReference atomicReference = new AtomicReference();
synchronized (atomicReference) {
this.a.a().a(new zzdm(this, atomicReference, str, str2, str3, z));
try {
atomicReference.wait(5000L);
} catch (InterruptedException e) {
e().w().a("Interrupted waiting for get user properties", e);
}
}
List<zzfv> list = (List) atomicReference.get();
if (list == null) {
e().w().a("Timed out waiting for get user properties");
return Collections.emptyMap();
}
ArrayMap arrayMap = new ArrayMap(list.size());
for (zzfv zzfvVar : list) {
arrayMap.put(zzfvVar.name, zzfvVar.getValue());
}
return arrayMap;
}
public final void a(String str, String str2, Bundle bundle, boolean z, boolean z2, long j) {
g();
b(str == null ? "app" : str, str2, j, bundle == null ? new Bundle() : bundle, z2, !z2 || this.d == null || zzfy.h(str2), !z, null);
}
public final void a(String str, String str2, Object obj, boolean z) {
a(str, str2, obj, z, d().a());
}
public final void a(String str, String str2, Object obj, boolean z, long j) {
if (str == null) {
str = "app";
}
String str3 = str;
int i = 6;
if (z) {
i = k().b(str2);
} else {
zzfy k = k();
if (k.b("user property", str2)) {
if (!k.a("user property", zzcw.a, str2)) {
i = 15;
} else if (k.a("user property", 24, str2)) {
i = 0;
}
}
}
if (i != 0) {
k();
this.a.s().a(i, "_ev", zzfy.a(str2, 24, true), str2 != null ? str2.length() : 0);
return;
}
if (obj != null) {
int b = k().b(str2, obj);
if (b != 0) {
k();
this.a.s().a(b, "_ev", zzfy.a(str2, 24, true), ((obj instanceof String) || (obj instanceof CharSequence)) ? String.valueOf(obj).length() : 0);
return;
} else {
Object c = k().c(str2, obj);
if (c != null) {
a(str3, str2, j, c);
return;
}
return;
}
}
a(str3, str2, j, (Object) null);
}
private final void a(String str, String str2, long j, Object obj) {
a().a(new zzdd(this, str, str2, obj, j));
}
final void a(String str, String str2, Object obj, long j) {
Preconditions.b(str);
Preconditions.b(str2);
f();
g();
w();
if (!this.a.f()) {
e().A().a("User property not set since app measurement is disabled");
} else if (this.a.H()) {
e().A().a("Setting user property (FE)", j().a(str2), obj);
r().a(new zzfv(str2, j, obj, str));
}
}
final void a(String str) {
this.g.set(str);
}
public final void a(AppMeasurement.ConditionalUserProperty conditionalUserProperty) {
Preconditions.a(conditionalUserProperty);
g();
AppMeasurement.ConditionalUserProperty conditionalUserProperty2 = new AppMeasurement.ConditionalUserProperty(conditionalUserProperty);
if (!TextUtils.isEmpty(conditionalUserProperty2.mAppId)) {
e().w().a("Package name should be null when calling setConditionalUserProperty");
}
conditionalUserProperty2.mAppId = null;
c(conditionalUserProperty2);
}
public final void a(String str, String str2, Bundle bundle) {
g();
b((String) null, str, str2, bundle);
}
public final void a(String str, String str2, String str3, Bundle bundle) {
Preconditions.b(str);
n();
throw null;
}
public final List<AppMeasurement.ConditionalUserProperty> a(String str, String str2, String str3) {
Preconditions.b(str);
n();
throw null;
}
public final Map<String, Object> a(String str, String str2, boolean z) {
g();
return b((String) null, str, str2, z);
}
public final Map<String, Object> a(String str, String str2, String str3, boolean z) {
Preconditions.b(str);
n();
throw null;
}
}