package com.google.android.gms.internal.measurement;

import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/* JADX INFO: renamed from: com.google.android.gms.internal.measurement.l0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0662l0 {
    public static volatile C0662l0 i;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final String f9900a = "FA";

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final T2.a f9901b = T2.a.f6551a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ExecutorService f9902c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final P.g f9903d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final ArrayList f9904e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f9905f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f9906g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public volatile J f9907h;

    public C0662l0(Context context, Bundle bundle) {
        int i5 = 0;
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new ThreadFactoryC0637g0());
        threadPoolExecutor.allowCoreThreadTimeOut(true);
        this.f9902c = Executors.unconfigurableExecutorService(threadPoolExecutor);
        this.f9903d = new P.g(23, this);
        this.f9904e = new ArrayList();
        try {
            if (d3.G0.g(context, d3.G0.b(context)) != null) {
                try {
                    Class.forName("com.google.firebase.analytics.FirebaseAnalytics", false, C0662l0.class.getClassLoader());
                } catch (ClassNotFoundException unused) {
                    this.f9906g = true;
                    Log.w(this.f9900a, "Disabling data collection. Found google_app_id in strings.xml but Google Analytics for Firebase is missing. Remove this value or add Google Analytics for Firebase to resume data collection.");
                    return;
                }
            }
        } catch (IllegalStateException unused2) {
        }
        b(new C0607a0(this, context, bundle, i5));
        Application application = (Application) context.getApplicationContext();
        if (application == null) {
            Log.w(this.f9900a, "Unable to register lifecycle notifications. Application null.");
        } else {
            application.registerActivityLifecycleCallbacks(new C0657k0(this));
        }
    }

    public static C0662l0 d(Context context, Bundle bundle) {
        P2.w.f(context);
        if (i == null) {
            synchronized (C0662l0.class) {
                try {
                    if (i == null) {
                        i = new C0662l0(context, bundle);
                    }
                } finally {
                }
            }
        }
        return i;
    }

    public final void a(Exception exc, boolean z8, boolean z9) {
        this.f9906g |= z8;
        String str = this.f9900a;
        if (z8) {
            Log.w(str, "Data collection startup failed. No data will be collected.", exc);
            return;
        }
        if (z9) {
            b(new X(this, exc));
        }
        Log.w(str, "Error with data collection. Data lost.", exc);
    }

    public final void b(AbstractRunnableC0642h0 abstractRunnableC0642h0) {
        this.f9902c.execute(abstractRunnableC0642h0);
    }

    public final int c(String str) {
        G g8 = new G();
        b(new C0607a0(this, str, g8, 1));
        Integer num = (Integer) G.e(g8.d(10000L), Integer.class);
        if (num == null) {
            return 25;
        }
        return num.intValue();
    }

    public final List e(String str, String str2) {
        G g8 = new G();
        b(new Z(this, str, str2, g8));
        List list = (List) G.e(g8.d(5000L), List.class);
        return list == null ? Collections.EMPTY_LIST : list;
    }

    public final Map f(String str, String str2, boolean z8) {
        G g8 = new G();
        b(new C0632f0(this, str, str2, z8, g8));
        Bundle bundleD = g8.d(5000L);
        if (bundleD == null || bundleD.size() == 0) {
            return Collections.EMPTY_MAP;
        }
        HashMap map = new HashMap(bundleD.size());
        for (String str3 : bundleD.keySet()) {
            Object obj = bundleD.get(str3);
            if ((obj instanceof Double) || (obj instanceof Long) || (obj instanceof String)) {
                map.put(str3, obj);
            }
        }
        return map;
    }
}
