package d3;

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;

/* JADX INFO: renamed from: d3.g, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0784g extends O3.e {

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

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

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public InterfaceC0781f f11954t;

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

    public final boolean F() {
        ((C0817r0) this.f5146q).getClass();
        Boolean boolP = P("firebase_analytics_collection_deactivated");
        return boolP != null && boolP.booleanValue();
    }

    public final boolean G(String str) {
        return "1".equals(this.f11954t.k(str, "measurement.event_sampling_enabled"));
    }

    public final boolean H() {
        if (this.f11952r == null) {
            Boolean boolP = P("app_measurement_lite");
            this.f11952r = boolP;
            if (boolP == null) {
                this.f11952r = Boolean.FALSE;
            }
        }
        return this.f11952r.booleanValue() || !((C0817r0) this.f5146q).f12146u;
    }

    public final String I(String str) {
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        try {
            String str2 = (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class, String.class).invoke(null, str, "");
            P2.w.f(str2);
            return str2;
        } catch (ClassNotFoundException e8) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11875v.c(e8, "Could not find SystemProperties class");
            return "";
        } catch (IllegalAccessException e9) {
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.f11875v.c(e9, "Could not access SystemProperties.get()");
            return "";
        } catch (NoSuchMethodException e10) {
            Z z10 = c0817r0.f12150y;
            C0817r0.k(z10);
            z10.f11875v.c(e10, "Could not find SystemProperties.get() method");
            return "";
        } catch (InvocationTargetException e11) {
            Z z11 = c0817r0.f12150y;
            C0817r0.k(z11);
            z11.f11875v.c(e11, "SystemProperties.get() threw an exception");
            return "";
        }
    }

    public final double J(String str, H h8) {
        if (TextUtils.isEmpty(str)) {
            return ((Double) h8.a(null)).doubleValue();
        }
        String strK = this.f11954t.k(str, h8.f11475a);
        if (TextUtils.isEmpty(strK)) {
            return ((Double) h8.a(null)).doubleValue();
        }
        try {
            return ((Double) h8.a(Double.valueOf(Double.parseDouble(strK)))).doubleValue();
        } catch (NumberFormatException unused) {
            return ((Double) h8.a(null)).doubleValue();
        }
    }

    public final int K(String str, H h8) {
        if (TextUtils.isEmpty(str)) {
            return ((Integer) h8.a(null)).intValue();
        }
        String strK = this.f11954t.k(str, h8.f11475a);
        if (TextUtils.isEmpty(strK)) {
            return ((Integer) h8.a(null)).intValue();
        }
        try {
            return ((Integer) h8.a(Integer.valueOf(Integer.parseInt(strK)))).intValue();
        } catch (NumberFormatException unused) {
            return ((Integer) h8.a(null)).intValue();
        }
    }

    public final long L() {
        ((C0817r0) this.f5146q).getClass();
        return 119002L;
    }

    public final long M(String str, H h8) {
        if (TextUtils.isEmpty(str)) {
            return ((Long) h8.a(null)).longValue();
        }
        String strK = this.f11954t.k(str, h8.f11475a);
        if (TextUtils.isEmpty(strK)) {
            return ((Long) h8.a(null)).longValue();
        }
        try {
            return ((Long) h8.a(Long.valueOf(Long.parseLong(strK)))).longValue();
        } catch (NumberFormatException unused) {
            return ((Long) h8.a(null)).longValue();
        }
    }

    public final Bundle N() {
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        try {
            Context context = c0817r0.f12142q;
            PackageManager packageManager = context.getPackageManager();
            Z z8 = c0817r0.f12150y;
            if (packageManager == null) {
                C0817r0.k(z8);
                z8.f11875v.b("Failed to load metadata: PackageManager is null");
                return null;
            }
            I0.j jVarA = U2.b.a(context);
            ApplicationInfo applicationInfo = jVarA.f3229q.getPackageManager().getApplicationInfo(context.getPackageName(), 128);
            if (applicationInfo != null) {
                return applicationInfo.metaData;
            }
            C0817r0.k(z8);
            z8.f11875v.b("Failed to load metadata: ApplicationInfo is null");
            return null;
        } catch (PackageManager.NameNotFoundException e8) {
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.f11875v.c(e8, "Failed to load metadata: Package name not found");
            return null;
        }
    }

    public final C0 O(String str, boolean z8) {
        Object obj;
        P2.w.c(str);
        Bundle bundleN = N();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (bundleN == null) {
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.f11875v.b("Failed to load metadata: Metadata bundle is null");
            obj = null;
        } else {
            obj = bundleN.get(str);
        }
        C0 c02 = C0.f11431r;
        if (obj == null) {
            return c02;
        }
        if (Boolean.TRUE.equals(obj)) {
            return C0.f11434u;
        }
        if (Boolean.FALSE.equals(obj)) {
            return C0.f11433t;
        }
        if (z8 && "eu_consent_policy".equals(obj)) {
            return C0.f11432s;
        }
        Z z10 = c0817r0.f12150y;
        C0817r0.k(z10);
        z10.f11878y.c(str, "Invalid manifest metadata for");
        return c02;
    }

    public final Boolean P(String str) {
        P2.w.c(str);
        Bundle bundleN = N();
        if (bundleN != null) {
            if (bundleN.containsKey(str)) {
                return Boolean.valueOf(bundleN.getBoolean(str));
            }
            return null;
        }
        Z z8 = ((C0817r0) this.f5146q).f12150y;
        C0817r0.k(z8);
        z8.f11875v.b("Failed to load metadata: Metadata bundle is null");
        return null;
    }

    public final String Q(String str, H h8) {
        return TextUtils.isEmpty(str) ? (String) h8.a(null) : (String) h8.a(this.f11954t.k(str, h8.f11475a));
    }

    public final boolean R(String str, H h8) {
        if (TextUtils.isEmpty(str)) {
            return ((Boolean) h8.a(null)).booleanValue();
        }
        String strK = this.f11954t.k(str, h8.f11475a);
        return TextUtils.isEmpty(strK) ? ((Boolean) h8.a(null)).booleanValue() : ((Boolean) h8.a(Boolean.valueOf("1".equals(strK)))).booleanValue();
    }

    public final boolean S() {
        Boolean boolP = P("google_analytics_automatic_screen_reporting_enabled");
        return boolP == null || boolP.booleanValue();
    }
}
