package com.google.android.gms.analytics; import android.app.Activity; import android.app.Application; import android.content.Context; import android.os.Bundle; import com.google.android.gms.internal.gtm.zzap; import com.google.android.gms.internal.gtm.zzby; import com.google.android.gms.internal.gtm.zzch; import com.google.android.gms.internal.gtm.zzcw; import com.google.android.gms.internal.gtm.zzcy; import com.google.android.gms.internal.gtm.zzda; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; /* loaded from: classes.dex */ public final class GoogleAnalytics extends com.google.android.gms.analytics.zza { private static List zzrp = new ArrayList(); private boolean zzrq; private Set zzrr; private boolean zzrs; private boolean zzrt; private volatile boolean zzru; private boolean zzrv; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public interface zza { void zzc(Activity activity); void zzd(Activity activity); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class zzb implements Application.ActivityLifecycleCallbacks { private final GoogleAnalytics zzrw; zzb(GoogleAnalytics googleAnalytics) { this.zzrw = googleAnalytics; } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityCreated(Activity activity, Bundle bundle) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityDestroyed(Activity activity) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityPaused(Activity activity) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityResumed(Activity activity) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityStarted(Activity activity) { this.zzrw.zza(activity); } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityStopped(Activity activity) { this.zzrw.zzb(activity); } } public final void zzag() { zzda zzcu = zzab().zzcu(); zzcu.zzgh(); if (zzcu.zzgi()) { setDryRun(zzcu.zzgj()); } zzcu.zzgh(); this.zzrq = true; } public GoogleAnalytics(zzap zzapVar) { super(zzapVar); this.zzrr = new HashSet(); } public static GoogleAnalytics getInstance(Context context) { return zzap.zzc(context).zzde(); } public static void zzah() { synchronized (GoogleAnalytics.class) { List list = zzrp; if (list != null) { Iterator it = list.iterator(); while (it.hasNext()) { it.next().run(); } zzrp = null; } } } public final void enableAutoActivityReports(Application application) { if (this.zzrs) { return; } application.registerActivityLifecycleCallbacks(new zzb(this)); this.zzrs = true; } public final void reportActivityStart(Activity activity) { if (this.zzrs) { return; } zza(activity); } final void zza(Activity activity) { Iterator it = this.zzrr.iterator(); while (it.hasNext()) { it.next().zzc(activity); } } public final void reportActivityStop(Activity activity) { if (this.zzrs) { return; } zzb(activity); } final void zzb(Activity activity) { Iterator it = this.zzrr.iterator(); while (it.hasNext()) { it.next().zzd(activity); } } public final Tracker newTracker(String str) { Tracker tracker; synchronized (this) { tracker = new Tracker(zzab(), str, null); tracker.zzag(); } return tracker; } public final Tracker newTracker(int i) { Tracker tracker; zzcy zzq; synchronized (this) { tracker = new Tracker(zzab(), null, null); if (i > 0 && (zzq = new zzcw(zzab()).zzq(i)) != null) { tracker.zza(zzq); } tracker.zzag(); } return tracker; } /* JADX INFO: Access modifiers changed from: package-private */ public final void zza(zza zzaVar) { this.zzrr.add(zzaVar); Context context = zzab().getContext(); if (context instanceof Application) { enableAutoActivityReports((Application) context); } } /* JADX INFO: Access modifiers changed from: package-private */ public final void zzb(zza zzaVar) { this.zzrr.remove(zzaVar); } public final void setAppOptOut(boolean z) { this.zzru = z; if (this.zzru) { zzab().zzcs().zzch(); } } @Deprecated public final Logger getLogger() { return zzch.getLogger(); } @Deprecated public final void setLogger(Logger logger) { zzch.setLogger(logger); if (this.zzrv) { return; } zzby.zzzb.get(); zzby.zzzb.get(); this.zzrv = true; } public final void setLocalDispatchPeriod(int i) { zzab().zzcs().setLocalDispatchPeriod(i); } public final void dispatchLocalHits() { zzab().zzcs().zzci(); } public final void setDryRun(boolean z) { this.zzrt = z; } public final boolean isInitialized() { return this.zzrq; } public final boolean isDryRunEnabled() { return this.zzrt; } public final boolean getAppOptOut() { return this.zzru; } }