package okhttp3.n0.http2;

import io.netty.handler.codec.rtsp.RtspHeaders;
import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import kotlin.Metadata;
import kotlin.jvm.internal.o;
import kotlin.ranges.IntProgression;
import kotlin.ranges.j;
import okhttp3.n0.c;
import okhttp3.n0.http2.Hpack;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import okio.Source;
import okio.Timeout;

/* JADX INFO: renamed from: y.n0.j.n, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\f\u0018\u0000 #2\u00020\u0001:\u0003#$%B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\b\u0010\u000b\u001a\u00020\fH\u0016J\u0016\u0010\r\u001a\u00020\u00052\u0006\u0010\u000e\u001a\u00020\u00052\u0006\u0010\u000f\u001a\u00020\u0010J\u000e\u0010\u0011\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u0010J(\u0010\u0012\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u0017\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J.\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00192\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u001b\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001c\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001d\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J\u0018\u0010\u001e\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001e\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001f\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010 \u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010!\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\"\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lokhttp3/internal/http2/Http2Reader;", "Ljava/io/Closeable;", "source", "Lokio/BufferedSource;", "client", "", "(Lokio/BufferedSource;Z)V", "continuation", "Lokhttp3/internal/http2/Http2Reader$ContinuationSource;", "hpackReader", "Lokhttp3/internal/http2/Hpack$Reader;", "close", "", "nextFrame", "requireSettings", "handler", "Lokhttp3/internal/http2/Http2Reader$Handler;", "readConnectionPreface", "readData", "length", "", "flags", "streamId", "readGoAway", "readHeaderBlock", "", "Lokhttp3/internal/http2/Header;", "padding", "readHeaders", "readPing", "readPriority", "readPushPromise", "readRstStream", "readSettings", "readWindowUpdate", "Companion", "ContinuationSource", "Handler", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class Http2Reader implements Closeable {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final Http2Reader f9973f = null;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final Logger f9974m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final BufferedSource f9975n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final boolean f9976o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final a f9977p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final Hpack.a f9978q;

    /* JADX INFO: renamed from: y.n0.j.n$a */
    @Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0011\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0017\u001a\u00020\u0018H\u0016J\u0018\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\u001aH\u0016J\b\u0010\u001e\u001a\u00020\u0018H\u0002J\b\u0010\u001f\u001a\u00020 H\u0016R\u001a\u0010\u0005\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0007\u0010\b\"\u0004\b\t\u0010\nR\u001a\u0010\u000b\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\f\u0010\b\"\u0004\b\r\u0010\nR\u001a\u0010\u000e\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\b\"\u0004\b\u0010\u0010\nR\u001a\u0010\u0011\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0012\u0010\b\"\u0004\b\u0013\u0010\nR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\u0014\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0015\u0010\b\"\u0004\b\u0016\u0010\n¨\u0006!"}, d2 = {"Lokhttp3/internal/http2/Http2Reader$ContinuationSource;", "Lokio/Source;", "source", "Lokio/BufferedSource;", "(Lokio/BufferedSource;)V", "flags", "", "getFlags", "()I", "setFlags", "(I)V", "left", "getLeft", "setLeft", "length", "getLength", "setLength", "padding", "getPadding", "setPadding", "streamId", "getStreamId", "setStreamId", "close", "", "read", "", "sink", "Lokio/Buffer;", "byteCount", "readContinuationHeader", RtspHeaders.Values.TIMEOUT, "Lokio/Timeout;", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class a implements Source {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final BufferedSource f9979f;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public int f9980m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        public int f9981n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        public int f9982o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public int f9983p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public int f9984q;

        public a(BufferedSource bufferedSource) {
            o.f(bufferedSource, "source");
            this.f9979f = bufferedSource;
        }

        @Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
        public void close() {
        }

        @Override // okio.Source
        public long r(Buffer buffer, long j2) throws IOException {
            int i2;
            int i3;
            o.f(buffer, "sink");
            do {
                int i4 = this.f9983p;
                if (i4 != 0) {
                    long jR = this.f9979f.r(buffer, Math.min(j2, i4));
                    if (jR == -1) {
                        return -1L;
                    }
                    this.f9983p -= (int) jR;
                    return jR;
                }
                this.f9979f.skip(this.f9984q);
                this.f9984q = 0;
                if ((this.f9981n & 4) != 0) {
                    return -1L;
                }
                i2 = this.f9982o;
                int iU = c.u(this.f9979f);
                this.f9983p = iU;
                this.f9980m = iU;
                int i5 = this.f9979f.readByte() & 255;
                this.f9981n = this.f9979f.readByte() & 255;
                Http2Reader http2Reader = Http2Reader.f9973f;
                Logger logger = Http2Reader.f9974m;
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine(Http2.a.b(true, this.f9982o, this.f9980m, i5, this.f9981n));
                }
                i3 = this.f9979f.readInt() & Integer.MAX_VALUE;
                this.f9982o = i3;
                if (i5 != 9) {
                    throw new IOException(i5 + " != TYPE_CONTINUATION");
                }
            } while (i3 == i2);
            throw new IOException("TYPE_CONTINUATION streamId changed");
        }

        @Override // okio.Source
        /* JADX INFO: renamed from: timeout */
        public Timeout getF10138m() {
            return this.f9979f.getF10138m();
        }
    }

    /* JADX INFO: renamed from: y.n0.j.n$b */
    @Metadata(d1 = {"\u0000X\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u0003\bf\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H&J8\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\b2\u0006\u0010\f\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\u000eH&J(\u0010\u000f\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0012\u001a\u00020\u00132\u0006\u0010\u0014\u001a\u00020\u0006H&J \u0010\u0015\u001a\u00020\u00032\u0006\u0010\u0016\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\nH&J.\u0010\u001a\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u001b\u001a\u00020\u00062\f\u0010\u001c\u001a\b\u0012\u0004\u0012\u00020\u001e0\u001dH&J \u0010\u001f\u001a\u00020\u00032\u0006\u0010 \u001a\u00020\u00112\u0006\u0010!\u001a\u00020\u00062\u0006\u0010\"\u001a\u00020\u0006H&J(\u0010#\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010$\u001a\u00020\u00062\u0006\u0010%\u001a\u00020\u00062\u0006\u0010&\u001a\u00020\u0011H&J&\u0010'\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010(\u001a\u00020\u00062\f\u0010)\u001a\b\u0012\u0004\u0012\u00020\u001e0\u001dH&J\u0018\u0010*\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u0018H&J\u0018\u0010+\u001a\u00020\u00032\u0006\u0010,\u001a\u00020\u00112\u0006\u0010+\u001a\u00020-H&J\u0018\u0010.\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010/\u001a\u00020\u000eH&¨\u00060"}, d2 = {"Lokhttp3/internal/http2/Http2Reader$Handler;", "", "ackSettings", "", "alternateService", "streamId", "", "origin", "", "protocol", "Lokio/ByteString;", "host", RtspHeaders.Values.PORT, "maxAge", "", "data", "inFinished", "", "source", "Lokio/BufferedSource;", "length", "goAway", "lastGoodStreamId", "errorCode", "Lokhttp3/internal/http2/ErrorCode;", "debugData", "headers", "associatedStreamId", "headerBlock", "", "Lokhttp3/internal/http2/Header;", "ping", "ack", "payload1", "payload2", "priority", "streamDependency", "weight", "exclusive", "pushPromise", "promisedStreamId", "requestHeaders", "rstStream", "settings", "clearPrevious", "Lokhttp3/internal/http2/Settings;", "windowUpdate", "windowSizeIncrement", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public interface b {
        void a();

        void b(boolean z2, Settings settings);

        void c(boolean z2, int i2, int i3, List<Header> list);

        void d(int i2, long j2);

        void e(boolean z2, int i2, BufferedSource bufferedSource, int i3);

        void h(boolean z2, int i2, int i3);

        void i(int i2, int i3, int i4, boolean z2);

        void j(int i2, ErrorCode errorCode);

        void k(int i2, int i3, List<Header> list);

        void l(int i2, ErrorCode errorCode, ByteString byteString);
    }

    static {
        Logger logger = Logger.getLogger(Http2.class.getName());
        o.e(logger, "getLogger(Http2::class.java.name)");
        f9974m = logger;
    }

    public Http2Reader(BufferedSource bufferedSource, boolean z2) {
        o.f(bufferedSource, "source");
        this.f9975n = bufferedSource;
        this.f9976o = z2;
        a aVar = new a(bufferedSource);
        this.f9977p = aVar;
        this.f9978q = new Hpack.a(aVar, 4096, 0, 4);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r10v2 */
    /* JADX WARN: Type inference failed for: r10v3 */
    /* JADX WARN: Type inference failed for: r10v4 */
    /* JADX WARN: Type inference failed for: r5v2 */
    /* JADX WARN: Type inference failed for: r5v3 */
    /* JADX WARN: Type inference failed for: r5v6 */
    /* JADX WARN: Type inference failed for: r8v2 */
    /* JADX WARN: Type inference failed for: r8v3 */
    /* JADX WARN: Type inference failed for: r8v4 */
    public final boolean a(boolean z2, b bVar) throws IOException {
        ErrorCode errorCode;
        int i2;
        ErrorCode errorCode2;
        o.f(bVar, "handler");
        int i3 = 0;
        int i4 = 0;
        int i5 = 0;
        try {
            this.f9975n.t(9L);
            int iU = c.u(this.f9975n);
            if (iU > 16384) {
                throw new IOException(o.l("FRAME_SIZE_ERROR: ", Integer.valueOf(iU)));
            }
            int i6 = this.f9975n.readByte() & 255;
            int i7 = this.f9975n.readByte() & 255;
            int i8 = this.f9975n.readInt() & Integer.MAX_VALUE;
            Logger logger = f9974m;
            if (logger.isLoggable(Level.FINE)) {
                logger.fine(Http2.a.b(true, i8, iU, i6, i7));
            }
            if (z2 && i6 != 4) {
                throw new IOException(o.l("Expected a SETTINGS frame but was ", Http2.a.a(i6)));
            }
            switch (i6) {
                case 0:
                    if (i8 == 0) {
                        throw new IOException("PROTOCOL_ERROR: TYPE_DATA streamId == 0");
                    }
                    boolean z3 = (i7 & 1) != 0;
                    if (((i7 & 32) != 0) == true) {
                        throw new IOException("PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA");
                    }
                    int i9 = i7 & 8;
                    if (i9 != 0) {
                        byte b2 = this.f9975n.readByte();
                        byte[] bArr = c.a;
                        i3 = b2 & 255;
                    }
                    if (i9 != 0) {
                        iU--;
                    }
                    if (i3 > iU) {
                        throw new IOException(g.a.a.a.a.o("PROTOCOL_ERROR padding ", i3, " > remaining length ", iU));
                    }
                    bVar.e(z3, i8, this.f9975n, iU - i3);
                    this.f9975n.skip(i3);
                    return true;
                case 1:
                    if (i8 == 0) {
                        throw new IOException("PROTOCOL_ERROR: TYPE_HEADERS streamId == 0");
                    }
                    boolean z4 = (i7 & 1) != 0;
                    int i10 = i7 & 8;
                    if (i10 != 0) {
                        byte b3 = this.f9975n.readByte();
                        byte[] bArr2 = c.a;
                        i5 = b3 & 255;
                    }
                    if ((i7 & 32) != 0) {
                        e(bVar, i8);
                        iU -= 5;
                    }
                    if (i10 != 0) {
                        iU--;
                    }
                    if (i5 > iU) {
                        throw new IOException(g.a.a.a.a.o("PROTOCOL_ERROR padding ", i5, " > remaining length ", iU));
                    }
                    bVar.c(z4, i8, -1, d(iU - i5, i5, i7, i8));
                    return true;
                case 2:
                    if (iU != 5) {
                        throw new IOException(g.a.a.a.a.n("TYPE_PRIORITY length: ", iU, " != 5"));
                    }
                    if (i8 == 0) {
                        throw new IOException("TYPE_PRIORITY streamId == 0");
                    }
                    e(bVar, i8);
                    return true;
                case 3:
                    if (iU != 4) {
                        throw new IOException(g.a.a.a.a.n("TYPE_RST_STREAM length: ", iU, " != 4"));
                    }
                    if (i8 == 0) {
                        throw new IOException("TYPE_RST_STREAM streamId == 0");
                    }
                    int i11 = this.f9975n.readInt();
                    ErrorCode[] errorCodeArrValues = ErrorCode.values();
                    int i12 = 0;
                    while (true) {
                        if (i12 < 14) {
                            errorCode = errorCodeArrValues[i12];
                            if ((errorCode.B == i11) == false) {
                                i12++;
                            }
                        } else {
                            errorCode = null;
                        }
                    }
                    if (errorCode == null) {
                        throw new IOException(o.l("TYPE_RST_STREAM unexpected error code: ", Integer.valueOf(i11)));
                    }
                    bVar.j(i8, errorCode);
                    return true;
                case 4:
                    if (i8 != 0) {
                        throw new IOException("TYPE_SETTINGS streamId != 0");
                    }
                    if ((i7 & 1) != 0) {
                        if (iU != 0) {
                            throw new IOException("FRAME_SIZE_ERROR ack frame should be empty!");
                        }
                        bVar.a();
                    } else {
                        if (iU % 6 != 0) {
                            throw new IOException(o.l("TYPE_SETTINGS length % 6 != 0: ", Integer.valueOf(iU)));
                        }
                        Settings settings = new Settings();
                        IntProgression intProgressionD = j.d(j.e(0, iU), 6);
                        int i13 = intProgressionD.f6199f;
                        int i14 = intProgressionD.f6200m;
                        int i15 = intProgressionD.f6201n;
                        if ((i15 > 0 && i13 <= i14) || (i15 < 0 && i14 <= i13)) {
                            while (true) {
                                int i16 = i13 + i15;
                                short s2 = this.f9975n.readShort();
                                byte[] bArr3 = c.a;
                                int i17 = s2 & 65535;
                                i2 = this.f9975n.readInt();
                                if (i17 != 2) {
                                    if (i17 == 3) {
                                        i17 = 4;
                                    } else if (i17 == 4) {
                                        i17 = 7;
                                        if (i2 < 0) {
                                            throw new IOException("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1");
                                        }
                                    } else if (i17 == 5 && (i2 < 16384 || i2 > 16777215)) {
                                    }
                                } else if (i2 != 0 && i2 != 1) {
                                    throw new IOException("PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1");
                                }
                                settings.c(i17, i2);
                                if (i13 != i14) {
                                    i13 = i16;
                                }
                            }
                            throw new IOException(o.l("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: ", Integer.valueOf(i2)));
                        }
                        bVar.b(false, settings);
                    }
                    return true;
                case 5:
                    if (i8 == 0) {
                        throw new IOException("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0");
                    }
                    int i18 = i7 & 8;
                    if (i18 != 0) {
                        byte b4 = this.f9975n.readByte();
                        byte[] bArr4 = c.a;
                        i4 = b4 & 255;
                    }
                    int i19 = this.f9975n.readInt() & Integer.MAX_VALUE;
                    int i20 = iU - 4;
                    if (i18 != 0) {
                        i20--;
                    }
                    if (i4 > i20) {
                        throw new IOException(g.a.a.a.a.o("PROTOCOL_ERROR padding ", i4, " > remaining length ", i20));
                    }
                    bVar.k(i8, i19, d(i20 - i4, i4, i7, i8));
                    return true;
                case 6:
                    if (iU != 8) {
                        throw new IOException(o.l("TYPE_PING length != 8: ", Integer.valueOf(iU)));
                    }
                    if (i8 != 0) {
                        throw new IOException("TYPE_PING streamId != 0");
                    }
                    bVar.h((i7 & 1) != 0, this.f9975n.readInt(), this.f9975n.readInt());
                    return true;
                case 7:
                    if (iU < 8) {
                        throw new IOException(o.l("TYPE_GOAWAY length < 8: ", Integer.valueOf(iU)));
                    }
                    if (i8 != 0) {
                        throw new IOException("TYPE_GOAWAY streamId != 0");
                    }
                    int i21 = this.f9975n.readInt();
                    int i22 = this.f9975n.readInt();
                    int i23 = iU - 8;
                    ErrorCode[] errorCodeArrValues2 = ErrorCode.values();
                    int i24 = 0;
                    while (true) {
                        if (i24 < 14) {
                            errorCode2 = errorCodeArrValues2[i24];
                            if ((errorCode2.B == i22) == false) {
                                i24++;
                            }
                        } else {
                            errorCode2 = null;
                        }
                    }
                    if (errorCode2 == null) {
                        throw new IOException(o.l("TYPE_GOAWAY unexpected error code: ", Integer.valueOf(i22)));
                    }
                    ByteString byteStringB = ByteString.f10121m;
                    if (i23 > 0) {
                        byteStringB = this.f9975n.b(i23);
                    }
                    bVar.l(i21, errorCode2, byteStringB);
                    return true;
                case 8:
                    if (iU != 4) {
                        throw new IOException(o.l("TYPE_WINDOW_UPDATE length !=4: ", Integer.valueOf(iU)));
                    }
                    int i25 = this.f9975n.readInt();
                    byte[] bArr5 = c.a;
                    long j2 = ((long) i25) & 2147483647L;
                    if (j2 == 0) {
                        throw new IOException("windowSizeIncrement was 0");
                    }
                    bVar.d(i8, j2);
                    return true;
                default:
                    this.f9975n.skip(iU);
                    return true;
            }
        } catch (EOFException unused) {
            return false;
        }
    }

    public final void c(b bVar) throws IOException {
        o.f(bVar, "handler");
        if (this.f9976o) {
            if (!a(true, bVar)) {
                throw new IOException("Required SETTINGS preface not received");
            }
            return;
        }
        BufferedSource bufferedSource = this.f9975n;
        ByteString byteString = Http2.f9903b;
        ByteString byteStringB = bufferedSource.b(byteString.g());
        Logger logger = f9974m;
        if (logger.isLoggable(Level.FINE)) {
            logger.fine(c.j(o.l("<< CONNECTION ", byteStringB.h()), new Object[0]));
        }
        if (!o.a(byteString, byteStringB)) {
            throw new IOException(o.l("Expected a connection header but was ", byteStringB.q()));
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        this.f9975n.close();
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x003c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final java.util.List<okhttp3.n0.http2.Header> d(int r3, int r4, int r5, int r6) throws java.io.IOException {
        /*
            Method dump skipped, instruction units count: 314
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: okhttp3.n0.http2.Http2Reader.d(int, int, int, int):java.util.List");
    }

    public final void e(b bVar, int i2) {
        int i3 = this.f9975n.readInt();
        boolean z2 = (Integer.MIN_VALUE & i3) != 0;
        byte b2 = this.f9975n.readByte();
        byte[] bArr = c.a;
        bVar.i(i2, i3 & Integer.MAX_VALUE, (b2 & 255) + 1, z2);
    }
}
