- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
441 lines
14 KiB
Java
441 lines
14 KiB
Java
package okio;
|
|
|
|
import android.support.v4.media.session.PlaybackStateCompat;
|
|
import csdk.gluads.Consts;
|
|
import java.io.EOFException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.charset.Charset;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public final class RealBufferedSource implements BufferedSource {
|
|
public final Buffer buffer = new Buffer();
|
|
public boolean closed;
|
|
public final Source source;
|
|
|
|
@Override // okio.BufferedSource, okio.BufferedSink
|
|
public Buffer buffer() {
|
|
return this.buffer;
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public Buffer getBuffer() {
|
|
return this.buffer;
|
|
}
|
|
|
|
@Override // java.nio.channels.Channel
|
|
public boolean isOpen() {
|
|
return !this.closed;
|
|
}
|
|
|
|
public RealBufferedSource(Source source) {
|
|
if (source == null) {
|
|
throw new NullPointerException("source == null");
|
|
}
|
|
this.source = source;
|
|
}
|
|
|
|
@Override // okio.Source
|
|
public long read(Buffer buffer, long j) {
|
|
if (buffer == null) {
|
|
throw new IllegalArgumentException("sink == null");
|
|
}
|
|
if (j < 0) {
|
|
throw new IllegalArgumentException("byteCount < 0: " + j);
|
|
}
|
|
if (this.closed) {
|
|
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
Buffer buffer2 = this.buffer;
|
|
if (buffer2.size == 0 && this.source.read(buffer2, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
|
return -1L;
|
|
}
|
|
return this.buffer.read(buffer, Math.min(j, this.buffer.size));
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public boolean exhausted() {
|
|
if (this.closed) {
|
|
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
return this.buffer.exhausted() && this.source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1;
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public void require(long j) {
|
|
if (!request(j)) {
|
|
throw new EOFException();
|
|
}
|
|
}
|
|
|
|
public boolean request(long j) {
|
|
Buffer buffer;
|
|
if (j < 0) {
|
|
throw new IllegalArgumentException("byteCount < 0: " + j);
|
|
}
|
|
if (this.closed) {
|
|
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
do {
|
|
buffer = this.buffer;
|
|
if (buffer.size >= j) {
|
|
return true;
|
|
}
|
|
} while (this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1);
|
|
return false;
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public byte readByte() {
|
|
require(1L);
|
|
return this.buffer.readByte();
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public ByteString readByteString(long j) {
|
|
require(j);
|
|
return this.buffer.readByteString(j);
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public int select(Options options) {
|
|
if (this.closed) {
|
|
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
do {
|
|
int selectPrefix = this.buffer.selectPrefix(options, true);
|
|
if (selectPrefix == -1) {
|
|
return -1;
|
|
}
|
|
if (selectPrefix != -2) {
|
|
this.buffer.skip(options.byteStrings[selectPrefix].size());
|
|
return selectPrefix;
|
|
}
|
|
} while (this.source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1);
|
|
return -1;
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public byte[] readByteArray() {
|
|
this.buffer.writeAll(this.source);
|
|
return this.buffer.readByteArray();
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public byte[] readByteArray(long j) {
|
|
require(j);
|
|
return this.buffer.readByteArray(j);
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public void readFully(byte[] bArr) {
|
|
try {
|
|
require(bArr.length);
|
|
this.buffer.readFully(bArr);
|
|
} catch (EOFException e) {
|
|
int i = 0;
|
|
while (true) {
|
|
Buffer buffer = this.buffer;
|
|
long j = buffer.size;
|
|
if (j > 0) {
|
|
int read = buffer.read(bArr, i, (int) j);
|
|
if (read == -1) {
|
|
throw new AssertionError();
|
|
}
|
|
i += read;
|
|
} else {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // java.nio.channels.ReadableByteChannel
|
|
public int read(ByteBuffer byteBuffer) {
|
|
Buffer buffer = this.buffer;
|
|
if (buffer.size == 0 && this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
|
return -1;
|
|
}
|
|
return this.buffer.read(byteBuffer);
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public long readAll(Sink sink) {
|
|
if (sink == null) {
|
|
throw new IllegalArgumentException("sink == null");
|
|
}
|
|
long j = 0;
|
|
while (this.source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1) {
|
|
long completeSegmentByteCount = this.buffer.completeSegmentByteCount();
|
|
if (completeSegmentByteCount > 0) {
|
|
j += completeSegmentByteCount;
|
|
sink.write(this.buffer, completeSegmentByteCount);
|
|
}
|
|
}
|
|
if (this.buffer.size() <= 0) {
|
|
return j;
|
|
}
|
|
long size = j + this.buffer.size();
|
|
Buffer buffer = this.buffer;
|
|
sink.write(buffer, buffer.size());
|
|
return size;
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public String readString(Charset charset) {
|
|
if (charset == null) {
|
|
throw new IllegalArgumentException("charset == null");
|
|
}
|
|
this.buffer.writeAll(this.source);
|
|
return this.buffer.readString(charset);
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public String readUtf8LineStrict() {
|
|
return readUtf8LineStrict(Long.MAX_VALUE);
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public String readUtf8LineStrict(long j) {
|
|
if (j < 0) {
|
|
throw new IllegalArgumentException("limit < 0: " + j);
|
|
}
|
|
long j2 = j == Long.MAX_VALUE ? Long.MAX_VALUE : j + 1;
|
|
long indexOf = indexOf((byte) 10, 0L, j2);
|
|
if (indexOf != -1) {
|
|
return this.buffer.readUtf8Line(indexOf);
|
|
}
|
|
if (j2 < Long.MAX_VALUE && request(j2) && this.buffer.getByte(j2 - 1) == 13 && request(1 + j2) && this.buffer.getByte(j2) == 10) {
|
|
return this.buffer.readUtf8Line(j2);
|
|
}
|
|
Buffer buffer = new Buffer();
|
|
Buffer buffer2 = this.buffer;
|
|
buffer2.copyTo(buffer, 0L, Math.min(32L, buffer2.size()));
|
|
throw new EOFException("\\n not found: limit=" + Math.min(this.buffer.size(), j) + " content=" + buffer.readByteString().hex() + (char) 8230);
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public short readShort() {
|
|
require(2L);
|
|
return this.buffer.readShort();
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public short readShortLe() {
|
|
require(2L);
|
|
return this.buffer.readShortLe();
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public int readInt() {
|
|
require(4L);
|
|
return this.buffer.readInt();
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public int readIntLe() {
|
|
require(4L);
|
|
return this.buffer.readIntLe();
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public long readDecimalLong() {
|
|
byte b;
|
|
require(1L);
|
|
int i = 0;
|
|
while (true) {
|
|
int i2 = i + 1;
|
|
if (!request(i2)) {
|
|
break;
|
|
}
|
|
b = this.buffer.getByte(i);
|
|
if ((b < 48 || b > 57) && !(i == 0 && b == 45)) {
|
|
break;
|
|
}
|
|
i = i2;
|
|
}
|
|
if (i == 0) {
|
|
throw new NumberFormatException(String.format("Expected leading [0-9] or '-' character but was %#x", Byte.valueOf(b)));
|
|
}
|
|
return this.buffer.readDecimalLong();
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:20:0x0031, code lost:
|
|
|
|
if (r0 == 0) goto L21;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:22:0x0047, code lost:
|
|
|
|
throw new java.lang.NumberFormatException(java.lang.String.format("Expected leading [0-9a-fA-F] character but was %#x", java.lang.Byte.valueOf(r2)));
|
|
*/
|
|
@Override // okio.BufferedSource
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public long readHexadecimalUnsignedLong() {
|
|
/*
|
|
r5 = this;
|
|
r0 = 1
|
|
r5.require(r0)
|
|
r0 = 0
|
|
L6:
|
|
int r1 = r0 + 1
|
|
long r2 = (long) r1
|
|
boolean r2 = r5.request(r2)
|
|
if (r2 == 0) goto L48
|
|
okio.Buffer r2 = r5.buffer
|
|
long r3 = (long) r0
|
|
byte r2 = r2.getByte(r3)
|
|
r3 = 48
|
|
if (r2 < r3) goto L1e
|
|
r3 = 57
|
|
if (r2 <= r3) goto L2f
|
|
L1e:
|
|
r3 = 97
|
|
if (r2 < r3) goto L26
|
|
r3 = 102(0x66, float:1.43E-43)
|
|
if (r2 <= r3) goto L2f
|
|
L26:
|
|
r3 = 65
|
|
if (r2 < r3) goto L31
|
|
r3 = 70
|
|
if (r2 <= r3) goto L2f
|
|
goto L31
|
|
L2f:
|
|
r0 = r1
|
|
goto L6
|
|
L31:
|
|
if (r0 == 0) goto L34
|
|
goto L48
|
|
L34:
|
|
java.lang.NumberFormatException r0 = new java.lang.NumberFormatException
|
|
java.lang.Byte r1 = java.lang.Byte.valueOf(r2)
|
|
java.lang.Object[] r1 = new java.lang.Object[]{r1}
|
|
java.lang.String r2 = "Expected leading [0-9a-fA-F] character but was %#x"
|
|
java.lang.String r1 = java.lang.String.format(r2, r1)
|
|
r0.<init>(r1)
|
|
throw r0
|
|
L48:
|
|
okio.Buffer r0 = r5.buffer
|
|
long r0 = r0.readHexadecimalUnsignedLong()
|
|
return r0
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: okio.RealBufferedSource.readHexadecimalUnsignedLong():long");
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public void skip(long j) {
|
|
if (this.closed) {
|
|
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
while (j > 0) {
|
|
Buffer buffer = this.buffer;
|
|
if (buffer.size == 0 && this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
|
throw new EOFException();
|
|
}
|
|
long min = Math.min(j, this.buffer.size());
|
|
this.buffer.skip(min);
|
|
j -= min;
|
|
}
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public long indexOf(byte b) {
|
|
return indexOf(b, 0L, Long.MAX_VALUE);
|
|
}
|
|
|
|
public long indexOf(byte b, long j, long j2) {
|
|
if (this.closed) {
|
|
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
if (j < 0 || j2 < j) {
|
|
throw new IllegalArgumentException(String.format("fromIndex=%s toIndex=%s", Long.valueOf(j), Long.valueOf(j2)));
|
|
}
|
|
while (j < j2) {
|
|
long indexOf = this.buffer.indexOf(b, j, j2);
|
|
if (indexOf == -1) {
|
|
Buffer buffer = this.buffer;
|
|
long j3 = buffer.size;
|
|
if (j3 >= j2 || this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
|
break;
|
|
}
|
|
j = Math.max(j, j3);
|
|
} else {
|
|
return indexOf;
|
|
}
|
|
}
|
|
return -1L;
|
|
}
|
|
|
|
@Override // okio.BufferedSource
|
|
public InputStream inputStream() {
|
|
return new InputStream() { // from class: okio.RealBufferedSource.1
|
|
@Override // java.io.InputStream
|
|
public int read() {
|
|
RealBufferedSource realBufferedSource = RealBufferedSource.this;
|
|
if (realBufferedSource.closed) {
|
|
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
Buffer buffer = realBufferedSource.buffer;
|
|
if (buffer.size == 0 && realBufferedSource.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
|
return -1;
|
|
}
|
|
return RealBufferedSource.this.buffer.readByte() & 255;
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read(byte[] bArr, int i, int i2) {
|
|
if (RealBufferedSource.this.closed) {
|
|
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
Util.checkOffsetAndCount(bArr.length, i, i2);
|
|
RealBufferedSource realBufferedSource = RealBufferedSource.this;
|
|
Buffer buffer = realBufferedSource.buffer;
|
|
if (buffer.size == 0 && realBufferedSource.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
|
return -1;
|
|
}
|
|
return RealBufferedSource.this.buffer.read(bArr, i, i2);
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int available() {
|
|
RealBufferedSource realBufferedSource = RealBufferedSource.this;
|
|
if (realBufferedSource.closed) {
|
|
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
|
|
}
|
|
return (int) Math.min(realBufferedSource.buffer.size, 2147483647L);
|
|
}
|
|
|
|
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() {
|
|
RealBufferedSource.this.close();
|
|
}
|
|
|
|
public String toString() {
|
|
return RealBufferedSource.this + ".inputStream()";
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() {
|
|
if (this.closed) {
|
|
return;
|
|
}
|
|
this.closed = true;
|
|
this.source.close();
|
|
this.buffer.clear();
|
|
}
|
|
|
|
@Override // okio.Source
|
|
public Timeout timeout() {
|
|
return this.source.timeout();
|
|
}
|
|
|
|
public String toString() {
|
|
return "buffer(" + this.source + ")";
|
|
}
|
|
}
|