package L1;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import java.lang.reflect.InvocationTargetException;
import y1.C1112b;

/* JADX INFO: renamed from: L1.g, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0098g extends A2.e {

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public Boolean f1806l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public String f1807m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public InterfaceC0095f f1808n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public Boolean f1809o;

    public final boolean l(String str) {
        return "1".equals(this.f1808n.c(str, "gaia_collection_enabled"));
    }

    public final boolean m(String str) {
        return "1".equals(this.f1808n.c(str, "measurement.event_sampling_enabled"));
    }

    public final boolean n() {
        if (this.f1806l == null) {
            Boolean boolW = w("app_measurement_lite");
            this.f1806l = boolW;
            if (boolW == null) {
                this.f1806l = Boolean.FALSE;
            }
        }
        return this.f1806l.booleanValue() || !((C0146w0) this.f29k).f2033l;
    }

    public final String o(String str) {
        C0146w0 c0146w0 = (C0146w0) this.f29k;
        try {
            String str2 = (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class, String.class).invoke(null, str, "");
            s1.z.g(str2);
            return str2;
        } catch (ClassNotFoundException e2) {
            X x5 = c0146w0.p;
            C0146w0.l(x5);
            x5.p.c("Could not find SystemProperties class", e2);
            return "";
        } catch (IllegalAccessException e6) {
            X x6 = c0146w0.p;
            C0146w0.l(x6);
            x6.p.c("Could not access SystemProperties.get()", e6);
            return "";
        } catch (NoSuchMethodException e7) {
            X x7 = c0146w0.p;
            C0146w0.l(x7);
            x7.p.c("Could not find SystemProperties.get() method", e7);
            return "";
        } catch (InvocationTargetException e8) {
            X x8 = c0146w0.p;
            C0146w0.l(x8);
            x8.p.c("SystemProperties.get() threw an exception", e8);
            return "";
        }
    }

    public final void p() {
        ((C0146w0) this.f29k).getClass();
    }

    public final String q(String str, E e2) {
        return TextUtils.isEmpty(str) ? (String) e2.a(null) : (String) e2.a(this.f1808n.c(str, e2.f1336a));
    }

    public final long r(String str, E e2) {
        if (TextUtils.isEmpty(str)) {
            return ((Long) e2.a(null)).longValue();
        }
        String strC = this.f1808n.c(str, e2.f1336a);
        if (TextUtils.isEmpty(strC)) {
            return ((Long) e2.a(null)).longValue();
        }
        try {
            return ((Long) e2.a(Long.valueOf(Long.parseLong(strC)))).longValue();
        } catch (NumberFormatException unused) {
            return ((Long) e2.a(null)).longValue();
        }
    }

    public final int s(String str, E e2) {
        if (TextUtils.isEmpty(str)) {
            return ((Integer) e2.a(null)).intValue();
        }
        String strC = this.f1808n.c(str, e2.f1336a);
        if (TextUtils.isEmpty(strC)) {
            return ((Integer) e2.a(null)).intValue();
        }
        try {
            return ((Integer) e2.a(Integer.valueOf(Integer.parseInt(strC)))).intValue();
        } catch (NumberFormatException unused) {
            return ((Integer) e2.a(null)).intValue();
        }
    }

    public final double t(String str, E e2) {
        if (TextUtils.isEmpty(str)) {
            return ((Double) e2.a(null)).doubleValue();
        }
        String strC = this.f1808n.c(str, e2.f1336a);
        if (TextUtils.isEmpty(strC)) {
            return ((Double) e2.a(null)).doubleValue();
        }
        try {
            return ((Double) e2.a(Double.valueOf(Double.parseDouble(strC)))).doubleValue();
        } catch (NumberFormatException unused) {
            return ((Double) e2.a(null)).doubleValue();
        }
    }

    public final boolean u(String str, E e2) {
        if (TextUtils.isEmpty(str)) {
            return ((Boolean) e2.a(null)).booleanValue();
        }
        String strC = this.f1808n.c(str, e2.f1336a);
        return TextUtils.isEmpty(strC) ? ((Boolean) e2.a(null)).booleanValue() : ((Boolean) e2.a(Boolean.valueOf("1".equals(strC)))).booleanValue();
    }

    public final Bundle v() {
        C0146w0 c0146w0 = (C0146w0) this.f29k;
        try {
            Context context = c0146w0.f2032k;
            Context context2 = c0146w0.f2032k;
            PackageManager packageManager = context.getPackageManager();
            X x5 = c0146w0.p;
            if (packageManager == null) {
                C0146w0.l(x5);
                x5.p.b("Failed to load metadata: PackageManager is null");
                return null;
            }
            ApplicationInfo applicationInfoD = C1112b.a(context2).d(128, context2.getPackageName());
            if (applicationInfoD != null) {
                return applicationInfoD.metaData;
            }
            C0146w0.l(x5);
            x5.p.b("Failed to load metadata: ApplicationInfo is null");
            return null;
        } catch (PackageManager.NameNotFoundException e2) {
            X x6 = c0146w0.p;
            C0146w0.l(x6);
            x6.p.c("Failed to load metadata: Package name not found", e2);
            return null;
        }
    }

    public final Boolean w(String str) {
        s1.z.d(str);
        Bundle bundleV = v();
        if (bundleV != null) {
            if (bundleV.containsKey(str)) {
                return Boolean.valueOf(bundleV.getBoolean(str));
            }
            return null;
        }
        X x5 = ((C0146w0) this.f29k).p;
        C0146w0.l(x5);
        x5.p.b("Failed to load metadata: Metadata bundle is null");
        return null;
    }

    public final boolean x() {
        ((C0146w0) this.f29k).getClass();
        Boolean boolW = w("firebase_analytics_collection_deactivated");
        return boolW != null && boolW.booleanValue();
    }

    public final boolean y() {
        Boolean boolW = w("google_analytics_automatic_screen_reporting_enabled");
        return boolW == null || boolW.booleanValue();
    }

    public final I0 z(String str, boolean z5) {
        Object obj;
        s1.z.d(str);
        Bundle bundleV = v();
        C0146w0 c0146w0 = (C0146w0) this.f29k;
        if (bundleV == null) {
            X x5 = c0146w0.p;
            C0146w0.l(x5);
            x5.p.b("Failed to load metadata: Metadata bundle is null");
            obj = null;
        } else {
            obj = bundleV.get(str);
        }
        I0 i02 = I0.UNINITIALIZED;
        if (obj == null) {
            return i02;
        }
        if (Boolean.TRUE.equals(obj)) {
            return I0.GRANTED;
        }
        if (Boolean.FALSE.equals(obj)) {
            return I0.DENIED;
        }
        if (z5 && "eu_consent_policy".equals(obj)) {
            return I0.POLICY;
        }
        X x6 = c0146w0.p;
        C0146w0.l(x6);
        x6.f1626s.c("Invalid manifest metadata for", str);
        return i02;
    }
}
