package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ProviderInfo;
import android.os.IBinder;
import android.os.IInterface;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.android.gms.common.internal.Objects;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.util.PlatformVersion;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Ut, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0538Ut {
    public static final Jp0 b;
    public static final Lp0 c;
    public static Boolean e = null;
    public static String f = null;
    public static boolean g = false;
    public static int h = -1;
    public static Boolean i;
    public static Su0 m;
    public static Fv0 n;
    public final Context a;
    public static final ThreadLocal j = new ThreadLocal();
    public static final J5 k = new J5(4);
    public static final Jp0 l = new Jp0(4);
    public static final Jp0 d = new Jp0(29);

    static {
        int i2 = 28;
        b = new Jp0(i2);
        c = new Lp0(i2);
    }

    public C0538Ut(Context context) {
        Preconditions.checkNotNull(context);
        this.a = context;
    }

    public static int a(Context context, String str) {
        try {
            Class<?> clsLoadClass = context.getApplicationContext().getClassLoader().loadClass("com.google.android.gms.dynamite.descriptors." + str + ".ModuleDescriptor");
            Field declaredField = clsLoadClass.getDeclaredField("MODULE_ID");
            Field declaredField2 = clsLoadClass.getDeclaredField("MODULE_VERSION");
            if (Objects.equal(declaredField.get(null), str)) {
                return declaredField2.getInt(null);
            }
            String.valueOf(declaredField.get(null));
            return 0;
        } catch (ClassNotFoundException unused) {
            return 0;
        } catch (Exception e2) {
            "Failed to load module descriptor class: ".concat(String.valueOf(e2.getMessage()));
            return 0;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:131:0x01ed  */
    /* JADX WARN: Removed duplicated region for block: B:132:0x01f3  */
    /* JADX WARN: Removed duplicated region for block: B:135:0x01fc  */
    /* JADX WARN: Removed duplicated region for block: B:165:0x006d A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:18:0x005b A[Catch: all -> 0x024c, TRY_LEAVE, TryCatch #5 {all -> 0x024c, blocks: (B:7:0x0041, B:18:0x005b), top: B:163:0x0041 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static o.C0538Ut c(android.content.Context r22, o.InterfaceC0512Tt r23, java.lang.String r24) throws java.lang.Throwable {
        /*
            Method dump skipped, instructions count: 632
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0538Ut.c(android.content.Context, o.Tt, java.lang.String):o.Ut");
    }

    /* JADX WARN: Removed duplicated region for block: B:103:0x0155  */
    /* JADX WARN: Removed duplicated region for block: B:105:0x0158 A[Catch: all -> 0x00d5, TRY_ENTER, TryCatch #10 {all -> 0x00d5, blocks: (B:3:0x0002, B:63:0x00ca, B:65:0x00d0, B:73:0x00df, B:105:0x0158, B:114:0x016a, B:130:0x01c0, B:131:0x01c3, B:125:0x01b8, B:71:0x00db, B:133:0x01c5, B:4:0x0003, B:7:0x000a, B:8:0x0026, B:61:0x00c7, B:21:0x004a, B:44:0x00a1, B:47:0x00a4, B:54:0x00bc, B:62:0x00c9, B:60:0x00c2), top: B:144:0x0002, inners: #2, #4 }] */
    /* JADX WARN: Removed duplicated region for block: B:130:0x01c0 A[Catch: all -> 0x00d5, TryCatch #10 {all -> 0x00d5, blocks: (B:3:0x0002, B:63:0x00ca, B:65:0x00d0, B:73:0x00df, B:105:0x0158, B:114:0x016a, B:130:0x01c0, B:131:0x01c3, B:125:0x01b8, B:71:0x00db, B:133:0x01c5, B:4:0x0003, B:7:0x000a, B:8:0x0026, B:61:0x00c7, B:21:0x004a, B:44:0x00a1, B:47:0x00a4, B:54:0x00bc, B:62:0x00c9, B:60:0x00c2), top: B:144:0x0002, inners: #2, #4 }] */
    /* JADX WARN: Removed duplicated region for block: B:159:? A[Catch: all -> 0x00d5, SYNTHETIC, TRY_LEAVE, TryCatch #10 {all -> 0x00d5, blocks: (B:3:0x0002, B:63:0x00ca, B:65:0x00d0, B:73:0x00df, B:105:0x0158, B:114:0x016a, B:130:0x01c0, B:131:0x01c3, B:125:0x01b8, B:71:0x00db, B:133:0x01c5, B:4:0x0003, B:7:0x000a, B:8:0x0026, B:61:0x00c7, B:21:0x004a, B:44:0x00a1, B:47:0x00a4, B:54:0x00bc, B:62:0x00c9, B:60:0x00c2), top: B:144:0x0002, inners: #2, #4 }] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00b0 A[Catch: all -> 0x0037, TryCatch #11 {, blocks: (B:9:0x0027, B:11:0x0033, B:51:0x00b9, B:16:0x003c, B:18:0x0043, B:20:0x0049, B:25:0x0050, B:27:0x0054, B:30:0x005d, B:32:0x0065, B:35:0x006c, B:42:0x0098, B:43:0x00a0, B:38:0x0073, B:40:0x0079, B:41:0x008a, B:46:0x00a3, B:49:0x00a6, B:50:0x00b0, B:17:0x003f), top: B:145:0x0027, inners: #8 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static int d(android.content.Context r11, java.lang.String r12, boolean r13) {
        /*
            Method dump skipped, instructions count: 458
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0538Ut.d(android.content.Context, java.lang.String, boolean):int");
    }

    /* JADX WARN: Finally extract failed */
    /* JADX WARN: Removed duplicated region for block: B:125:0x00e4 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:86:0x0137 A[PHI: r13
      0x0137: PHI (r13v6 boolean) = (r13v5 boolean), (r13v9 boolean) binds: [B:59:0x00ee, B:84:0x0134] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static int e(android.content.Context r12, java.lang.String r13, boolean r14, boolean r15) throws java.lang.Throwable {
        /*
            Method dump skipped, instructions count: 395
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0538Ut.e(android.content.Context, java.lang.String, boolean, boolean):int");
    }

    public static void f(ClassLoader classLoader) throws C0434Qt {
        try {
            Fv0 fv0 = null;
            IBinder iBinder = (IBinder) classLoader.loadClass("com.google.android.gms.dynamiteloader.DynamiteLoaderV2").getConstructor(null).newInstance(null);
            if (iBinder != null) {
                IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoaderV2");
                fv0 = iInterfaceQueryLocalInterface instanceof Fv0 ? (Fv0) iInterfaceQueryLocalInterface : new Fv0(iBinder, "com.google.android.gms.dynamite.IDynamiteLoaderV2");
            }
            n = fv0;
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e2) {
            throw new C0434Qt("Failed to instantiate dynamite loader", e2);
        }
    }

    public static boolean g(Context context) {
        ApplicationInfo applicationInfo;
        Boolean bool = Boolean.TRUE;
        if (bool.equals(null) || bool.equals(i)) {
            return true;
        }
        boolean z = false;
        if (i == null) {
            ProviderInfo providerInfoResolveContentProvider = context.getPackageManager().resolveContentProvider("com.google.android.gms.chimera", true != PlatformVersion.isAtLeastQ() ? 0 : 268435456);
            if (GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context, 10000000) == 0 && providerInfoResolveContentProvider != null && "com.google.android.gms".equals(providerInfoResolveContentProvider.packageName)) {
                z = true;
            }
            i = Boolean.valueOf(z);
            if (z && (applicationInfo = providerInfoResolveContentProvider.applicationInfo) != null && (applicationInfo.flags & 129) == 0) {
                g = true;
            }
        }
        return z;
    }

    public static Su0 h(Context context) {
        Su0 su0;
        synchronized (C0538Ut.class) {
            Su0 su02 = m;
            if (su02 != null) {
                return su02;
            }
            try {
                IBinder iBinder = (IBinder) context.createPackageContext("com.google.android.gms", 3).getClassLoader().loadClass("com.google.android.gms.chimera.container.DynamiteLoaderImpl").newInstance();
                if (iBinder == null) {
                    su0 = null;
                } else {
                    IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoader");
                    su0 = iInterfaceQueryLocalInterface instanceof Su0 ? (Su0) iInterfaceQueryLocalInterface : new Su0(iBinder, "com.google.android.gms.dynamite.IDynamiteLoader");
                }
                if (su0 != null) {
                    m = su0;
                    return su0;
                }
            } catch (Exception e2) {
                e2.getMessage();
            }
            return null;
        }
    }

    public final IBinder b(String str) throws C0434Qt {
        try {
            return (IBinder) this.a.getClassLoader().loadClass(str).newInstance();
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e2) {
            throw new C0434Qt("Failed to instantiate module class: ".concat(str), e2);
        }
    }
}
