package defpackage;

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

/* renamed from: ᵭᵼᵟʾ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4162 implements InterfaceC0452 {

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public volatile boolean f15555;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public C4179 f15556;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public long f15557;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final C0186 f15560;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final C1790 f15561;

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public boolean f15562;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final Uri f15563;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public InterfaceC2154 f15564;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public final /* synthetic */ C3425 f15565;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final C3425 f15566;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final ʽᵡ f15567;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final C4184 f15559 = new C4184();

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public boolean f15558 = true;

    public C4162(C3425 c3425, Uri uri, InterfaceC2569 interfaceC2569, ʽᵡ r4, C3425 c34252, C1790 c1790) {
        this.f15565 = c3425;
        this.f15563 = uri;
        this.f15560 = new C0186(interfaceC2569);
        this.f15567 = r4;
        this.f15566 = c34252;
        this.f15561 = c1790;
        C0417.f2319.getAndIncrement();
        this.f15556 = m9066(0L, null);
    }

    @Override // defpackage.InterfaceC0452
    /* renamed from: ˎˏʜʾ */
    public final void mo1781() {
        InterfaceC2569 c4239;
        InterfaceC2689 interfaceC2689;
        int i;
        int iMo1578 = 0;
        String str = null;
        while (iMo1578 == 0 && !this.f15555) {
            try {
                long j = this.f15559.f15658;
                C4179 c4179M9066 = m9066(j, str);
                this.f15556 = c4179M9066;
                long jMo1165 = this.f15560.mo1165(c4179M9066);
                if (this.f15555) {
                    if (iMo1578 != 1 && this.f15567.ˌᵪ() != -1) {
                        this.f15559.f15658 = this.f15567.ˌᵪ();
                    }
                    ˏᵭᵔᵬ.ˇʼʤˎ(this.f15560);
                    return;
                }
                List list = (List) this.f15560.f1629.mo1416().get("ETag");
                str = (list == null || list.isEmpty()) ? null : (String) list.get(0);
                if (jMo1165 != -1) {
                    jMo1165 += j;
                    C3425 c3425 = this.f15565;
                    c3425.f12804.post(new RunnableC5409(c3425, 0));
                }
                long j2 = jMo1165;
                this.f15565.f12783 = C1248.m3791(this.f15560.f1629.mo1416());
                C0186 c0186 = this.f15560;
                C1248 c1248 = this.f15565.f12783;
                if (c1248 == null || (i = c1248.f5212) == -1) {
                    c4239 = c0186;
                } else {
                    c4239 = new C4239(c0186, i, this);
                    InterfaceC2154 interfaceC2154M7798 = this.f15565.m7798(new C2237(0, true));
                    this.f15564 = interfaceC2154M7798;
                    interfaceC2154M7798.mo4407(C3425.f12760);
                }
                this.f15567.ᵫᵮʾ(c4239, this.f15563, this.f15560.f1629.mo1416(), j, j2, this.f15566);
                if (this.f15565.f12783 != null && (interfaceC2689 = (InterfaceC2689) this.f15567.ᵿʗᵝʽ) != null) {
                    InterfaceC2689 interfaceC2689Mo1575 = interfaceC2689.mo1575();
                    if (interfaceC2689Mo1575 instanceof C2209) {
                        ((C2209) interfaceC2689Mo1575).f8683 = true;
                    }
                }
                if (this.f15558) {
                    ʽᵡ r8 = this.f15567;
                    long j3 = this.f15557;
                    InterfaceC2689 interfaceC26892 = (InterfaceC2689) r8.ᵿʗᵝʽ;
                    interfaceC26892.getClass();
                    interfaceC26892.mo1577(j, j3);
                    this.f15558 = false;
                }
                while (iMo1578 == 0 && !this.f15555) {
                    try {
                        C1790 c1790 = this.f15561;
                        synchronized (c1790) {
                            while (!c1790.f7196) {
                                c1790.f7195.getClass();
                                c1790.wait();
                            }
                        }
                        ʽᵡ r82 = this.f15567;
                        C4184 c4184 = this.f15559;
                        InterfaceC2689 interfaceC26893 = (InterfaceC2689) r82.ᵿʗᵝʽ;
                        interfaceC26893.getClass();
                        C1938 c1938 = (C1938) r82.ᵾᵬ;
                        c1938.getClass();
                        iMo1578 = interfaceC26893.mo1578(c1938, c4184);
                        long j4 = this.f15567.ˌᵪ();
                        if (j4 > this.f15565.f12777 + j) {
                            this.f15561.m5102();
                            C3425 c34252 = this.f15565;
                            c34252.f12804.post(c34252.f12766);
                            j = j4;
                        }
                    } catch (InterruptedException unused) {
                        throw new InterruptedIOException();
                    }
                }
                if (iMo1578 == 1) {
                    iMo1578 = 0;
                } else if (this.f15567.ˌᵪ() != -1) {
                    this.f15559.f15658 = this.f15567.ˌᵪ();
                }
                ˏᵭᵔᵬ.ˇʼʤˎ(this.f15560);
            } catch (Throwable th) {
                if (iMo1578 != 1 && this.f15567.ˌᵪ() != -1) {
                    this.f15559.f15658 = this.f15567.ˌᵪ();
                }
                ˏᵭᵔᵬ.ˇʼʤˎ(this.f15560);
                throw th;
            }
        }
    }

    @Override // defpackage.InterfaceC0452
    /* renamed from: ᵝᵵᵺ */
    public final void mo1782() {
        this.f15555 = true;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C4179 m9066(long j, String str) {
        Map mapM10079 = C3425.f12761;
        if (str != null && !str.startsWith("W/")) {
            C4782 c4782M4455 = AbstractC1530.m4455();
            c4782M4455.m10103(mapM10079.entrySet());
            c4782M4455.m10104("If-Range", str);
            mapM10079 = c4782M4455.m10079(false);
        }
        Map map = Collections.EMPTY_MAP;
        Uri uri = this.f15563;
        ᵛᵾˏ.ᵨᵳʝ(uri, "The uri must be set.");
        return new C4179(uri, 1, null, mapM10079, j, -1L, null, 6);
    }
}
