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 C1769 implements InterfaceC1636 {

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

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

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final /* synthetic */ C0764 f7091;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final boolean f7092;

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

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public boolean f7094;

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

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public boolean f7096;

    public C1769(C0764 c0764, InterfaceC1636 interfaceC1636, long j, boolean z) {
        this.f7091 = c0764;
        this.f7090 = interfaceC1636;
        this.f7093 = j;
        this.f7092 = z;
        this.f7096 = z;
    }

    @Override // defpackage.InterfaceC1636, java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        if (this.f7089) {
            return;
        }
        this.f7089 = true;
        long j = this.f7093;
        if (j != -1 && this.f7095 != j) {
            throw new ProtocolException("unexpected end of stream");
        }
        try {
            m4906();
            m4904(null);
        } catch (IOException e) {
            throw m4904(e);
        }
    }

    @Override // defpackage.InterfaceC1636, java.io.Flushable
    public final void flush() throws IOException {
        try {
            m4905();
        } catch (IOException e) {
            throw m4904(e);
        }
    }

    public final String toString() {
        return C1769.class.getSimpleName() + '(' + this.f7090 + ')';
    }

    @Override // defpackage.InterfaceC1636
    /* JADX INFO: renamed from: ˀᵭ */
    public final void mo1843(C4903 c4903, long j) throws IOException {
        if (this.f7089) {
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("closed");
            return;
        }
        long j2 = this.f7093;
        if (j2 != -1 && this.f7095 + j > j2) {
            throw new ProtocolException("expected " + this.f7093 + " bytes but received " + (this.f7095 + j));
        }
        try {
            if (this.f7096) {
                this.f7096 = false;
                ((C4778) this.f7091.f3428).f18181.getClass();
            }
            this.f7090.mo1843(c4903, j);
            this.f7095 += j;
        } catch (IOException e) {
            throw m4904(e);
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final IOException m4904(IOException iOException) {
        if (this.f7094) {
            return iOException;
        }
        this.f7094 = true;
        return C0764.m2737(this.f7091, this.f7092, iOException, 4);
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final void m4905() {
        this.f7090.flush();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m4906() {
        this.f7090.close();
    }

    @Override // defpackage.InterfaceC1636
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final C2466 mo1844() {
        return this.f7090.mo1844();
    }
}
