package defpackage;

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

/* JADX INFO: renamed from: ᵺʽ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5113 extends AbstractC1004 {

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

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final /* synthetic */ C2376 f19264;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C5113(C2376 c2376, C1695 c1695, long j) {
        super(c2376, c1695);
        this.f19264 = c2376;
        this.f19263 = j;
        if (j == 0) {
            m3326(C0661.f3101);
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        boolean zM3673;
        if (this.f4378) {
            return;
        }
        if (this.f19263 != 0) {
            try {
                zM3673 = AbstractC1190.m3673(this, 100);
            } catch (IOException unused) {
                zM3673 = false;
            }
            if (!zM3673) {
                this.f19264.f9300.mo8822();
                m3326(C2376.f9299);
            }
        }
        this.f4378 = true;
    }

    @Override // defpackage.AbstractC1004, defpackage.InterfaceC3906
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ */
    public final long mo1490(C4903 c4903, long j) throws IOException {
        if (this.f4378) {
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("closed");
            return 0L;
        }
        long j2 = this.f19263;
        if (j2 == 0) {
            return -1L;
        }
        long jMo1490 = super.mo1490(c4903, Math.min(j2, 8192L));
        if (jMo1490 == -1) {
            this.f19264.f9300.mo8822();
            ProtocolException protocolException = new ProtocolException("unexpected end of stream");
            m3326(C2376.f9299);
            throw protocolException;
        }
        long j3 = this.f19263 - jMo1490;
        this.f19263 = j3;
        if (j3 == 0) {
            m3326(C0661.f3101);
        }
        return jMo1490;
    }
}
