package com.google.android.gms.measurement.internal; import android.app.Activity; import android.os.Bundle; import androidx.collection.ArrayMap; import com.google.android.gms.common.internal.Preconditions; import com.ubt.jimu.controller.data.widget.JockstickDataConverter; import com.unity3d.ads.metadata.MediationMetaData; import java.util.Map; /* loaded from: classes.dex */ public final class zzdy extends zzf { protected zzdx c; private volatile zzdx d; private zzdx e; private final Map f; private String g; public zzdy(zzbw zzbwVar) { super(zzbwVar); this.f = new ArrayMap(); } private final zzdx d(Activity activity) { Preconditions.a(activity); zzdx zzdxVar = this.f.get(activity); if (zzdxVar != null) { return zzdxVar; } zzdx zzdxVar2 = new zzdx(null, a(activity.getClass().getCanonicalName()), k().t()); this.f.put(activity, zzdxVar2); return zzdxVar2; } public final zzdx B() { w(); f(); return this.c; } public final zzdx C() { g(); return this.d; } public final void a(Activity activity, String str, String str2) { if (this.d == null) { e().w().a("setCurrentScreen cannot be called while no activity active"); return; } if (this.f.get(activity) == null) { e().w().a("setCurrentScreen must be called with an activity in the activity lifecycle"); return; } if (str2 == null) { str2 = a(activity.getClass().getCanonicalName()); } boolean equals = this.d.b.equals(str2); boolean e = zzfy.e(this.d.a, str); if (equals && e) { e().y().a("setCurrentScreen cannot be called with the same class and name"); return; } if (str != null && (str.length() <= 0 || str.length() > 100)) { e().w().a("Invalid screen name length in setCurrentScreen. Length", Integer.valueOf(str.length())); return; } if (str2 != null && (str2.length() <= 0 || str2.length() > 100)) { e().w().a("Invalid class name length in setCurrentScreen. Length", Integer.valueOf(str2.length())); return; } e().B().a("Setting current screen to name, class", str == null ? "null" : str, str2); zzdx zzdxVar = new zzdx(str, str2, k().t()); this.f.put(activity, zzdxVar); a(activity, zzdxVar, true); } public final void b(Activity activity) { zzdx d = d(activity); this.e = this.d; this.d = null; a().a(new zzea(this, d)); } public final void c(Activity activity) { a(activity, d(activity), false); zza o = o(); o.a().a(new zzd(o, o.d().b())); } @Override // com.google.android.gms.measurement.internal.zzf protected final boolean y() { return false; } public final void b(Activity activity, Bundle bundle) { zzdx zzdxVar; if (bundle == null || (zzdxVar = this.f.get(activity)) == null) { return; } Bundle bundle2 = new Bundle(); bundle2.putLong(JockstickDataConverter.ID, zzdxVar.c); bundle2.putString(MediationMetaData.KEY_NAME, zzdxVar.a); bundle2.putString("referrer_name", zzdxVar.b); bundle.putBundle("com.google.app_measurement.screen_service", bundle2); } private final void a(Activity activity, zzdx zzdxVar, boolean z) { zzdx zzdxVar2 = this.d == null ? this.e : this.d; if (zzdxVar.b == null) { zzdxVar = new zzdx(zzdxVar.a, a(activity.getClass().getCanonicalName()), zzdxVar.c); } this.e = this.d; this.d = zzdxVar; a().a(new zzdz(this, z, zzdxVar2, zzdxVar)); } /* JADX INFO: Access modifiers changed from: private */ public final void a(zzdx zzdxVar, boolean z) { o().a(d().b()); if (u().a(zzdxVar.d, z)) { zzdxVar.d = false; } } public static void a(zzdx zzdxVar, Bundle bundle, boolean z) { if (bundle != null && zzdxVar != null && (!bundle.containsKey("_sc") || z)) { String str = zzdxVar.a; if (str != null) { bundle.putString("_sn", str); } else { bundle.remove("_sn"); } bundle.putString("_sc", zzdxVar.b); bundle.putLong("_si", zzdxVar.c); return; } if (bundle != null && zzdxVar == null && z) { bundle.remove("_sn"); bundle.remove("_sc"); bundle.remove("_si"); } } public final void a(String str, zzdx zzdxVar) { f(); synchronized (this) { if (this.g == null || this.g.equals(str) || zzdxVar != null) { this.g = str; } } } private static String a(String str) { String[] split = str.split("\\."); String str2 = split.length > 0 ? split[split.length - 1] : ""; return str2.length() > 100 ? str2.substring(0, 100) : str2; } public final void a(Activity activity, Bundle bundle) { Bundle bundle2; if (bundle == null || (bundle2 = bundle.getBundle("com.google.app_measurement.screen_service")) == null) { return; } this.f.put(activity, new zzdx(bundle2.getString(MediationMetaData.KEY_NAME), bundle2.getString("referrer_name"), bundle2.getLong(JockstickDataConverter.ID))); } public final void a(Activity activity) { this.f.remove(activity); } }