package o;

import java.io.IOException;
import java.net.ProtocolException;
import java.util.concurrent.TimeUnit;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.xF, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2890xF extends AbstractC2605uF {

    /* renamed from: o, reason: collision with root package name */
    public long f786o;
    public final /* synthetic */ C2689v7 p;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2890xF(C2689v7 c2689v7, long j) {
        super(c2689v7);
        this.p = c2689v7;
        this.f786o = j;
        if (j == 0) {
            b();
        }
    }

    @Override // o.AbstractC2605uF, o.T90
    public final long C(long j, C0732af c0732af) throws IOException {
        if (j < 0) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("byteCount < 0: ", j).toString());
        }
        if (this.m) {
            throw new IllegalStateException("closed");
        }
        long j2 = this.f786o;
        if (j2 == 0) {
            return -1L;
        }
        long jC = super.C(Math.min(j2, j), c0732af);
        if (jC == -1) {
            ((C2486t00) this.p.c).k();
            ProtocolException protocolException = new ProtocolException("unexpected end of stream");
            b();
            throw protocolException;
        }
        long j3 = this.f786o - jC;
        this.f786o = j3;
        if (j3 == 0) {
            b();
        }
        return jC;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        boolean zT;
        if (this.m) {
            return;
        }
        if (this.f786o != 0) {
            TimeUnit timeUnit = TimeUnit.MILLISECONDS;
            try {
                zT = AbstractC2264qi0.t(this, 100);
            } catch (IOException unused) {
                zT = false;
            }
            if (!zT) {
                ((C2486t00) this.p.c).k();
                b();
            }
        }
        this.m = true;
    }
}
