package com.google.firebase.analytics;

import X.8yY;
import X.8z1;
import X.8zJ;
import X.8zm;
import X.914;
import X.9AP;
import X.C0247R9n;
import X.C0249R9p;
import X.C0250R9q;
import X.C0264RAe;
import X.C0265RAf;
import X.QdW;
import X.R5O;
import X.R82;
import X.R95;
import X.RA5;
import X.RA6;
import X.RA7;
import X.RAA;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public final class FirebaseAnalytics {
    public static volatile FirebaseAnalytics zza;
    public final R95 zzb;
    public String zzc;
    public long zzd;
    public final Object zze = new Object();
    public ExecutorService zzf;

    static {
        Covode.recordClassIndex(45142);
    }

    public final void resetAnalyticsData() {
        zza((String) null);
        R95 r95 = this.zzb;
        r95.LIZ((C0249R9p) new RA6(r95));
    }

    private final ExecutorService zza() {
        ExecutorService executorService;
        MethodCollector.i(18219);
        synchronized (FirebaseAnalytics.class) {
            try {
                if (this.zzf == null) {
                    this.zzf = new QdW(TimeUnit.SECONDS, new ArrayBlockingQueue(100));
                }
                executorService = this.zzf;
            } finally {
                MethodCollector.o(18219);
            }
        }
        return executorService;
    }

    /* access modifiers changed from: private */
    public final String zzb() {
        MethodCollector.i(18222);
        synchronized (this.zze) {
            try {
                if (Math.abs(9AP.LIZ.LIZIZ() - this.zzd) < 1000) {
                    String str = this.zzc;
                    return str;
                }
                MethodCollector.o(18222);
                return null;
            } finally {
                MethodCollector.o(18222);
            }
        }
    }

    public final 8zJ<String> getAppInstanceId() {
        try {
            String zzb2 = zzb();
            if (zzb2 != null) {
                return 8z1.LIZ(zzb2);
            }
            return 8z1.LIZ(zza(), new C0247R9n(this));
        } catch (Exception e) {
            this.zzb.LIZ("Failed to schedule task for getAppInstanceId", (Object) null);
            return 8z1.LIZ(e);
        }
    }

    public final String getFirebaseInstanceId() {
        boolean z;
        try {
            8zm LIZLLL = 8zm.LIZLLL();
            if (LIZLLL != null) {
                z = true;
            } else {
                z = false;
            }
            914.LIZIZ(z, "Null is not a valid value of FirebaseApp.");
            return (String) 8z1.LIZ(((R5O) LIZLLL.LIZ(8yY.class)).LIZ(), 30000, TimeUnit.MILLISECONDS);
        } catch (ExecutionException e) {
            throw new IllegalStateException(e.getCause());
        } catch (TimeoutException unused) {
            throw new IllegalThreadStateException("Firebase Installations getId Task has timed out.");
        } catch (InterruptedException e2) {
            throw new IllegalStateException(e2);
        }
    }

    public FirebaseAnalytics(R95 r95) {
        914.LIZ(r95);
        this.zzb = r95;
    }

    public final void setAnalyticsCollectionEnabled(boolean z) {
        R95 r95 = this.zzb;
        r95.LIZ((C0249R9p) new RA7(r95, z));
    }

    public final void setMinimumSessionDuration(long j) {
        R95 r95 = this.zzb;
        r95.LIZ((C0249R9p) new C0265RAf(r95, j));
    }

    public final void setSessionTimeoutDuration(long j) {
        R95 r95 = this.zzb;
        r95.LIZ((C0249R9p) new C0264RAe(r95, j));
    }

    public final void setUserId(String str) {
        R95 r95 = this.zzb;
        r95.LIZ((C0249R9p) new RA5(r95, str));
    }

    /* access modifiers changed from: private */
    public final void zza(String str) {
        MethodCollector.i(18221);
        synchronized (this.zze) {
            try {
                this.zzc = str;
                this.zzd = 9AP.LIZ.LIZIZ();
            } finally {
                MethodCollector.o(18221);
            }
        }
    }

    public static FirebaseAnalytics getInstance(Context context) {
        MethodCollector.i(18164);
        if (zza == null) {
            synchronized (FirebaseAnalytics.class) {
                try {
                    if (zza == null) {
                        zza = new FirebaseAnalytics(R95.LIZ(context, (Bundle) null));
                    }
                } catch (Throwable th) {
                    MethodCollector.o(18164);
                    throw th;
                }
            }
        }
        FirebaseAnalytics firebaseAnalytics = zza;
        MethodCollector.o(18164);
        return firebaseAnalytics;
    }

    public final void logEvent(String str, Bundle bundle) {
        this.zzb.LIZ((String) null, str, bundle, false);
    }

    public final void setUserProperty(String str, String str2) {
        this.zzb.LIZ((String) null, str, (Object) str2, false);
    }

    public static R82 getScionFrontendApiImplementation(Context context, Bundle bundle) {
        R95 LIZ = R95.LIZ(context, bundle);
        if (LIZ == null) {
            return null;
        }
        return new RAA(LIZ);
    }

    public final void setCurrentScreen(Activity activity, String str, String str2) {
        R95 r95 = this.zzb;
        r95.LIZ((C0249R9p) new C0250R9q(r95, activity, str, str2));
    }
}
