package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.wrappers.Wrappers;
import java.lang.reflect.InvocationTargetException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.ho0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1421ho0 extends Eu0 {
    public Boolean b;
    public String c;
    public InterfaceC1133eo0 d;
    public Boolean e;

    public final int A(String str, C1805lq0 c1805lq0) {
        if (TextUtils.isEmpty(str)) {
            return ((Integer) c1805lq0.a(null)).intValue();
        }
        String strA = this.d.a(str, c1805lq0.a);
        if (TextUtils.isEmpty(strA)) {
            return ((Integer) c1805lq0.a(null)).intValue();
        }
        try {
            return ((Integer) c1805lq0.a(Integer.valueOf(Integer.parseInt(strA)))).intValue();
        } catch (NumberFormatException unused) {
            return ((Integer) c1805lq0.a(null)).intValue();
        }
    }

    public final double B(String str, C1805lq0 c1805lq0) {
        if (TextUtils.isEmpty(str)) {
            return ((Double) c1805lq0.a(null)).doubleValue();
        }
        String strA = this.d.a(str, c1805lq0.a);
        if (TextUtils.isEmpty(strA)) {
            return ((Double) c1805lq0.a(null)).doubleValue();
        }
        try {
            return ((Double) c1805lq0.a(Double.valueOf(Double.parseDouble(strA)))).doubleValue();
        } catch (NumberFormatException unused) {
            return ((Double) c1805lq0.a(null)).doubleValue();
        }
    }

    public final boolean C(String str, C1805lq0 c1805lq0) {
        if (TextUtils.isEmpty(str)) {
            return ((Boolean) c1805lq0.a(null)).booleanValue();
        }
        String strA = this.d.a(str, c1805lq0.a);
        return TextUtils.isEmpty(strA) ? ((Boolean) c1805lq0.a(null)).booleanValue() : ((Boolean) c1805lq0.a(Boolean.valueOf("1".equals(strA)))).booleanValue();
    }

    public final Bundle D() {
        Kr0 kr0 = (Kr0) this.a;
        try {
            Context context = kr0.a;
            Context context2 = kr0.a;
            Nq0 nq0 = kr0.f;
            if (context.getPackageManager() == null) {
                Kr0.l(nq0);
                nq0.f.b("Failed to load metadata: PackageManager is null");
                return null;
            }
            ApplicationInfo applicationInfo = Wrappers.packageManager(context2).getApplicationInfo(context2.getPackageName(), 128);
            if (applicationInfo != null) {
                return applicationInfo.metaData;
            }
            Kr0.l(nq0);
            nq0.f.b("Failed to load metadata: ApplicationInfo is null");
            return null;
        } catch (PackageManager.NameNotFoundException e) {
            Nq0 nq02 = kr0.f;
            Kr0.l(nq02);
            nq02.f.c(e, "Failed to load metadata: Package name not found");
            return null;
        }
    }

    public final Boolean E(String str) {
        Preconditions.checkNotEmpty(str);
        Bundle bundleD = D();
        if (bundleD != null) {
            if (bundleD.containsKey(str)) {
                return Boolean.valueOf(bundleD.getBoolean(str));
            }
            return null;
        }
        Nq0 nq0 = ((Kr0) this.a).f;
        Kr0.l(nq0);
        nq0.f.b("Failed to load metadata: Metadata bundle is null");
        return null;
    }

    public final boolean F() {
        ((Kr0) this.a).getClass();
        Boolean boolE = E("firebase_analytics_collection_deactivated");
        return boolE != null && boolE.booleanValue();
    }

    public final boolean G() {
        Boolean boolE = E("google_analytics_automatic_screen_reporting_enabled");
        return boolE == null || boolE.booleanValue();
    }

    public final EnumC1809ls0 H(String str, boolean z) {
        Object obj;
        Preconditions.checkNotEmpty(str);
        Kr0 kr0 = (Kr0) this.a;
        Bundle bundleD = D();
        if (bundleD == null) {
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.f.b("Failed to load metadata: Metadata bundle is null");
            obj = null;
        } else {
            obj = bundleD.get(str);
        }
        EnumC1809ls0 enumC1809ls0 = EnumC1809ls0.m;
        if (obj == null) {
            return enumC1809ls0;
        }
        if (Boolean.TRUE.equals(obj)) {
            return EnumC1809ls0.p;
        }
        if (Boolean.FALSE.equals(obj)) {
            return EnumC1809ls0.f627o;
        }
        if (z && "eu_consent_policy".equals(obj)) {
            return EnumC1809ls0.n;
        }
        Nq0 nq02 = kr0.f;
        Kr0.l(nq02);
        nq02.i.c(str, "Invalid manifest metadata for");
        return enumC1809ls0;
    }

    public final boolean t(String str) {
        return "1".equals(this.d.a(str, "gaia_collection_enabled"));
    }

    public final boolean u(String str) {
        return "1".equals(this.d.a(str, "measurement.event_sampling_enabled"));
    }

    public final boolean v() {
        if (this.b == null) {
            Boolean boolE = E("app_measurement_lite");
            this.b = boolE;
            if (boolE == null) {
                this.b = Boolean.FALSE;
            }
        }
        return this.b.booleanValue() || !((Kr0) this.a).b;
    }

    public final String w(String str) {
        Kr0 kr0 = (Kr0) this.a;
        try {
            String str2 = (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class, String.class).invoke(null, str, "");
            Preconditions.checkNotNull(str2);
            return str2;
        } catch (ClassNotFoundException e) {
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.f.c(e, "Could not find SystemProperties class");
            return "";
        } catch (IllegalAccessException e2) {
            Nq0 nq02 = kr0.f;
            Kr0.l(nq02);
            nq02.f.c(e2, "Could not access SystemProperties.get()");
            return "";
        } catch (NoSuchMethodException e3) {
            Nq0 nq03 = kr0.f;
            Kr0.l(nq03);
            nq03.f.c(e3, "Could not find SystemProperties.get() method");
            return "";
        } catch (InvocationTargetException e4) {
            Nq0 nq04 = kr0.f;
            Kr0.l(nq04);
            nq04.f.c(e4, "SystemProperties.get() threw an exception");
            return "";
        }
    }

    public final void x() {
        ((Kr0) this.a).getClass();
    }

    public final String y(String str, C1805lq0 c1805lq0) {
        return TextUtils.isEmpty(str) ? (String) c1805lq0.a(null) : (String) c1805lq0.a(this.d.a(str, c1805lq0.a));
    }

    public final long z(String str, C1805lq0 c1805lq0) {
        if (TextUtils.isEmpty(str)) {
            return ((Long) c1805lq0.a(null)).longValue();
        }
        String strA = this.d.a(str, c1805lq0.a);
        if (TextUtils.isEmpty(strA)) {
            return ((Long) c1805lq0.a(null)).longValue();
        }
        try {
            return ((Long) c1805lq0.a(Long.valueOf(Long.parseLong(strA)))).longValue();
        } catch (NumberFormatException unused) {
            return ((Long) c1805lq0.a(null)).longValue();
        }
    }
}
