package defpackage;

import java.util.concurrent.locks.ReentrantLock;

/* JADX INFO: renamed from: ᵽᵱʽﾞ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5388 implements InterfaceC1306 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final C3965 f20405;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final ᵘᵛ f20407;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public InterfaceC2047 f20409;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public volatile boolean f20410;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final ReentrantLock f20406 = new ReentrantLock();

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final C2415 f20408 = new C2415();

    public C5388(C3965 c3965, ᵘᵛ r2) {
        this.f20405 = c3965;
        this.f20407 = r2;
    }

    @Override // java.lang.AutoCloseable
    public final void close() throws Exception {
        this.f20410 = true;
        InterfaceC2047 interfaceC2047 = this.f20409;
        if (interfaceC2047 != null) {
            if (interfaceC2047 == null) {
                interfaceC2047 = null;
            }
            interfaceC2047.close();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:36:0x0087  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x008b  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x00a1  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00a5  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m10980(ᵧːᵿ r11, AbstractC3500 abstractC3500) throws Throwable {
        C2695 c2695;
        long j;
        if (abstractC3500 instanceof C2695) {
            c2695 = (C2695) abstractC3500;
            int i = c2695.f10375;
            if ((i & Integer.MIN_VALUE) != 0) {
                c2695.f10375 = i - Integer.MIN_VALUE;
            } else {
                c2695 = new C2695(this, abstractC3500);
            }
        }
        InterfaceC3822 interfaceC3822 = c2695.f13450;
        Object obj = c2695.f10377;
        int i2 = c2695.f10375;
        C5063 c5063 = C5063.f19112;
        InterfaceC2643 interfaceC2643 = null;
        int i3 = 2;
        ReentrantLock reentrantLock = this.f20406;
        if (i2 != 0) {
            if (i2 != 1) {
                if (i2 == 2) {
                    ᵟˌᵫ.ˊˌˊ(obj);
                    return c5063;
                }
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
                return null;
            }
            j = c2695.f10376;
            try {
                ᵟˌᵫ.ˊˌˊ(obj);
                if (j != Thread.currentThread().getId()) {
                    reentrantLock.unlock();
                    return c5063;
                }
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Resumed on a different thread during connection pool initialization. This can occur when Room's SupportSQLite wrapper is used with a suspending driver. Please report this issue at https://issuetracker.google.com/issues/new?component=413107&template=1096568.");
                return null;
            } catch (Throwable th) {
                th = th;
                if (j == Thread.currentThread().getId()) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Resumed on a different thread during connection pool initialization. This can occur when Room's SupportSQLite wrapper is used with a suspending driver. Please report this issue at https://issuetracker.google.com/issues/new?component=413107&template=1096568.");
                    return null;
                }
                reentrantLock.unlock();
                throw th;
            }
        }
        ᵟˌᵫ.ˊˌˊ(obj);
        InterfaceC5263 interfaceC5263Mo2664 = interfaceC3822.mo2664(ˉᵠﹳᵘ.ᵔᵖᵹᵫ);
        C1807 c1807 = AbstractC0307.f1985;
        EnumC0111 enumC0111 = EnumC0111.f1384;
        if (interfaceC5263Mo2664 != c1807) {
            C4974 c4974 = new C4974(r11, interfaceC2643, i3);
            c2695.f10375 = 2;
            if (ᵽˊᵘᵬ.ᵔᵖᵹᵫ(this.f20408, c4974, c2695) != enumC0111) {
                return c5063;
            }
        } else {
            if (ᵥˈᵛ.ˊᵫᵗ(((C4469) interfaceC3822.mo2664(C4469.f17069)) != null ? "Room Invalidation Tracker Refresh" : null, "RoomSupportSQLiteTransaction")) {
                long id = Thread.currentThread().getId();
                reentrantLock.lock();
                try {
                    c2695.f10376 = id;
                    c2695.f10375 = 1;
                    if (r11.ʽˈˋ(c2695) != enumC0111) {
                        j = id;
                        if (j != Thread.currentThread().getId()) {
                        }
                    }
                } catch (Throwable th2) {
                    th = th2;
                    j = id;
                    if (j == Thread.currentThread().getId()) {
                    }
                }
            }
        }
        return enumC0111;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @Override // defpackage.InterfaceC1306
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object mo3445(boolean z, InterfaceC0321 interfaceC0321, AbstractC3500 abstractC3500) {
        C5135 c5135;
        if (abstractC3500 instanceof C5135) {
            c5135 = (C5135) abstractC3500;
            int i = c5135.f19306;
            if ((i & Integer.MIN_VALUE) != 0) {
                c5135.f19306 = i - Integer.MIN_VALUE;
            } else {
                c5135 = new C5135(this, abstractC3500);
            }
        }
        Object obj = c5135.f19308;
        Object obj2 = EnumC0111.f1384;
        int i2 = c5135.f19306;
        if (i2 == 0) {
            ᵟˌᵫ.ˊˌˊ(obj);
            if (this.f20410) {
                ˋˀᵧ.ᵸˆˁ(21, "Connection pool is closed");
                throw null;
            }
            C3999 c3999 = (C3999) c5135.f13450.mo2664(C3999.f15306);
            C5434 c5434 = c3999 != null ? c3999.f15307 : null;
            if (c5434 != null) {
                c5135.f19306 = 1;
                Object objMo1564 = interfaceC0321.mo1564(c5434, c5135);
                if (objMo1564 != obj2) {
                    return objMo1564;
                }
            } else if (this.f20409 == null) {
                ᵧːᵿ r9 = new ᵧːᵿ(this, (InterfaceC2643) null, 6);
                c5135.f19307 = interfaceC0321;
                c5135.f19306 = 2;
                if (m10980(r9, c5135) != obj2) {
                }
            }
        }
        if (i2 == 1) {
            ᵟˌᵫ.ˊˌˊ(obj);
            return obj;
        }
        if (i2 != 2) {
            if (i2 == 3) {
                ᵟˌᵫ.ˊˌˊ(obj);
                return obj;
            }
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("call to 'resume' before 'invoke' with coroutine");
            return null;
        }
        interfaceC0321 = c5135.f19307;
        ᵟˌᵫ.ˊˌˊ(obj);
        ᵘᵛ r1 = this.f20407;
        InterfaceC2047 interfaceC2047 = this.f20409;
        if (interfaceC2047 == null) {
            interfaceC2047 = null;
        }
        C5434 c54342 = new C5434(r1, interfaceC2047);
        C3999 c39992 = new C3999(c54342);
        ᵡᵥ r12 = new ᵡᵥ(interfaceC0321, c54342, (InterfaceC2643) null, 2);
        c5135.f19307 = null;
        c5135.f19306 = 3;
        Object obj3 = ᵲᵧˇ.ᵠˏˏ(c39992, r12, c5135);
        return obj3 == obj2 ? obj2 : obj3;
    }
}
