package p4;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import p5.C2740j;
import p5.J;
import p5.P;
import p5.S;

/* JADX INFO: renamed from: p4.f, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C2727f implements P {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public byte f23020c;

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public short f23023f;

    public C2727f(J j4) {
        this.f23018a = j4;
    }

    @Override // p5.P
    public final long read(C2740j c2740j, long j4) throws IOException {
        int i6;
        int iD;
        do {
            int i7 = this.f23022e;
            J j6 = this.f23018a;
            if (i7 == 0) {
                j6.B(this.f23023f);
                this.f23023f = (short) 0;
                if ((this.f23020c & 4) == 0) {
                    i6 = this.f23021d;
                    int iA = j.a(j6);
                    this.f23022e = iA;
                    this.f23019b = iA;
                    byte b5 = (byte) (j6.b() & 255);
                    this.f23020c = (byte) (j6.b() & 255);
                    Logger logger = j.f23035a;
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine(AbstractC2728g.a(true, this.f23021d, this.f23019b, b5, this.f23020c));
                    }
                    iD = j6.d() & Integer.MAX_VALUE;
                    this.f23021d = iD;
                    if (b5 != 9) {
                        j.c("%s != TYPE_CONTINUATION", Byte.valueOf(b5));
                        throw null;
                    }
                }
            } else {
                long j7 = j6.read(c2740j, Math.min(j4, i7));
                if (j7 != -1) {
                    this.f23022e -= (int) j7;
                    return j7;
                }
            }
            return -1L;
        } while (iD == i6);
        j.c("TYPE_CONTINUATION streamId changed", new Object[0]);
        throw null;
    }

    @Override // p5.P
    public final S timeout() {
        return this.f23018a.f23058a.timeout();
    }

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