package defpackage;

import android.content.ContentProviderClient;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.SystemClock;
import com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader;
import com.google.android.gms.dynamite.DynamiteModule$LoadingException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/* JADX INFO: renamed from: ˁˏˑ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0705 {

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public static int f3219 = -1;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public static C1750 f3220;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static final C3952 f3221;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public static C5137 f3222;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static Boolean f3223;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public static boolean f3226;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static final C1470 f3228;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public static Boolean f3229;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public static String f3230;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final Context f3231;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public static final ThreadLocal f3225 = new ThreadLocal();

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public static final C0140 f3227 = new C0140(12);

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public static final C3826 f3224 = new C3826(4);

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static final C3826 f3218 = new C3826(8);

    static {
        int i = 8;
        f3221 = new C3952(i);
        f3228 = new C1470(i);
    }

    public C0705(Context context) {
        this.f3231 = context;
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public static C5137 m2549(Context context) {
        C5137 c5137;
        synchronized (C0705.class) {
            C5137 c51372 = f3222;
            if (c51372 != null) {
                return c51372;
            }
            try {
                IBinder iBinder = (IBinder) context.createPackageContext("com.google.android.gms", 3).getClassLoader().loadClass("com.google.android.gms.chimera.container.DynamiteLoaderImpl").newInstance();
                if (iBinder == null) {
                    c5137 = null;
                } else {
                    IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoader");
                    c5137 = iInterfaceQueryLocalInterface instanceof C5137 ? (C5137) iInterfaceQueryLocalInterface : new C5137(iBinder, "com.google.android.gms.dynamite.IDynamiteLoader", 1);
                }
                if (c5137 != null) {
                    f3222 = c5137;
                    return c5137;
                }
            } catch (Exception e) {
                new StringBuilder(String.valueOf(e.getMessage()).length() + 45);
            }
            return null;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0095 A[Catch: all -> 0x0089, TRY_LEAVE, TryCatch #4 {all -> 0x0089, blocks: (B:7:0x003a, B:11:0x0082, B:18:0x008e, B:22:0x0095, B:34:0x00b8, B:111:0x01f8, B:112:0x01ff, B:115:0x0202, B:116:0x0203, B:117:0x020a, B:134:0x0260, B:135:0x027e, B:118:0x020b, B:120:0x0222, B:122:0x0232, B:132:0x0258, B:133:0x025f, B:136:0x027f, B:137:0x02c6), top: B:156:0x003a, inners: #2 }] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00b5  */
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C0705 m2550(Context context, InterfaceC4602 interfaceC4602, String str) throws Throwable {
        long j;
        C0705 c0705;
        int i;
        Boolean bool;
        InterfaceC4754 interfaceC4754M10646;
        C1750 c1750;
        boolean z;
        Context applicationContext = context.getApplicationContext();
        if (applicationContext == null) {
            throw new DynamiteModule$LoadingException("null application Context");
        }
        ThreadLocal threadLocal = f3225;
        C2678 c2678 = (C2678) threadLocal.get();
        C2678 c26782 = new C2678();
        threadLocal.set(c26782);
        C0140 c0140 = f3227;
        Long l = (Long) c0140.get();
        long jLongValue = l.longValue();
        try {
            j = jLongValue;
        } catch (Throwable th) {
            th = th;
            j = jLongValue;
        }
        try {
            c0140.set(Long.valueOf(SystemClock.uptimeMillis()));
            C5151 c5151Mo4210 = interfaceC4602.mo4210(context, str, f3224);
            new StringBuilder(str.length() + 26 + String.valueOf(c5151Mo4210.f19366).length() + 19 + str.length() + 1 + String.valueOf(c5151Mo4210.f19364).length());
            int i2 = c5151Mo4210.f19365;
            if (i2 != 0) {
                if (i2 != -1) {
                    if (i2 == 1 || c5151Mo4210.f19364 != 0) {
                        if (i2 != -1) {
                            "Selected local version of ".concat(str);
                            C0705 c07052 = new C0705(applicationContext);
                            if (j == 0) {
                                c0140.remove();
                            } else {
                                c0140.set(l);
                            }
                            Cursor cursor = c26782.f10342;
                            if (cursor != null) {
                                cursor.close();
                            }
                            threadLocal.set(c2678);
                            return c07052;
                        }
                        if (i2 != 1) {
                            StringBuilder sb = new StringBuilder(String.valueOf(i2).length() + 36);
                            sb.append("VersionPolicy returned invalid code:");
                            sb.append(i2);
                            throw new DynamiteModule$LoadingException(sb.toString());
                        }
                        try {
                            i = c5151Mo4210.f19364;
                        } catch (DynamiteModule$LoadingException e) {
                            new StringBuilder(String.valueOf(e.getMessage()).length() + 30);
                            int i3 = c5151Mo4210.f19366;
                            if (i3 == 0 || interfaceC4602.mo4210(context, str, new ᵾːʿ(i3, 14)).f19365 != -1) {
                                throw new DynamiteModule$LoadingException("Remote load failed. No local fallback found.", e);
                            }
                            "Selected local version of ".concat(str);
                            c0705 = new C0705(applicationContext);
                        }
                        try {
                            synchronized (C0705.class) {
                                if (!m2551(context)) {
                                    throw new DynamiteModule$LoadingException("Remote loading disabled");
                                }
                                bool = f3223;
                            }
                            if (bool == null) {
                                throw new DynamiteModule$LoadingException("Failed to determine which loading route to use.");
                            }
                            if (bool.booleanValue()) {
                                new StringBuilder(str.length() + 40 + String.valueOf(i).length());
                                synchronized (C0705.class) {
                                    c1750 = f3220;
                                }
                                if (c1750 == null) {
                                    throw new DynamiteModule$LoadingException("DynamiteLoaderV2 was not cached.");
                                }
                                C2678 c26783 = (C2678) threadLocal.get();
                                if (c26783 == null || c26783.f10342 == null) {
                                    throw new DynamiteModule$LoadingException("No result cursor");
                                }
                                Context applicationContext2 = context.getApplicationContext();
                                Cursor cursor2 = c26783.f10342;
                                new BinderC3730(null);
                                synchronized (C0705.class) {
                                    z = f3219 >= 2;
                                }
                                Context context2 = (Context) BinderC3730.m8395(z ? c1750.m4794(new BinderC3730(applicationContext2), str, i, new BinderC3730(cursor2)) : c1750.m4793(new BinderC3730(applicationContext2), str, i, new BinderC3730(cursor2)));
                                if (context2 == null) {
                                    throw new DynamiteModule$LoadingException("Failed to get module context");
                                }
                                c0705 = new C0705(context2);
                            } else {
                                new StringBuilder(str.length() + 40 + String.valueOf(i).length());
                                C5137 c5137M2549 = m2549(context);
                                if (c5137M2549 == null) {
                                    throw new DynamiteModule$LoadingException("Failed to create IDynamiteLoader.");
                                }
                                Parcel parcelM10694 = c5137M2549.m10694(c5137M2549.m10695(), 6);
                                int i4 = parcelM10694.readInt();
                                parcelM10694.recycle();
                                if (i4 >= 3) {
                                    C2678 c26784 = (C2678) threadLocal.get();
                                    if (c26784 == null) {
                                        throw new DynamiteModule$LoadingException("No cached result cursor holder");
                                    }
                                    interfaceC4754M10646 = c5137M2549.m10643(new BinderC3730(context), str, i, new BinderC3730(c26784.f10342));
                                } else {
                                    interfaceC4754M10646 = i4 == 2 ? c5137M2549.m10646(new BinderC3730(context), str, i) : c5137M2549.m10645(new BinderC3730(context), str, i);
                                }
                                Object objM8395 = BinderC3730.m8395(interfaceC4754M10646);
                                if (objM8395 == null) {
                                    throw new DynamiteModule$LoadingException("Failed to load remote module.");
                                }
                                c0705 = new C0705((Context) objM8395);
                            }
                            if (j == 0) {
                                f3227.remove();
                            } else {
                                f3227.set(l);
                            }
                            Cursor cursor3 = c26782.f10342;
                            if (cursor3 != null) {
                                cursor3.close();
                            }
                            f3225.set(c2678);
                            return c0705;
                        } catch (RemoteException e2) {
                            throw new DynamiteModule$LoadingException("Failed to load remote module.", e2);
                        } catch (DynamiteModule$LoadingException e3) {
                            throw e3;
                        } catch (Throwable th2) {
                            throw new DynamiteModule$LoadingException("Failed to load remote module.", th2);
                        }
                    }
                } else if (c5151Mo4210.f19366 != 0) {
                    i2 = -1;
                    if (i2 == 1) {
                    }
                    if (i2 != -1) {
                    }
                }
            }
            int i5 = c5151Mo4210.f19366;
            int i6 = c5151Mo4210.f19364;
            StringBuilder sb2 = new StringBuilder(str.length() + 46 + String.valueOf(i5).length() + 23 + String.valueOf(i6).length() + 1);
            sb2.append("No acceptable module ");
            sb2.append(str);
            sb2.append(" found. Local version is ");
            sb2.append(i5);
            sb2.append(" and remote version is ");
            sb2.append(i6);
            sb2.append(".");
            throw new DynamiteModule$LoadingException(sb2.toString());
        } catch (Throwable th3) {
            th = th3;
            if (j == 0) {
                f3227.remove();
            } else {
                f3227.set(l);
            }
            Cursor cursor4 = c26782.f10342;
            if (cursor4 != null) {
                cursor4.close();
            }
            f3225.set(c2678);
            throw th;
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static boolean m2551(Context context) {
        ApplicationInfo applicationInfo;
        Boolean bool = Boolean.TRUE;
        if (bool.equals(null) || bool.equals(f3229)) {
            return true;
        }
        boolean z = false;
        if (f3229 == null) {
            ProviderInfo providerInfoResolveContentProvider = context.getPackageManager().resolveContentProvider("com.google.android.gms.chimera", Build.VERSION.SDK_INT >= 29 ? 268435456 : 0);
            if (C5073.f19129.m10399(context, 10000000) == 0 && providerInfoResolveContentProvider != null && "com.google.android.gms".equals(providerInfoResolveContentProvider.packageName)) {
                z = true;
            }
            f3229 = Boolean.valueOf(z);
            if (z && (applicationInfo = providerInfoResolveContentProvider.applicationInfo) != null && (applicationInfo.flags & 129) == 0) {
                f3226 = true;
            }
        }
        return z;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static int m2552(Context context, String str) {
        try {
            ClassLoader classLoader = context.getApplicationContext().getClassLoader();
            StringBuilder sb = new StringBuilder(str.length() + 61);
            sb.append("com.google.android.gms.dynamite.descriptors.");
            sb.append(str);
            sb.append(".ModuleDescriptor");
            Class<?> clsLoadClass = classLoader.loadClass(sb.toString());
            Field declaredField = clsLoadClass.getDeclaredField("MODULE_ID");
            Field declaredField2 = clsLoadClass.getDeclaredField("MODULE_VERSION");
            if (ᵬʕˎʽ.ᵻʽᵯ(declaredField.get(null), str)) {
                return declaredField2.getInt(null);
            }
            new StringBuilder(String.valueOf(declaredField.get(null)).length() + 50 + str.length() + 1);
            return 0;
        } catch (ClassNotFoundException unused) {
            new StringBuilder(str.length() + 45);
            return 0;
        } catch (Exception e) {
            "Failed to load module descriptor class: ".concat(String.valueOf(e.getMessage()));
            return 0;
        }
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public static void m2553(ClassLoader classLoader) throws DynamiteModule$LoadingException {
        try {
            C1750 c1750 = 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");
                c1750 = iInterfaceQueryLocalInterface instanceof C1750 ? (C1750) iInterfaceQueryLocalInterface : new C1750(iBinder, "com.google.android.gms.dynamite.IDynamiteLoaderV2", 1);
            }
            f3220 = c1750;
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
            throw new DynamiteModule$LoadingException("Failed to instantiate dynamite loader", e);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:101:0x016d  */
    /* JADX WARN: Removed duplicated region for block: B:103:0x0170 A[Catch: all -> 0x00e1, TRY_ENTER, TryCatch #0 {all -> 0x00e1, blocks: (B:3:0x0002, B:63:0x00d6, B:65:0x00dc, B:73:0x00fb, B:103:0x0170, B:112:0x0183, B:128:0x01ea, B:129:0x01ed, B:123:0x01e1, B:71:0x00e7, B:131:0x01ef, B:4:0x0003, B:7:0x000a, B:8:0x0026, B:61:0x00d3, B:21:0x004a, B:44:0x00a1, B:47:0x00a4, B:54:0x00bc, B:62:0x00d5, B:60:0x00c2), top: B:136:0x0002, inners: #6, #12 }] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00b0 A[Catch: all -> 0x0037, TryCatch #10 {, 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:144:0x0027, inners: #13 }] */
    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int m2554(Context context, String str, boolean z) {
        Field declaredField;
        Throwable th;
        RemoteException remoteException;
        int i;
        Cursor cursor;
        try {
            synchronized (C0705.class) {
                Boolean bool = f3223;
                boolean z2 = true;
                Cursor cursor2 = null;
                if (bool == null) {
                    try {
                        declaredField = context.getApplicationContext().getClassLoader().loadClass(DynamiteModule$DynamiteLoaderClassLoader.class.getName()).getDeclaredField("sClassLoader");
                    } catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException e) {
                        new StringBuilder(e.toString().length() + 30);
                        bool = Boolean.FALSE;
                    }
                    synchronized (declaredField.getDeclaringClass()) {
                        ClassLoader classLoader = (ClassLoader) declaredField.get(null);
                        if (classLoader == ClassLoader.getSystemClassLoader()) {
                            bool = Boolean.FALSE;
                        } else if (classLoader != null) {
                            try {
                                m2553(classLoader);
                            } catch (DynamiteModule$LoadingException unused) {
                            }
                            bool = Boolean.TRUE;
                        } else {
                            if (!m2551(context)) {
                                return 0;
                            }
                            if (!f3226) {
                                Boolean bool2 = Boolean.TRUE;
                                if (bool2.equals(null)) {
                                    declaredField.set(null, ClassLoader.getSystemClassLoader());
                                    bool = Boolean.FALSE;
                                } else {
                                    try {
                                        int iM2555 = m2555(context, str, z, true);
                                        String str2 = f3230;
                                        if (str2 != null && !str2.isEmpty()) {
                                            ClassLoader c3073 = ᵲᵧˇ.ˊᵾʽʼ();
                                            if (c3073 == null) {
                                                if (Build.VERSION.SDK_INT >= 29) {
                                                    AbstractC3148.m7254();
                                                    String str3 = f3230;
                                                    ᵘᵞʿⁱ.ᵶᵥᵝ(str3);
                                                    c3073 = AbstractC3148.m7255(ClassLoader.getSystemClassLoader(), str3);
                                                } else {
                                                    String str4 = f3230;
                                                    ᵘᵞʿⁱ.ᵶᵥᵝ(str4);
                                                    c3073 = new C3073(str4, ClassLoader.getSystemClassLoader());
                                                }
                                            }
                                            m2553(c3073);
                                            declaredField.set(null, c3073);
                                            f3223 = bool2;
                                            return iM2555;
                                        }
                                        return iM2555;
                                    } catch (DynamiteModule$LoadingException unused2) {
                                        declaredField.set(null, ClassLoader.getSystemClassLoader());
                                        bool = Boolean.FALSE;
                                    }
                                }
                            }
                            new StringBuilder(e.toString().length() + 30);
                            bool = Boolean.FALSE;
                            f3223 = bool;
                        }
                        f3223 = bool;
                    }
                }
                if (bool.booleanValue()) {
                    try {
                        return m2555(context, str, z, false);
                    } catch (DynamiteModule$LoadingException e2) {
                        new StringBuilder(String.valueOf(e2.getMessage()).length() + 42);
                        return 0;
                    }
                }
                C5137 c5137M2549 = m2549(context);
                try {
                    if (c5137M2549 == null) {
                        return 0;
                    }
                    try {
                        Parcel parcelM10694 = c5137M2549.m10694(c5137M2549.m10695(), 6);
                        int i2 = parcelM10694.readInt();
                        parcelM10694.recycle();
                        if (i2 >= 3) {
                            ThreadLocal threadLocal = f3225;
                            C2678 c2678 = (C2678) threadLocal.get();
                            if (c2678 != null && (cursor = c2678.f10342) != null) {
                                return cursor.getInt(0);
                            }
                            Cursor cursor3 = (Cursor) BinderC3730.m8395(c5137M2549.m10644(new BinderC3730(context), str, z, ((Long) f3227.get()).longValue()));
                            if (cursor3 != null) {
                                try {
                                    if (cursor3.moveToFirst()) {
                                        i = cursor3.getInt(0);
                                        if (i <= 0) {
                                            cursor2 = cursor3;
                                            if (cursor2 != null) {
                                                cursor2.close();
                                            }
                                        } else {
                                            C2678 c26782 = (C2678) threadLocal.get();
                                            if (c26782 == null || c26782.f10342 != null) {
                                                z2 = false;
                                            } else {
                                                c26782.f10342 = cursor3;
                                            }
                                            if (!z2) {
                                            }
                                            if (cursor2 != null) {
                                            }
                                        }
                                    }
                                } catch (RemoteException e3) {
                                    remoteException = e3;
                                    cursor2 = cursor3;
                                    new StringBuilder(String.valueOf(remoteException.getMessage()).length() + 42);
                                    if (cursor2 == null) {
                                        return 0;
                                    }
                                    cursor2.close();
                                    return 0;
                                } catch (Throwable th2) {
                                    th = th2;
                                    cursor2 = cursor3;
                                    if (cursor2 == null) {
                                        throw th;
                                    }
                                    cursor2.close();
                                    throw th;
                                }
                            }
                            if (cursor3 == null) {
                                return 0;
                            }
                            cursor3.close();
                            return 0;
                        }
                        if (i2 == 2) {
                            BinderC3730 binderC3730 = new BinderC3730(context);
                            Parcel parcelM10695 = c5137M2549.m10695();
                            AbstractC4052.m8859(parcelM10695, binderC3730);
                            parcelM10695.writeString(str);
                            parcelM10695.writeInt(z ? 1 : 0);
                            Parcel parcelM106942 = c5137M2549.m10694(parcelM10695, 5);
                            i = parcelM106942.readInt();
                            parcelM106942.recycle();
                        } else {
                            BinderC3730 binderC37302 = new BinderC3730(context);
                            Parcel parcelM106952 = c5137M2549.m10695();
                            AbstractC4052.m8859(parcelM106952, binderC37302);
                            parcelM106952.writeString(str);
                            parcelM106952.writeInt(z ? 1 : 0);
                            Parcel parcelM106943 = c5137M2549.m10694(parcelM106952, 3);
                            i = parcelM106943.readInt();
                            parcelM106943.recycle();
                        }
                        return i;
                    } catch (RemoteException e4) {
                        remoteException = e4;
                    }
                } catch (Throwable th3) {
                    th = th3;
                }
            }
        } finally {
        }
    }

    /* JADX WARN: Finally extract failed */
    /* JADX WARN: Removed duplicated region for block: B:124:0x00e7 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:85:0x013a A[PHI: r3
      0x013a: PHI (r3v4 boolean) = (r3v3 boolean), (r3v6 boolean) binds: [B:58:0x00f1, B:83:0x0137] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int m2555(Context context, String str, boolean z, boolean z2) throws Throwable {
        Exception exc;
        Throwable th;
        Cursor cursorQuery;
        MatrixCursor matrixCursor;
        boolean z3;
        try {
            try {
                boolean z4 = true;
                Uri uriBuild = new Uri.Builder().scheme("content").authority("com.google.android.gms.chimera").path(true != z ? "api" : "api_force_staging").appendPath(str).appendQueryParameter("requestStartUptime", String.valueOf(((Long) f3227.get()).longValue())).build();
                ContentProviderClient contentProviderClientAcquireUnstableContentProviderClient = context.getContentResolver().acquireUnstableContentProviderClient(uriBuild);
                boolean z5 = false;
                if (contentProviderClientAcquireUnstableContentProviderClient != null) {
                    try {
                        cursorQuery = contentProviderClientAcquireUnstableContentProviderClient.query(uriBuild, null, null, null, null);
                    } catch (RemoteException unused) {
                    } catch (Throwable th2) {
                        contentProviderClientAcquireUnstableContentProviderClient.release();
                        throw th2;
                    }
                    if (cursorQuery != null) {
                        try {
                            int count = cursorQuery.getCount();
                            int columnCount = cursorQuery.getColumnCount();
                            matrixCursor = new MatrixCursor(cursorQuery.getColumnNames(), count);
                            for (int i = 0; i < count; i++) {
                                if (!cursorQuery.moveToPosition(i)) {
                                    throw new RemoteException("Cursor read incomplete (ContentProvider dead?)");
                                }
                                Object[] objArr = new Object[columnCount];
                                for (int i2 = 0; i2 < columnCount; i2++) {
                                    int type = cursorQuery.getType(i2);
                                    if (type == 0) {
                                        objArr[i2] = null;
                                    } else if (type == 1) {
                                        objArr[i2] = Long.valueOf(cursorQuery.getLong(i2));
                                    } else if (type == 2) {
                                        objArr[i2] = Double.valueOf(cursorQuery.getDouble(i2));
                                    } else if (type == 3) {
                                        objArr[i2] = cursorQuery.getString(i2);
                                    } else {
                                        if (type != 4) {
                                            throw new RemoteException("Unknown column type");
                                        }
                                        objArr[i2] = cursorQuery.getBlob(i2);
                                    }
                                }
                                matrixCursor.addRow(objArr);
                            }
                            cursorQuery.close();
                            contentProviderClientAcquireUnstableContentProviderClient.release();
                            if (matrixCursor != null) {
                                try {
                                    if (matrixCursor.moveToFirst()) {
                                        int i3 = matrixCursor.getInt(0);
                                        if (i3 > 0) {
                                            synchronized (C0705.class) {
                                                try {
                                                    f3230 = matrixCursor.getString(2);
                                                    int columnIndex = matrixCursor.getColumnIndex("loaderVersion");
                                                    if (columnIndex >= 0) {
                                                        f3219 = matrixCursor.getInt(columnIndex);
                                                    }
                                                    int columnIndex2 = matrixCursor.getColumnIndex("disableStandaloneDynamiteLoader2");
                                                    if (columnIndex2 >= 0) {
                                                        z3 = matrixCursor.getInt(columnIndex2) != 0;
                                                        f3226 = z3;
                                                    } else {
                                                        z3 = false;
                                                    }
                                                } finally {
                                                }
                                            }
                                            C2678 c2678 = (C2678) f3225.get();
                                            if (c2678 == null || c2678.f10342 != null) {
                                                z4 = false;
                                            } else {
                                                c2678.f10342 = matrixCursor;
                                            }
                                            z5 = z3;
                                            matrixCursor = z4 ? null : matrixCursor;
                                        }
                                        if (z2 && z5) {
                                            throw new DynamiteModule$LoadingException("forcing fallback to container DynamiteLoader impl");
                                        }
                                        if (matrixCursor != null) {
                                            matrixCursor.close();
                                        }
                                        return i3;
                                    }
                                } catch (Exception e) {
                                    exc = e;
                                    if (exc instanceof DynamiteModule$LoadingException) {
                                        throw exc;
                                    }
                                    String message = exc.getMessage();
                                    StringBuilder sb = new StringBuilder(String.valueOf(message).length() + 25);
                                    sb.append("V2 version check failed: ");
                                    sb.append(message);
                                    throw new DynamiteModule$LoadingException(sb.toString(), exc);
                                } catch (Throwable th3) {
                                    th = th3;
                                    matrixCursor = matrixCursor;
                                    if (matrixCursor == null) {
                                        throw th;
                                    }
                                    matrixCursor.close();
                                    throw th;
                                }
                            }
                            throw new DynamiteModule$LoadingException("Failed to connect to dynamite module ContentResolver.");
                        } catch (Throwable th4) {
                            try {
                                cursorQuery.close();
                                throw th4;
                            } catch (Throwable th5) {
                                th4.addSuppressed(th5);
                                throw th4;
                            }
                        }
                    }
                    contentProviderClientAcquireUnstableContentProviderClient.release();
                }
                matrixCursor = null;
                if (matrixCursor != null) {
                }
                throw new DynamiteModule$LoadingException("Failed to connect to dynamite module ContentResolver.");
            } catch (Throwable th6) {
                th = th6;
            }
        } catch (Exception e2) {
            exc = e2;
        }
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final IBinder m2556(String str) throws DynamiteModule$LoadingException {
        try {
            return (IBinder) this.f3231.getClassLoader().loadClass(str).newInstance();
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
            throw new DynamiteModule$LoadingException("Failed to instantiate module class: ".concat(str), e);
        }
    }
}
