package defpackage;

import java.io.IOException;
import java.net.ProtocolException;

/* renamed from: ᵚˏᵰᐧ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2665 extends AbstractC5412 {

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

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public final /* synthetic */ C4699 f10348;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public boolean f10349;

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

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public boolean f10351;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public long f10352;

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2665(C4699 c4699, InterfaceC3226 interfaceC3226, long j, boolean z) {
        super(interfaceC3226);
        this.f10348 = c4699;
        this.f10350 = j;
        this.f10353 = z;
        this.f10351 = true;
        if (j == 0) {
            m6661(null);
        }
    }

    @Override // defpackage.AbstractC5412, java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        if (this.f10347) {
            return;
        }
        this.f10347 = true;
        try {
            super.close();
            m6661(null);
        } catch (IOException e) {
            throw m6661(e);
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final IOException m6661(IOException iOException) {
        if (this.f10349) {
            return iOException;
        }
        this.f10349 = true;
        if (iOException == null && this.f10351) {
            this.f10351 = false;
        }
        return C4699.m9878(this.f10348, this.f10353, iOException, 8);
    }

    @Override // defpackage.InterfaceC3226
    /* renamed from: ᵳٴᵶ */
    public final long mo2229(C0963 c0963, long j) throws IOException {
        C4699 c4699 = this.f10348;
        if (this.f10347) {
            ᵹˉᵞ.ᵳٴᵶ("closed");
            return 0L;
        }
        try {
            long jMo2229 = this.f20276.mo2229(c0963, 8192L);
            if (this.f10351) {
                this.f10351 = false;
            }
            if (jMo2229 == -1) {
                m6661(null);
                return -1L;
            }
            long j2 = this.f10352 + jMo2229;
            long j3 = this.f10350;
            if (j3 == -1 || j2 <= j3) {
                this.f10352 = j2;
                if (((InterfaceC4906) c4699.f17374).mo1102()) {
                    m6661(null);
                }
                return jMo2229;
            }
            throw new ProtocolException("expected " + j3 + " bytes but received " + j2);
        } catch (IOException e) {
            throw m6661(e);
        }
    }
}
