package defpackage;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* renamed from: ᵲʨᵹ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4463 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final Object f16652;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final Object f16653;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final Object f16654;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public boolean f16655;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final /* synthetic */ int f16656;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public boolean f16657;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public Object f16658;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final Object f16659;

    public C4463(C2519 c2519, AbstractC1741 abstractC1741) {
        int i;
        Object c5151;
        this.f16656 = 1;
        int i2 = c2519.f9804;
        String str = c2519.f9813;
        InterfaceC2889 interfaceC2889 = c2519.f9806;
        this.f16659 = c2519;
        this.f16652 = abstractC1741;
        Object obj = c2519.f9801;
        this.f16654 = obj == null ? C3035.f11677 : obj;
        InterfaceC0805 interfaceC0805 = c2519.f9808;
        if (interfaceC0805 != null) {
            if (interfaceC0805 instanceof C0977) {
                c5151 = new C4797(new ᵪᵨ(this, 9, interfaceC0805), str == null ? ":memory:" : str);
            } else if (str == null) {
                c5151 = new C5151(new ᵪᵨ(this, 9, interfaceC0805));
            } else {
                ᵪᵨ r10 = new ᵪᵨ(this, 9, interfaceC0805);
                int iM4088 = AbstractC1327.m4088(i2);
                if (iM4088 == 1) {
                    i = 1;
                } else {
                    if (iM4088 != 2) {
                        throw new IllegalStateException(("Can't get max number of reader for journal mode '" + AbstractC2990.m7305(i2) + '\'').toString());
                    }
                    i = 4;
                }
                int iM40882 = AbstractC1327.m4088(i2);
                if (iM40882 != 1 && iM40882 != 2) {
                    throw new IllegalStateException(("Can't get max number of writers for journal mode '" + AbstractC2990.m7305(i2) + '\'').toString());
                }
                c5151 = new C5151(r10, str, i);
            }
            this.f16653 = c5151;
        } else {
            if (interfaceC2889 == null) {
                ᵹˉᵞ.ˌᵜᵹᵩ("SQLiteManager was constructed with both null driver and open helper factory!");
                throw null;
            }
            this.f16653 = new C3548(new ˊʘ(23, interfaceC2889.m7054(new C4520(c2519.f9809, str, new C2124(this, abstractC1741.f6950), false, false))));
        }
        boolean z = i2 == 3;
        InterfaceC4217 interfaceC4217M9493 = m9493();
        if (interfaceC4217M9493 != null) {
            interfaceC4217M9493.setWriteAheadLoggingEnabled(z);
        }
    }

    public C4463(C2519 c2519, ᵙʢʽ r5) {
        this.f16656 = 1;
        this.f16659 = c2519;
        this.f16652 = new C3530(-1, "", "");
        List list = c2519.f9801;
        C3035 c3035 = C3035.f11677;
        this.f16654 = list == null ? c3035 : list;
        AbstractC2767.m6807(list == null ? c3035 : list, new C1813(1, new ᵡᵘˎʽ(29, this)));
        throw new C1225();
    }

    public C4463(boolean z, boolean z2, Long l, Long l2, Long l3, Long l4) {
        this.f16656 = 0;
        this.f16657 = z;
        this.f16655 = z2;
        this.f16659 = l;
        this.f16652 = l2;
        this.f16654 = l3;
        this.f16653 = l4;
        this.f16658 = AbstractC4546.m9662(C1859.f7545);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static final void m9488(C4463 c4463, InterfaceC3042 interfaceC3042) throws Throwable {
        Object c2952;
        AbstractC1741 abstractC1741 = (AbstractC1741) c4463.f16652;
        C2519 c2519 = (C2519) c4463.f16659;
        if (c2519.f9804 == 3) {
            ᵭʝʜ.ᵪʩ(interfaceC3042, "PRAGMA journal_mode = WAL");
        } else {
            ᵭʝʜ.ᵪʩ(interfaceC3042, "PRAGMA journal_mode = TRUNCATE");
        }
        if (c2519.f9804 == 3) {
            ᵭʝʜ.ᵪʩ(interfaceC3042, "PRAGMA synchronous = NORMAL");
        } else {
            ᵭʝʜ.ᵪʩ(interfaceC3042, "PRAGMA synchronous = FULL");
        }
        m9489(interfaceC3042);
        InterfaceC1171 interfaceC1171Mo1850 = interfaceC3042.mo1850("PRAGMA user_version");
        try {
            interfaceC1171Mo1850.mo3681();
            int i = (int) interfaceC1171Mo1850.getLong(0);
            ᵛᵾˏ.ᵾᵬ(interfaceC1171Mo1850, (Throwable) null);
            int i2 = abstractC1741.f6950;
            if (i != i2) {
                ᵭʝʜ.ᵪʩ(interfaceC3042, "BEGIN EXCLUSIVE TRANSACTION");
                try {
                    if (i == 0) {
                        c4463.m9494(interfaceC3042);
                    } else {
                        c4463.m9490(interfaceC3042, i, i2);
                    }
                    ᵭʝʜ.ᵪʩ(interfaceC3042, "PRAGMA user_version = " + i2);
                    c2952 = C3637.f13536;
                } catch (Throwable th) {
                    c2952 = new C2952(th);
                }
                if (!(c2952 instanceof C2952)) {
                    ᵭʝʜ.ᵪʩ(interfaceC3042, "END TRANSACTION");
                }
                Throwable thM8872 = AbstractC4019.m8872(c2952);
                if (thM8872 != null) {
                    ᵭʝʜ.ᵪʩ(interfaceC3042, "ROLLBACK TRANSACTION");
                    throw thM8872;
                }
            }
            c4463.m9492(interfaceC3042);
        } finally {
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static void m9489(InterfaceC3042 interfaceC3042) {
        InterfaceC1171 interfaceC1171Mo1850 = interfaceC3042.mo1850("PRAGMA busy_timeout");
        try {
            interfaceC1171Mo1850.mo3681();
            long j = interfaceC1171Mo1850.getLong(0);
            ᵛᵾˏ.ᵾᵬ(interfaceC1171Mo1850, (Throwable) null);
            if (j < 3000) {
                ᵭʝʜ.ᵪʩ(interfaceC3042, "PRAGMA busy_timeout = 3000");
            }
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                ᵛᵾˏ.ᵾᵬ(interfaceC1171Mo1850, th);
                throw th2;
            }
        }
    }

    public String toString() {
        switch (this.f16656) {
            case 0:
                Map map = (Map) this.f16658;
                Long l = (Long) this.f16653;
                Long l2 = (Long) this.f16654;
                Long l3 = (Long) this.f16652;
                Long l4 = (Long) this.f16659;
                ArrayList arrayList = new ArrayList();
                if (this.f16657) {
                    arrayList.add("isRegularFile");
                }
                if (this.f16655) {
                    arrayList.add("isDirectory");
                }
                if (l4 != null) {
                    arrayList.add("byteCount=" + l4.longValue());
                }
                if (l3 != null) {
                    arrayList.add("createdAt=" + l3.longValue());
                }
                if (l2 != null) {
                    arrayList.add("lastModifiedAt=" + l2.longValue());
                }
                if (l != null) {
                    arrayList.add("lastAccessedAt=" + l.longValue());
                }
                if (!map.isEmpty()) {
                    arrayList.add("extras=" + map);
                }
                return AbstractC2767.m6822(arrayList, ", ", "FileMetadata(", ")", null, 56);
            default:
                return super.toString();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:111:0x009b A[EDGE_INSN: B:111:0x009b->B:39:0x009b BREAK  A[LOOP:4: B:9:0x0025->B:115:?], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0030  */
    /* JADX WARN: Removed duplicated region for block: B:17:0x003c  */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0048  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0061  */
    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void m9490(defpackage.InterfaceC3042 r17, int r18, int r19) {
        /*
            Method dump skipped, instructions count: 430
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C4463.m9490(ᵟᴵ, int, int):void");
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public void m9491(InterfaceC3042 interfaceC3042) {
        ᵭʝʜ.ᵪʩ(interfaceC3042, "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)");
        ᵭʝʜ.ᵪʩ(interfaceC3042, "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '" + ((AbstractC1741) this.f16652).f6951 + "')");
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x0023  */
    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void m9492(defpackage.InterfaceC3042 r11) throws java.lang.Throwable {
        /*
            Method dump skipped, instructions count: 316
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C4463.m9492(ᵟᴵ):void");
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public InterfaceC4217 m9493() {
        InterfaceC2274 interfaceC2274 = (InterfaceC2274) this.f16653;
        C3548 c3548 = interfaceC2274 instanceof C3548 ? (C3548) interfaceC2274 : null;
        if (c3548 != null) {
            return (InterfaceC4217) c3548.f13300.ᵢˇᵭ;
        }
        return null;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public void m9494(InterfaceC3042 interfaceC3042) {
        AbstractC1741 abstractC1741 = (AbstractC1741) this.f16652;
        InterfaceC1171 interfaceC1171Mo1850 = interfaceC3042.mo1850("SELECT count(*) FROM sqlite_master WHERE name != 'android_metadata'");
        try {
            boolean z = false;
            if (interfaceC1171Mo1850.mo3681()) {
                if (interfaceC1171Mo1850.getLong(0) == 0) {
                    z = true;
                }
            }
            ᵛᵾˏ.ᵾᵬ(interfaceC1171Mo1850, (Throwable) null);
            abstractC1741.mo4953(interfaceC3042);
            if (!z) {
                C4413 c4413Mo4955 = abstractC1741.mo4955(interfaceC3042);
                if (!c4413Mo4955.f16510) {
                    ᵨᴵᵺ.ᵧᵾˀˈ(c4413Mo4955.f16508, "Pre-packaged database has an invalid schema: ");
                    return;
                }
            }
            m9491(interfaceC3042);
            abstractC1741.mo4951();
            Iterator it = ((List) this.f16654).iterator();
            while (it.hasNext()) {
                ((C1813) it.next()).getClass();
            }
        } finally {
        }
    }
}
