package defpackage;

import android.net.Uri;
import java.io.InterruptedIOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/* JADX INFO: renamed from: ᵨᵰ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3771 implements InterfaceC1933 {

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public InterfaceC5226 f14347;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public volatile boolean f14348;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public final /* synthetic */ C4708 f14349;

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

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public C0084 f14352;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final ᵯᵨᵲ f14353;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C0165 f14354;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public boolean f14355;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final C4708 f14356;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final C2123 f14357;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public long f14359;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final C2669 f14358 = new C2669();

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public boolean f14351 = true;

    public C3771(C4708 c4708, Uri uri, InterfaceC1070 interfaceC1070, ᵯᵨᵲ r4, C4708 c47082, C2123 c2123) {
        this.f14349 = c4708;
        this.f14350 = uri;
        this.f14354 = new C0165(interfaceC1070);
        this.f14353 = r4;
        this.f14356 = c47082;
        this.f14357 = c2123;
        C3622.f13742.getAndIncrement();
        this.f14352 = m8445(0L, null);
    }

    @Override // defpackage.InterfaceC1933
    /* JADX INFO: renamed from: ᵱᵽʡᵚ */
    public final void mo3273() {
        this.f14348 = true;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C0084 m8445(long j, String str) {
        Map mapM4052 = C4708.f17902;
        if (str != null && !str.startsWith("W/")) {
            C1404 c1404M7805 = AbstractC3409.m7805();
            c1404M7805.m4041(mapM4052.entrySet());
            c1404M7805.m4036("If-Range", str);
            mapM4052 = c1404M7805.m4052(false);
        }
        Map map = Collections.EMPTY_MAP;
        Uri uri = this.f14350;
        ᵻᵪ.ᵱʡˏ(uri, "The uri must be set.");
        return new C0084(uri, 1, null, mapM4052, j, -1L, null, 6);
    }

    @Override // defpackage.InterfaceC1933
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo3275() {
        InterfaceC1070 c3200;
        InterfaceC4291 interfaceC4291;
        int i;
        int iMo1258 = 0;
        String str = null;
        while (iMo1258 == 0 && !this.f14348) {
            try {
                long j = this.f14358.f10317;
                C0084 c0084M8445 = m8445(j, str);
                this.f14352 = c0084M8445;
                long jMo1308 = this.f14354.mo1308(c0084M8445);
                if (this.f14348) {
                    if (iMo1258 != 1 && this.f14353.ˊˌˊ() != -1) {
                        this.f14358.f10317 = this.f14353.ˊˌˊ();
                    }
                    ˑᵕʾ.ᵷᵺʾᵖ(this.f14354);
                    return;
                }
                List list = (List) this.f14354.f1574.mo1306().get("ETag");
                str = (list == null || list.isEmpty()) ? null : (String) list.get(0);
                if (jMo1308 != -1) {
                    jMo1308 += j;
                    C4708 c4708 = this.f14349;
                    c4708.f17916.post(new RunnableC2947(c4708, 0));
                }
                long j2 = jMo1308;
                this.f14349.f17942 = C0550.m2138(this.f14354.f1574.mo1306());
                C0165 c0165 = this.f14354;
                C0550 c0550 = this.f14349.f17942;
                if (c0550 == null || (i = c0550.f2799) == -1) {
                    c3200 = c0165;
                } else {
                    c3200 = new C3200(c0165, i, this);
                    InterfaceC5226 interfaceC5226M9842 = this.f14349.m9842(new C3230(0, true));
                    this.f14347 = interfaceC5226M9842;
                    interfaceC5226M9842.mo1742(C4708.f17901);
                }
                this.f14353.ʿᵿʽᵞ(c3200, this.f14350, this.f14354.f1574.mo1306(), j, j2, this.f14356);
                if (this.f14349.f17942 != null && (interfaceC4291 = (InterfaceC4291) this.f14353.ᵔᵖᵹᵫ) != null) {
                    InterfaceC4291 interfaceC4291Mo1254 = interfaceC4291.mo1254();
                    if (interfaceC4291Mo1254 instanceof C2724) {
                        ((C2724) interfaceC4291Mo1254).f10442 = true;
                    }
                }
                if (this.f14351) {
                    ᵯᵨᵲ r8 = this.f14353;
                    long j3 = this.f14359;
                    InterfaceC4291 interfaceC42912 = (InterfaceC4291) r8.ᵔᵖᵹᵫ;
                    interfaceC42912.getClass();
                    interfaceC42912.mo1252(j, j3);
                    this.f14351 = false;
                }
                while (iMo1258 == 0 && !this.f14348) {
                    try {
                        C2123 c2123 = this.f14357;
                        synchronized (c2123) {
                            while (!c2123.f8438) {
                                c2123.f8439.getClass();
                                c2123.wait();
                            }
                        }
                        ᵯᵨᵲ r82 = this.f14353;
                        C2669 c2669 = this.f14358;
                        InterfaceC4291 interfaceC42913 = (InterfaceC4291) r82.ᵔᵖᵹᵫ;
                        interfaceC42913.getClass();
                        C2373 c2373 = (C2373) r82.ᵨᵼⁱ;
                        c2373.getClass();
                        iMo1258 = interfaceC42913.mo1258(c2373, c2669);
                        long j4 = this.f14353.ˊˌˊ();
                        if (j4 > this.f14349.f17945 + j) {
                            this.f14357.m5627();
                            C4708 c47082 = this.f14349;
                            c47082.f17916.post(c47082.f17917);
                            j = j4;
                        }
                    } catch (InterruptedException unused) {
                        throw new InterruptedIOException();
                    }
                }
                if (iMo1258 == 1) {
                    iMo1258 = 0;
                } else if (this.f14353.ˊˌˊ() != -1) {
                    this.f14358.f10317 = this.f14353.ˊˌˊ();
                }
                ˑᵕʾ.ᵷᵺʾᵖ(this.f14354);
            } catch (Throwable th) {
                if (iMo1258 != 1 && this.f14353.ˊˌˊ() != -1) {
                    this.f14358.f10317 = this.f14353.ˊˌˊ();
                }
                ˑᵕʾ.ᵷᵺʾᵖ(this.f14354);
                throw th;
            }
        }
    }
}
