Initial commit
This commit is contained in:
297
sources/okio/AsyncTimeout.java
Normal file
297
sources/okio/AsyncTimeout.java
Normal file
@@ -0,0 +1,297 @@
|
||||
package okio;
|
||||
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AsyncTimeout extends Timeout {
|
||||
private static final long IDLE_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(60);
|
||||
private static final long IDLE_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(IDLE_TIMEOUT_MILLIS);
|
||||
private static final int TIMEOUT_WRITE_SIZE = 65536;
|
||||
static AsyncTimeout head;
|
||||
private boolean inQueue;
|
||||
private AsyncTimeout next;
|
||||
private long timeoutAt;
|
||||
|
||||
private static final class Watchdog extends Thread {
|
||||
Watchdog() {
|
||||
super("Okio Watchdog");
|
||||
setDaemon(true);
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:19:0x0015, code lost:
|
||||
|
||||
r1.timedOut();
|
||||
*/
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void run() {
|
||||
/*
|
||||
r3 = this;
|
||||
L0:
|
||||
java.lang.Class<okio.AsyncTimeout> r0 = okio.AsyncTimeout.class
|
||||
monitor-enter(r0) // Catch: java.lang.InterruptedException -> L0
|
||||
okio.AsyncTimeout r1 = okio.AsyncTimeout.awaitTimeout() // Catch: java.lang.Throwable -> L19
|
||||
if (r1 != 0) goto Lb
|
||||
monitor-exit(r0) // Catch: java.lang.Throwable -> L19
|
||||
goto L0
|
||||
Lb:
|
||||
okio.AsyncTimeout r2 = okio.AsyncTimeout.head // Catch: java.lang.Throwable -> L19
|
||||
if (r1 != r2) goto L14
|
||||
r1 = 0
|
||||
okio.AsyncTimeout.head = r1 // Catch: java.lang.Throwable -> L19
|
||||
monitor-exit(r0) // Catch: java.lang.Throwable -> L19
|
||||
return
|
||||
L14:
|
||||
monitor-exit(r0) // Catch: java.lang.Throwable -> L19
|
||||
r1.timedOut() // Catch: java.lang.InterruptedException -> L0
|
||||
goto L0
|
||||
L19:
|
||||
r1 = move-exception
|
||||
monitor-exit(r0) // Catch: java.lang.Throwable -> L19
|
||||
throw r1 // Catch: java.lang.InterruptedException -> L0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: okio.AsyncTimeout.Watchdog.run():void");
|
||||
}
|
||||
}
|
||||
|
||||
static AsyncTimeout awaitTimeout() throws InterruptedException {
|
||||
AsyncTimeout asyncTimeout = head.next;
|
||||
if (asyncTimeout == null) {
|
||||
long nanoTime = System.nanoTime();
|
||||
AsyncTimeout.class.wait(IDLE_TIMEOUT_MILLIS);
|
||||
if (head.next != null || System.nanoTime() - nanoTime < IDLE_TIMEOUT_NANOS) {
|
||||
return null;
|
||||
}
|
||||
return head;
|
||||
}
|
||||
long remainingNanos = asyncTimeout.remainingNanos(System.nanoTime());
|
||||
if (remainingNanos > 0) {
|
||||
long j = remainingNanos / 1000000;
|
||||
AsyncTimeout.class.wait(j, (int) (remainingNanos - (1000000 * j)));
|
||||
return null;
|
||||
}
|
||||
head.next = asyncTimeout.next;
|
||||
asyncTimeout.next = null;
|
||||
return asyncTimeout;
|
||||
}
|
||||
|
||||
private static synchronized boolean cancelScheduledTimeout(AsyncTimeout asyncTimeout) {
|
||||
synchronized (AsyncTimeout.class) {
|
||||
for (AsyncTimeout asyncTimeout2 = head; asyncTimeout2 != null; asyncTimeout2 = asyncTimeout2.next) {
|
||||
if (asyncTimeout2.next == asyncTimeout) {
|
||||
asyncTimeout2.next = asyncTimeout.next;
|
||||
asyncTimeout.next = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private long remainingNanos(long j) {
|
||||
return this.timeoutAt - j;
|
||||
}
|
||||
|
||||
private static synchronized void scheduleTimeout(AsyncTimeout asyncTimeout, long j, boolean z) {
|
||||
synchronized (AsyncTimeout.class) {
|
||||
if (head == null) {
|
||||
head = new AsyncTimeout();
|
||||
new Watchdog().start();
|
||||
}
|
||||
long nanoTime = System.nanoTime();
|
||||
if (j != 0 && z) {
|
||||
asyncTimeout.timeoutAt = Math.min(j, asyncTimeout.deadlineNanoTime() - nanoTime) + nanoTime;
|
||||
} else if (j != 0) {
|
||||
asyncTimeout.timeoutAt = j + nanoTime;
|
||||
} else {
|
||||
if (!z) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
asyncTimeout.timeoutAt = asyncTimeout.deadlineNanoTime();
|
||||
}
|
||||
long remainingNanos = asyncTimeout.remainingNanos(nanoTime);
|
||||
AsyncTimeout asyncTimeout2 = head;
|
||||
while (asyncTimeout2.next != null && remainingNanos >= asyncTimeout2.next.remainingNanos(nanoTime)) {
|
||||
asyncTimeout2 = asyncTimeout2.next;
|
||||
}
|
||||
asyncTimeout.next = asyncTimeout2.next;
|
||||
asyncTimeout2.next = asyncTimeout;
|
||||
if (asyncTimeout2 == head) {
|
||||
AsyncTimeout.class.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void enter() {
|
||||
if (this.inQueue) {
|
||||
throw new IllegalStateException("Unbalanced enter/exit");
|
||||
}
|
||||
long timeoutNanos = timeoutNanos();
|
||||
boolean hasDeadline = hasDeadline();
|
||||
if (timeoutNanos != 0 || hasDeadline) {
|
||||
this.inQueue = true;
|
||||
scheduleTimeout(this, timeoutNanos, hasDeadline);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean exit() {
|
||||
if (!this.inQueue) {
|
||||
return false;
|
||||
}
|
||||
this.inQueue = false;
|
||||
return cancelScheduledTimeout(this);
|
||||
}
|
||||
|
||||
protected IOException newTimeoutException(IOException iOException) {
|
||||
InterruptedIOException interruptedIOException = new InterruptedIOException("timeout");
|
||||
if (iOException != null) {
|
||||
interruptedIOException.initCause(iOException);
|
||||
}
|
||||
return interruptedIOException;
|
||||
}
|
||||
|
||||
public final Sink sink(final Sink sink) {
|
||||
return new Sink() { // from class: okio.AsyncTimeout.1
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
AsyncTimeout.this.enter();
|
||||
try {
|
||||
try {
|
||||
sink.close();
|
||||
AsyncTimeout.this.exit(true);
|
||||
} catch (IOException e) {
|
||||
throw AsyncTimeout.this.exit(e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
AsyncTimeout.this.exit(false);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
AsyncTimeout.this.enter();
|
||||
try {
|
||||
try {
|
||||
sink.flush();
|
||||
AsyncTimeout.this.exit(true);
|
||||
} catch (IOException e) {
|
||||
throw AsyncTimeout.this.exit(e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
AsyncTimeout.this.exit(false);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return AsyncTimeout.this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "AsyncTimeout.sink(" + sink + ")";
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
Util.checkOffsetAndCount(buffer.size, 0L, j);
|
||||
while (true) {
|
||||
long j2 = 0;
|
||||
if (j <= 0) {
|
||||
return;
|
||||
}
|
||||
Segment segment = buffer.head;
|
||||
while (true) {
|
||||
if (j2 >= PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH) {
|
||||
break;
|
||||
}
|
||||
j2 += segment.limit - segment.pos;
|
||||
if (j2 >= j) {
|
||||
j2 = j;
|
||||
break;
|
||||
}
|
||||
segment = segment.next;
|
||||
}
|
||||
AsyncTimeout.this.enter();
|
||||
try {
|
||||
try {
|
||||
sink.write(buffer, j2);
|
||||
j -= j2;
|
||||
AsyncTimeout.this.exit(true);
|
||||
} catch (IOException e) {
|
||||
throw AsyncTimeout.this.exit(e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
AsyncTimeout.this.exit(false);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public final Source source(final Source source) {
|
||||
return new Source() { // from class: okio.AsyncTimeout.2
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
try {
|
||||
source.close();
|
||||
AsyncTimeout.this.exit(true);
|
||||
} catch (IOException e) {
|
||||
throw AsyncTimeout.this.exit(e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
AsyncTimeout.this.exit(false);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
AsyncTimeout.this.enter();
|
||||
try {
|
||||
try {
|
||||
long read = source.read(buffer, j);
|
||||
AsyncTimeout.this.exit(true);
|
||||
return read;
|
||||
} catch (IOException e) {
|
||||
throw AsyncTimeout.this.exit(e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
AsyncTimeout.this.exit(false);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public Timeout timeout() {
|
||||
return AsyncTimeout.this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "AsyncTimeout.source(" + source + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void timedOut() {
|
||||
}
|
||||
|
||||
final void exit(boolean z) throws IOException {
|
||||
if (exit() && z) {
|
||||
throw newTimeoutException(null);
|
||||
}
|
||||
}
|
||||
|
||||
final IOException exit(IOException iOException) throws IOException {
|
||||
return !exit() ? iOException : newTimeoutException(iOException);
|
||||
}
|
||||
}
|
123
sources/okio/Base64.java
Normal file
123
sources/okio/Base64.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package okio;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class Base64 {
|
||||
private static final byte[] MAP = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47};
|
||||
private static final byte[] URL_MAP = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95};
|
||||
|
||||
private Base64() {
|
||||
}
|
||||
|
||||
public static byte[] decode(String str) {
|
||||
int i;
|
||||
char charAt;
|
||||
int length = str.length();
|
||||
while (length > 0 && ((charAt = str.charAt(length - 1)) == '=' || charAt == '\n' || charAt == '\r' || charAt == ' ' || charAt == '\t')) {
|
||||
length--;
|
||||
}
|
||||
byte[] bArr = new byte[(int) ((length * 6) / 8)];
|
||||
int i2 = 0;
|
||||
int i3 = 0;
|
||||
int i4 = 0;
|
||||
for (int i5 = 0; i5 < length; i5++) {
|
||||
char charAt2 = str.charAt(i5);
|
||||
if (charAt2 >= 'A' && charAt2 <= 'Z') {
|
||||
i = charAt2 - 'A';
|
||||
} else if (charAt2 >= 'a' && charAt2 <= 'z') {
|
||||
i = charAt2 - 'G';
|
||||
} else if (charAt2 >= '0' && charAt2 <= '9') {
|
||||
i = charAt2 + 4;
|
||||
} else if (charAt2 == '+' || charAt2 == '-') {
|
||||
i = 62;
|
||||
} else if (charAt2 == '/' || charAt2 == '_') {
|
||||
i = 63;
|
||||
} else {
|
||||
if (charAt2 != '\n' && charAt2 != '\r' && charAt2 != ' ' && charAt2 != '\t') {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
i3 = (i3 << 6) | ((byte) i);
|
||||
i2++;
|
||||
if (i2 % 4 == 0) {
|
||||
int i6 = i4 + 1;
|
||||
bArr[i4] = (byte) (i3 >> 16);
|
||||
int i7 = i6 + 1;
|
||||
bArr[i6] = (byte) (i3 >> 8);
|
||||
bArr[i7] = (byte) i3;
|
||||
i4 = i7 + 1;
|
||||
}
|
||||
}
|
||||
int i8 = i2 % 4;
|
||||
if (i8 == 1) {
|
||||
return null;
|
||||
}
|
||||
if (i8 == 2) {
|
||||
bArr[i4] = (byte) ((i3 << 12) >> 16);
|
||||
i4++;
|
||||
} else if (i8 == 3) {
|
||||
int i9 = i3 << 6;
|
||||
int i10 = i4 + 1;
|
||||
bArr[i4] = (byte) (i9 >> 16);
|
||||
i4 = i10 + 1;
|
||||
bArr[i10] = (byte) (i9 >> 8);
|
||||
}
|
||||
if (i4 == bArr.length) {
|
||||
return bArr;
|
||||
}
|
||||
byte[] bArr2 = new byte[i4];
|
||||
System.arraycopy(bArr, 0, bArr2, 0, i4);
|
||||
return bArr2;
|
||||
}
|
||||
|
||||
public static String encode(byte[] bArr) {
|
||||
return encode(bArr, MAP);
|
||||
}
|
||||
|
||||
public static String encodeUrl(byte[] bArr) {
|
||||
return encode(bArr, URL_MAP);
|
||||
}
|
||||
|
||||
private static String encode(byte[] bArr, byte[] bArr2) {
|
||||
byte[] bArr3 = new byte[((bArr.length + 2) / 3) * 4];
|
||||
int length = bArr.length - (bArr.length % 3);
|
||||
int i = 0;
|
||||
for (int i2 = 0; i2 < length; i2 += 3) {
|
||||
int i3 = i + 1;
|
||||
bArr3[i] = bArr2[(bArr[i2] & 255) >> 2];
|
||||
int i4 = i3 + 1;
|
||||
int i5 = i2 + 1;
|
||||
bArr3[i3] = bArr2[((bArr[i2] & 3) << 4) | ((bArr[i5] & 255) >> 4)];
|
||||
int i6 = i4 + 1;
|
||||
int i7 = (bArr[i5] & 15) << 2;
|
||||
int i8 = i2 + 2;
|
||||
bArr3[i4] = bArr2[i7 | ((bArr[i8] & 255) >> 6)];
|
||||
i = i6 + 1;
|
||||
bArr3[i6] = bArr2[bArr[i8] & 63];
|
||||
}
|
||||
int length2 = bArr.length % 3;
|
||||
if (length2 == 1) {
|
||||
int i9 = i + 1;
|
||||
bArr3[i] = bArr2[(bArr[length] & 255) >> 2];
|
||||
int i10 = i9 + 1;
|
||||
bArr3[i9] = bArr2[(bArr[length] & 3) << 4];
|
||||
bArr3[i10] = 61;
|
||||
bArr3[i10 + 1] = 61;
|
||||
} else if (length2 == 2) {
|
||||
int i11 = i + 1;
|
||||
bArr3[i] = bArr2[(bArr[length] & 255) >> 2];
|
||||
int i12 = i11 + 1;
|
||||
int i13 = (bArr[length] & 3) << 4;
|
||||
int i14 = length + 1;
|
||||
bArr3[i11] = bArr2[((bArr[i14] & 255) >> 4) | i13];
|
||||
bArr3[i12] = bArr2[(bArr[i14] & 15) << 2];
|
||||
bArr3[i12 + 1] = 61;
|
||||
}
|
||||
try {
|
||||
return new String(bArr3, "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
2061
sources/okio/Buffer.java
Normal file
2061
sources/okio/Buffer.java
Normal file
File diff suppressed because it is too large
Load Diff
58
sources/okio/BufferedSink.java
Normal file
58
sources/okio/BufferedSink.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface BufferedSink extends Sink, WritableByteChannel {
|
||||
Buffer buffer();
|
||||
|
||||
BufferedSink emit() throws IOException;
|
||||
|
||||
BufferedSink emitCompleteSegments() throws IOException;
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
void flush() throws IOException;
|
||||
|
||||
OutputStream outputStream();
|
||||
|
||||
BufferedSink write(ByteString byteString) throws IOException;
|
||||
|
||||
BufferedSink write(Source source, long j) throws IOException;
|
||||
|
||||
BufferedSink write(byte[] bArr) throws IOException;
|
||||
|
||||
BufferedSink write(byte[] bArr, int i, int i2) throws IOException;
|
||||
|
||||
long writeAll(Source source) throws IOException;
|
||||
|
||||
BufferedSink writeByte(int i) throws IOException;
|
||||
|
||||
BufferedSink writeDecimalLong(long j) throws IOException;
|
||||
|
||||
BufferedSink writeHexadecimalUnsignedLong(long j) throws IOException;
|
||||
|
||||
BufferedSink writeInt(int i) throws IOException;
|
||||
|
||||
BufferedSink writeIntLe(int i) throws IOException;
|
||||
|
||||
BufferedSink writeLong(long j) throws IOException;
|
||||
|
||||
BufferedSink writeLongLe(long j) throws IOException;
|
||||
|
||||
BufferedSink writeShort(int i) throws IOException;
|
||||
|
||||
BufferedSink writeShortLe(int i) throws IOException;
|
||||
|
||||
BufferedSink writeString(String str, int i, int i2, Charset charset) throws IOException;
|
||||
|
||||
BufferedSink writeString(String str, Charset charset) throws IOException;
|
||||
|
||||
BufferedSink writeUtf8(String str) throws IOException;
|
||||
|
||||
BufferedSink writeUtf8(String str, int i, int i2) throws IOException;
|
||||
|
||||
BufferedSink writeUtf8CodePoint(int i) throws IOException;
|
||||
}
|
93
sources/okio/BufferedSource.java
Normal file
93
sources/okio/BufferedSource.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface BufferedSource extends Source, ReadableByteChannel {
|
||||
Buffer buffer();
|
||||
|
||||
boolean exhausted() throws IOException;
|
||||
|
||||
long indexOf(byte b) throws IOException;
|
||||
|
||||
long indexOf(byte b, long j) throws IOException;
|
||||
|
||||
long indexOf(byte b, long j, long j2) throws IOException;
|
||||
|
||||
long indexOf(ByteString byteString) throws IOException;
|
||||
|
||||
long indexOf(ByteString byteString, long j) throws IOException;
|
||||
|
||||
long indexOfElement(ByteString byteString) throws IOException;
|
||||
|
||||
long indexOfElement(ByteString byteString, long j) throws IOException;
|
||||
|
||||
InputStream inputStream();
|
||||
|
||||
boolean rangeEquals(long j, ByteString byteString) throws IOException;
|
||||
|
||||
boolean rangeEquals(long j, ByteString byteString, int i, int i2) throws IOException;
|
||||
|
||||
int read(byte[] bArr) throws IOException;
|
||||
|
||||
int read(byte[] bArr, int i, int i2) throws IOException;
|
||||
|
||||
long readAll(Sink sink) throws IOException;
|
||||
|
||||
byte readByte() throws IOException;
|
||||
|
||||
byte[] readByteArray() throws IOException;
|
||||
|
||||
byte[] readByteArray(long j) throws IOException;
|
||||
|
||||
ByteString readByteString() throws IOException;
|
||||
|
||||
ByteString readByteString(long j) throws IOException;
|
||||
|
||||
long readDecimalLong() throws IOException;
|
||||
|
||||
void readFully(Buffer buffer, long j) throws IOException;
|
||||
|
||||
void readFully(byte[] bArr) throws IOException;
|
||||
|
||||
long readHexadecimalUnsignedLong() throws IOException;
|
||||
|
||||
int readInt() throws IOException;
|
||||
|
||||
int readIntLe() throws IOException;
|
||||
|
||||
long readLong() throws IOException;
|
||||
|
||||
long readLongLe() throws IOException;
|
||||
|
||||
short readShort() throws IOException;
|
||||
|
||||
short readShortLe() throws IOException;
|
||||
|
||||
String readString(long j, Charset charset) throws IOException;
|
||||
|
||||
String readString(Charset charset) throws IOException;
|
||||
|
||||
String readUtf8() throws IOException;
|
||||
|
||||
String readUtf8(long j) throws IOException;
|
||||
|
||||
int readUtf8CodePoint() throws IOException;
|
||||
|
||||
String readUtf8Line() throws IOException;
|
||||
|
||||
String readUtf8LineStrict() throws IOException;
|
||||
|
||||
String readUtf8LineStrict(long j) throws IOException;
|
||||
|
||||
boolean request(long j) throws IOException;
|
||||
|
||||
void require(long j) throws IOException;
|
||||
|
||||
int select(Options options) throws IOException;
|
||||
|
||||
void skip(long j) throws IOException;
|
||||
}
|
496
sources/okio/ByteString.java
Normal file
496
sources/okio/ByteString.java
Normal file
@@ -0,0 +1,496 @@
|
||||
package okio;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ByteString implements Serializable, Comparable<ByteString> {
|
||||
private static final long serialVersionUID = 1;
|
||||
final byte[] data;
|
||||
transient int hashCode;
|
||||
transient String utf8;
|
||||
static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
public static final ByteString EMPTY = of(new byte[0]);
|
||||
|
||||
ByteString(byte[] bArr) {
|
||||
this.data = bArr;
|
||||
}
|
||||
|
||||
static int codePointIndexToCharIndex(String str, int i) {
|
||||
int length = str.length();
|
||||
int i2 = 0;
|
||||
int i3 = 0;
|
||||
while (i2 < length) {
|
||||
if (i3 == i) {
|
||||
return i2;
|
||||
}
|
||||
int codePointAt = str.codePointAt(i2);
|
||||
if ((Character.isISOControl(codePointAt) && codePointAt != 10 && codePointAt != 13) || codePointAt == 65533) {
|
||||
return -1;
|
||||
}
|
||||
i3++;
|
||||
i2 += Character.charCount(codePointAt);
|
||||
}
|
||||
return str.length();
|
||||
}
|
||||
|
||||
public static ByteString decodeBase64(String str) {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("base64 == null");
|
||||
}
|
||||
byte[] decode = Base64.decode(str);
|
||||
if (decode != null) {
|
||||
return new ByteString(decode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ByteString decodeHex(String str) {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("hex == null");
|
||||
}
|
||||
if (str.length() % 2 != 0) {
|
||||
throw new IllegalArgumentException("Unexpected hex string: " + str);
|
||||
}
|
||||
byte[] bArr = new byte[str.length() / 2];
|
||||
for (int i = 0; i < bArr.length; i++) {
|
||||
int i2 = i * 2;
|
||||
bArr[i] = (byte) ((decodeHexDigit(str.charAt(i2)) << 4) + decodeHexDigit(str.charAt(i2 + 1)));
|
||||
}
|
||||
return of(bArr);
|
||||
}
|
||||
|
||||
private static int decodeHexDigit(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
}
|
||||
char c2 = 'a';
|
||||
if (c < 'a' || c > 'f') {
|
||||
c2 = 'A';
|
||||
if (c < 'A' || c > 'F') {
|
||||
throw new IllegalArgumentException("Unexpected hex digit: " + c);
|
||||
}
|
||||
}
|
||||
return (c - c2) + 10;
|
||||
}
|
||||
|
||||
private ByteString digest(String str) {
|
||||
try {
|
||||
return of(MessageDigest.getInstance(str).digest(this.data));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ByteString encodeString(String str, Charset charset) {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("s == null");
|
||||
}
|
||||
if (charset != null) {
|
||||
return new ByteString(str.getBytes(charset));
|
||||
}
|
||||
throw new IllegalArgumentException("charset == null");
|
||||
}
|
||||
|
||||
public static ByteString encodeUtf8(String str) {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("s == null");
|
||||
}
|
||||
ByteString byteString = new ByteString(str.getBytes(Util.UTF_8));
|
||||
byteString.utf8 = str;
|
||||
return byteString;
|
||||
}
|
||||
|
||||
private ByteString hmac(String str, ByteString byteString) {
|
||||
try {
|
||||
Mac mac = Mac.getInstance(str);
|
||||
mac.init(new SecretKeySpec(byteString.toByteArray(), str));
|
||||
return of(mac.doFinal(this.data));
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
} catch (NoSuchAlgorithmException e2) {
|
||||
throw new AssertionError(e2);
|
||||
}
|
||||
}
|
||||
|
||||
public static ByteString of(byte... bArr) {
|
||||
if (bArr != null) {
|
||||
return new ByteString((byte[]) bArr.clone());
|
||||
}
|
||||
throw new IllegalArgumentException("data == null");
|
||||
}
|
||||
|
||||
public static ByteString read(InputStream inputStream, int i) throws IOException {
|
||||
if (inputStream == null) {
|
||||
throw new IllegalArgumentException("in == null");
|
||||
}
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + i);
|
||||
}
|
||||
byte[] bArr = new byte[i];
|
||||
int i2 = 0;
|
||||
while (i2 < i) {
|
||||
int read = inputStream.read(bArr, i2, i - i2);
|
||||
if (read == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
i2 += read;
|
||||
}
|
||||
return new ByteString(bArr);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream objectInputStream) throws IOException {
|
||||
ByteString read = read(objectInputStream, objectInputStream.readInt());
|
||||
try {
|
||||
Field declaredField = ByteString.class.getDeclaredField("data");
|
||||
declaredField.setAccessible(true);
|
||||
declaredField.set(this, read.data);
|
||||
} catch (IllegalAccessException unused) {
|
||||
throw new AssertionError();
|
||||
} catch (NoSuchFieldException unused2) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||||
objectOutputStream.writeInt(this.data.length);
|
||||
objectOutputStream.write(this.data);
|
||||
}
|
||||
|
||||
public ByteBuffer asByteBuffer() {
|
||||
return ByteBuffer.wrap(this.data).asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
public String base64() {
|
||||
return Base64.encode(this.data);
|
||||
}
|
||||
|
||||
public String base64Url() {
|
||||
return Base64.encodeUrl(this.data);
|
||||
}
|
||||
|
||||
public final boolean endsWith(ByteString byteString) {
|
||||
return rangeEquals(size() - byteString.size(), byteString, 0, byteString.size());
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ByteString) {
|
||||
ByteString byteString = (ByteString) obj;
|
||||
int size = byteString.size();
|
||||
byte[] bArr = this.data;
|
||||
if (size == bArr.length && byteString.rangeEquals(0, bArr, 0, bArr.length)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte getByte(int i) {
|
||||
return this.data[i];
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int i = this.hashCode;
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
int hashCode = Arrays.hashCode(this.data);
|
||||
this.hashCode = hashCode;
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public String hex() {
|
||||
byte[] bArr = this.data;
|
||||
char[] cArr = new char[bArr.length * 2];
|
||||
int i = 0;
|
||||
for (byte b : bArr) {
|
||||
int i2 = i + 1;
|
||||
char[] cArr2 = HEX_DIGITS;
|
||||
cArr[i] = cArr2[(b >> 4) & 15];
|
||||
i = i2 + 1;
|
||||
cArr[i2] = cArr2[b & 15];
|
||||
}
|
||||
return new String(cArr);
|
||||
}
|
||||
|
||||
public ByteString hmacSha1(ByteString byteString) {
|
||||
return hmac("HmacSHA1", byteString);
|
||||
}
|
||||
|
||||
public ByteString hmacSha256(ByteString byteString) {
|
||||
return hmac("HmacSHA256", byteString);
|
||||
}
|
||||
|
||||
public ByteString hmacSha512(ByteString byteString) {
|
||||
return hmac("HmacSHA512", byteString);
|
||||
}
|
||||
|
||||
public final int indexOf(ByteString byteString) {
|
||||
return indexOf(byteString.internalArray(), 0);
|
||||
}
|
||||
|
||||
byte[] internalArray() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public final int lastIndexOf(ByteString byteString) {
|
||||
return lastIndexOf(byteString.internalArray(), size());
|
||||
}
|
||||
|
||||
public ByteString md5() {
|
||||
return digest("MD5");
|
||||
}
|
||||
|
||||
public boolean rangeEquals(int i, ByteString byteString, int i2, int i3) {
|
||||
return byteString.rangeEquals(i2, this.data, i, i3);
|
||||
}
|
||||
|
||||
public ByteString sha1() {
|
||||
return digest("SHA-1");
|
||||
}
|
||||
|
||||
public ByteString sha256() {
|
||||
return digest("SHA-256");
|
||||
}
|
||||
|
||||
public ByteString sha512() {
|
||||
return digest("SHA-512");
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.data.length;
|
||||
}
|
||||
|
||||
public final boolean startsWith(ByteString byteString) {
|
||||
return rangeEquals(0, byteString, 0, byteString.size());
|
||||
}
|
||||
|
||||
public String string(Charset charset) {
|
||||
if (charset != null) {
|
||||
return new String(this.data, charset);
|
||||
}
|
||||
throw new IllegalArgumentException("charset == null");
|
||||
}
|
||||
|
||||
public ByteString substring(int i) {
|
||||
return substring(i, this.data.length);
|
||||
}
|
||||
|
||||
public ByteString toAsciiLowercase() {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
byte[] bArr = this.data;
|
||||
if (i >= bArr.length) {
|
||||
return this;
|
||||
}
|
||||
byte b = bArr[i];
|
||||
if (b >= 65 && b <= 90) {
|
||||
byte[] bArr2 = (byte[]) bArr.clone();
|
||||
bArr2[i] = (byte) (b + 32);
|
||||
for (int i2 = i + 1; i2 < bArr2.length; i2++) {
|
||||
byte b2 = bArr2[i2];
|
||||
if (b2 >= 65 && b2 <= 90) {
|
||||
bArr2[i2] = (byte) (b2 + 32);
|
||||
}
|
||||
}
|
||||
return new ByteString(bArr2);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public ByteString toAsciiUppercase() {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
byte[] bArr = this.data;
|
||||
if (i >= bArr.length) {
|
||||
return this;
|
||||
}
|
||||
byte b = bArr[i];
|
||||
if (b >= 97 && b <= 122) {
|
||||
byte[] bArr2 = (byte[]) bArr.clone();
|
||||
bArr2[i] = (byte) (b - 32);
|
||||
for (int i2 = i + 1; i2 < bArr2.length; i2++) {
|
||||
byte b2 = bArr2[i2];
|
||||
if (b2 >= 97 && b2 <= 122) {
|
||||
bArr2[i2] = (byte) (b2 - 32);
|
||||
}
|
||||
}
|
||||
return new ByteString(bArr2);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] toByteArray() {
|
||||
return (byte[]) this.data.clone();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (this.data.length == 0) {
|
||||
return "[size=0]";
|
||||
}
|
||||
String utf8 = utf8();
|
||||
int codePointIndexToCharIndex = codePointIndexToCharIndex(utf8, 64);
|
||||
if (codePointIndexToCharIndex == -1) {
|
||||
if (this.data.length <= 64) {
|
||||
return "[hex=" + hex() + "]";
|
||||
}
|
||||
return "[size=" + this.data.length + " hex=" + substring(0, 64).hex() + "…]";
|
||||
}
|
||||
String replace = utf8.substring(0, codePointIndexToCharIndex).replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r");
|
||||
if (codePointIndexToCharIndex >= utf8.length()) {
|
||||
return "[text=" + replace + "]";
|
||||
}
|
||||
return "[size=" + this.data.length + " text=" + replace + "…]";
|
||||
}
|
||||
|
||||
public String utf8() {
|
||||
String str = this.utf8;
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
String str2 = new String(this.data, Util.UTF_8);
|
||||
this.utf8 = str2;
|
||||
return str2;
|
||||
}
|
||||
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
if (outputStream == null) {
|
||||
throw new IllegalArgumentException("out == null");
|
||||
}
|
||||
outputStream.write(this.data);
|
||||
}
|
||||
|
||||
@Override // java.lang.Comparable
|
||||
public int compareTo(ByteString byteString) {
|
||||
int size = size();
|
||||
int size2 = byteString.size();
|
||||
int min = Math.min(size, size2);
|
||||
for (int i = 0; i < min; i++) {
|
||||
int i2 = getByte(i) & 255;
|
||||
int i3 = byteString.getByte(i) & 255;
|
||||
if (i2 != i3) {
|
||||
return i2 < i3 ? -1 : 1;
|
||||
}
|
||||
}
|
||||
if (size == size2) {
|
||||
return 0;
|
||||
}
|
||||
return size < size2 ? -1 : 1;
|
||||
}
|
||||
|
||||
public final boolean endsWith(byte[] bArr) {
|
||||
return rangeEquals(size() - bArr.length, bArr, 0, bArr.length);
|
||||
}
|
||||
|
||||
public final int indexOf(ByteString byteString, int i) {
|
||||
return indexOf(byteString.internalArray(), i);
|
||||
}
|
||||
|
||||
public final int lastIndexOf(ByteString byteString, int i) {
|
||||
return lastIndexOf(byteString.internalArray(), i);
|
||||
}
|
||||
|
||||
public boolean rangeEquals(int i, byte[] bArr, int i2, int i3) {
|
||||
if (i >= 0) {
|
||||
byte[] bArr2 = this.data;
|
||||
if (i <= bArr2.length - i3 && i2 >= 0 && i2 <= bArr.length - i3 && Util.arrayRangeEquals(bArr2, i, bArr, i2, i3)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean startsWith(byte[] bArr) {
|
||||
return rangeEquals(0, bArr, 0, bArr.length);
|
||||
}
|
||||
|
||||
public ByteString substring(int i, int i2) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("beginIndex < 0");
|
||||
}
|
||||
byte[] bArr = this.data;
|
||||
if (i2 > bArr.length) {
|
||||
throw new IllegalArgumentException("endIndex > length(" + this.data.length + ")");
|
||||
}
|
||||
int i3 = i2 - i;
|
||||
if (i3 < 0) {
|
||||
throw new IllegalArgumentException("endIndex < beginIndex");
|
||||
}
|
||||
if (i == 0 && i2 == bArr.length) {
|
||||
return this;
|
||||
}
|
||||
byte[] bArr2 = new byte[i3];
|
||||
System.arraycopy(this.data, i, bArr2, 0, i3);
|
||||
return new ByteString(bArr2);
|
||||
}
|
||||
|
||||
public static ByteString of(byte[] bArr, int i, int i2) {
|
||||
if (bArr != null) {
|
||||
Util.checkOffsetAndCount(bArr.length, i, i2);
|
||||
byte[] bArr2 = new byte[i2];
|
||||
System.arraycopy(bArr, i, bArr2, 0, i2);
|
||||
return new ByteString(bArr2);
|
||||
}
|
||||
throw new IllegalArgumentException("data == null");
|
||||
}
|
||||
|
||||
public final int indexOf(byte[] bArr) {
|
||||
return indexOf(bArr, 0);
|
||||
}
|
||||
|
||||
public final int lastIndexOf(byte[] bArr) {
|
||||
return lastIndexOf(bArr, size());
|
||||
}
|
||||
|
||||
void write(Buffer buffer) {
|
||||
byte[] bArr = this.data;
|
||||
buffer.write(bArr, 0, bArr.length);
|
||||
}
|
||||
|
||||
public int indexOf(byte[] bArr, int i) {
|
||||
int length = this.data.length - bArr.length;
|
||||
for (int max = Math.max(i, 0); max <= length; max++) {
|
||||
if (Util.arrayRangeEquals(this.data, max, bArr, 0, bArr.length)) {
|
||||
return max;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int lastIndexOf(byte[] bArr, int i) {
|
||||
for (int min = Math.min(i, this.data.length - bArr.length); min >= 0; min--) {
|
||||
if (Util.arrayRangeEquals(this.data, min, bArr, 0, bArr.length)) {
|
||||
return min;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static ByteString of(ByteBuffer byteBuffer) {
|
||||
if (byteBuffer != null) {
|
||||
byte[] bArr = new byte[byteBuffer.remaining()];
|
||||
byteBuffer.get(bArr);
|
||||
return new ByteString(bArr);
|
||||
}
|
||||
throw new IllegalArgumentException("data == null");
|
||||
}
|
||||
}
|
127
sources/okio/DeflaterSink.java
Normal file
127
sources/okio/DeflaterSink.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class DeflaterSink implements Sink {
|
||||
private boolean closed;
|
||||
private final Deflater deflater;
|
||||
private final BufferedSink sink;
|
||||
|
||||
public DeflaterSink(Sink sink, Deflater deflater) {
|
||||
this(Okio.buffer(sink), deflater);
|
||||
}
|
||||
|
||||
private void deflate(boolean z) throws IOException {
|
||||
Segment writableSegment;
|
||||
int deflate;
|
||||
Buffer buffer = this.sink.buffer();
|
||||
while (true) {
|
||||
writableSegment = buffer.writableSegment(1);
|
||||
if (z) {
|
||||
Deflater deflater = this.deflater;
|
||||
byte[] bArr = writableSegment.data;
|
||||
int i = writableSegment.limit;
|
||||
deflate = deflater.deflate(bArr, i, 8192 - i, 2);
|
||||
} else {
|
||||
Deflater deflater2 = this.deflater;
|
||||
byte[] bArr2 = writableSegment.data;
|
||||
int i2 = writableSegment.limit;
|
||||
deflate = deflater2.deflate(bArr2, i2, 8192 - i2);
|
||||
}
|
||||
if (deflate > 0) {
|
||||
writableSegment.limit += deflate;
|
||||
buffer.size += deflate;
|
||||
this.sink.emitCompleteSegments();
|
||||
} else if (this.deflater.needsInput()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (writableSegment.pos == writableSegment.limit) {
|
||||
buffer.head = writableSegment.pop();
|
||||
SegmentPool.recycle(writableSegment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
Throwable th = null;
|
||||
try {
|
||||
finishDeflate();
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
try {
|
||||
this.deflater.end();
|
||||
} catch (Throwable th3) {
|
||||
if (th == null) {
|
||||
th = th3;
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.sink.close();
|
||||
} catch (Throwable th4) {
|
||||
if (th == null) {
|
||||
th = th4;
|
||||
}
|
||||
}
|
||||
this.closed = true;
|
||||
if (th != null) {
|
||||
Util.sneakyRethrow(th);
|
||||
}
|
||||
}
|
||||
|
||||
void finishDeflate() throws IOException {
|
||||
this.deflater.finish();
|
||||
deflate(false);
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
deflate(true);
|
||||
this.sink.flush();
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return this.sink.timeout();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "DeflaterSink(" + this.sink + ")";
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
Util.checkOffsetAndCount(buffer.size, 0L, j);
|
||||
while (j > 0) {
|
||||
Segment segment = buffer.head;
|
||||
int min = (int) Math.min(j, segment.limit - segment.pos);
|
||||
this.deflater.setInput(segment.data, segment.pos, min);
|
||||
deflate(false);
|
||||
long j2 = min;
|
||||
buffer.size -= j2;
|
||||
segment.pos += min;
|
||||
if (segment.pos == segment.limit) {
|
||||
buffer.head = segment.pop();
|
||||
SegmentPool.recycle(segment);
|
||||
}
|
||||
j -= j2;
|
||||
}
|
||||
}
|
||||
|
||||
DeflaterSink(BufferedSink bufferedSink, Deflater deflater) {
|
||||
if (bufferedSink == null) {
|
||||
throw new IllegalArgumentException("source == null");
|
||||
}
|
||||
if (deflater == null) {
|
||||
throw new IllegalArgumentException("inflater == null");
|
||||
}
|
||||
this.sink = bufferedSink;
|
||||
this.deflater = deflater;
|
||||
}
|
||||
}
|
43
sources/okio/ForwardingSink.java
Normal file
43
sources/okio/ForwardingSink.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class ForwardingSink implements Sink {
|
||||
private final Sink delegate;
|
||||
|
||||
public ForwardingSink(Sink sink) {
|
||||
if (sink == null) {
|
||||
throw new IllegalArgumentException("delegate == null");
|
||||
}
|
||||
this.delegate = sink;
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
this.delegate.close();
|
||||
}
|
||||
|
||||
public final Sink delegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
this.delegate.flush();
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return this.delegate.timeout();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "(" + this.delegate.toString() + ")";
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
this.delegate.write(buffer, j);
|
||||
}
|
||||
}
|
38
sources/okio/ForwardingSource.java
Normal file
38
sources/okio/ForwardingSource.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class ForwardingSource implements Source {
|
||||
private final Source delegate;
|
||||
|
||||
public ForwardingSource(Source source) {
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("delegate == null");
|
||||
}
|
||||
this.delegate = source;
|
||||
}
|
||||
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
this.delegate.close();
|
||||
}
|
||||
|
||||
public final Source delegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
return this.delegate.read(buffer, j);
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public Timeout timeout() {
|
||||
return this.delegate.timeout();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "(" + this.delegate.toString() + ")";
|
||||
}
|
||||
}
|
68
sources/okio/ForwardingTimeout.java
Normal file
68
sources/okio/ForwardingTimeout.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ForwardingTimeout extends Timeout {
|
||||
private Timeout delegate;
|
||||
|
||||
public ForwardingTimeout(Timeout timeout) {
|
||||
if (timeout == null) {
|
||||
throw new IllegalArgumentException("delegate == null");
|
||||
}
|
||||
this.delegate = timeout;
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public Timeout clearDeadline() {
|
||||
return this.delegate.clearDeadline();
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public Timeout clearTimeout() {
|
||||
return this.delegate.clearTimeout();
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public long deadlineNanoTime() {
|
||||
return this.delegate.deadlineNanoTime();
|
||||
}
|
||||
|
||||
public final Timeout delegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public boolean hasDeadline() {
|
||||
return this.delegate.hasDeadline();
|
||||
}
|
||||
|
||||
public final ForwardingTimeout setDelegate(Timeout timeout) {
|
||||
if (timeout == null) {
|
||||
throw new IllegalArgumentException("delegate == null");
|
||||
}
|
||||
this.delegate = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public void throwIfReached() throws IOException {
|
||||
this.delegate.throwIfReached();
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public Timeout timeout(long j, TimeUnit timeUnit) {
|
||||
return this.delegate.timeout(j, timeUnit);
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public long timeoutNanos() {
|
||||
return this.delegate.timeoutNanos();
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public Timeout deadlineNanoTime(long j) {
|
||||
return this.delegate.deadlineNanoTime(j);
|
||||
}
|
||||
}
|
107
sources/okio/GzipSink.java
Normal file
107
sources/okio/GzipSink.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class GzipSink implements Sink {
|
||||
private boolean closed;
|
||||
private final CRC32 crc = new CRC32();
|
||||
private final Deflater deflater;
|
||||
private final DeflaterSink deflaterSink;
|
||||
private final BufferedSink sink;
|
||||
|
||||
public GzipSink(Sink sink) {
|
||||
if (sink == null) {
|
||||
throw new IllegalArgumentException("sink == null");
|
||||
}
|
||||
this.deflater = new Deflater(-1, true);
|
||||
this.sink = Okio.buffer(sink);
|
||||
this.deflaterSink = new DeflaterSink(this.sink, this.deflater);
|
||||
writeHeader();
|
||||
}
|
||||
|
||||
private void updateCrc(Buffer buffer, long j) {
|
||||
Segment segment = buffer.head;
|
||||
while (j > 0) {
|
||||
int min = (int) Math.min(j, segment.limit - segment.pos);
|
||||
this.crc.update(segment.data, segment.pos, min);
|
||||
j -= min;
|
||||
segment = segment.next;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFooter() throws IOException {
|
||||
this.sink.writeIntLe((int) this.crc.getValue());
|
||||
this.sink.writeIntLe((int) this.deflater.getBytesRead());
|
||||
}
|
||||
|
||||
private void writeHeader() {
|
||||
Buffer buffer = this.sink.buffer();
|
||||
buffer.writeShort(8075);
|
||||
buffer.writeByte(8);
|
||||
buffer.writeByte(0);
|
||||
buffer.writeInt(0);
|
||||
buffer.writeByte(0);
|
||||
buffer.writeByte(0);
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
Throwable th = null;
|
||||
try {
|
||||
this.deflaterSink.finishDeflate();
|
||||
writeFooter();
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
try {
|
||||
this.deflater.end();
|
||||
} catch (Throwable th3) {
|
||||
if (th == null) {
|
||||
th = th3;
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.sink.close();
|
||||
} catch (Throwable th4) {
|
||||
if (th == null) {
|
||||
th = th4;
|
||||
}
|
||||
}
|
||||
this.closed = true;
|
||||
if (th != null) {
|
||||
Util.sneakyRethrow(th);
|
||||
}
|
||||
}
|
||||
|
||||
public Deflater deflater() {
|
||||
return this.deflater;
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
this.deflaterSink.flush();
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return this.sink.timeout();
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
if (j < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + j);
|
||||
}
|
||||
if (j == 0) {
|
||||
return;
|
||||
}
|
||||
updateCrc(buffer, j);
|
||||
this.deflaterSink.write(buffer, j);
|
||||
}
|
||||
}
|
151
sources/okio/GzipSource.java
Normal file
151
sources/okio/GzipSource.java
Normal file
@@ -0,0 +1,151 @@
|
||||
package okio;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class GzipSource implements Source {
|
||||
private static final byte FCOMMENT = 4;
|
||||
private static final byte FEXTRA = 2;
|
||||
private static final byte FHCRC = 1;
|
||||
private static final byte FNAME = 3;
|
||||
private static final byte SECTION_BODY = 1;
|
||||
private static final byte SECTION_DONE = 3;
|
||||
private static final byte SECTION_HEADER = 0;
|
||||
private static final byte SECTION_TRAILER = 2;
|
||||
private final Inflater inflater;
|
||||
private final InflaterSource inflaterSource;
|
||||
private final BufferedSource source;
|
||||
private int section = 0;
|
||||
private final CRC32 crc = new CRC32();
|
||||
|
||||
public GzipSource(Source source) {
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("source == null");
|
||||
}
|
||||
this.inflater = new Inflater(true);
|
||||
this.source = Okio.buffer(source);
|
||||
this.inflaterSource = new InflaterSource(this.source, this.inflater);
|
||||
}
|
||||
|
||||
private void checkEqual(String str, int i, int i2) throws IOException {
|
||||
if (i2 != i) {
|
||||
throw new IOException(String.format("%s: actual 0x%08x != expected 0x%08x", str, Integer.valueOf(i2), Integer.valueOf(i)));
|
||||
}
|
||||
}
|
||||
|
||||
private void consumeHeader() throws IOException {
|
||||
this.source.require(10L);
|
||||
byte b = this.source.buffer().getByte(3L);
|
||||
boolean z = ((b >> 1) & 1) == 1;
|
||||
if (z) {
|
||||
updateCrc(this.source.buffer(), 0L, 10L);
|
||||
}
|
||||
checkEqual("ID1ID2", 8075, this.source.readShort());
|
||||
this.source.skip(8L);
|
||||
if (((b >> 2) & 1) == 1) {
|
||||
this.source.require(2L);
|
||||
if (z) {
|
||||
updateCrc(this.source.buffer(), 0L, 2L);
|
||||
}
|
||||
long readShortLe = this.source.buffer().readShortLe();
|
||||
this.source.require(readShortLe);
|
||||
if (z) {
|
||||
updateCrc(this.source.buffer(), 0L, readShortLe);
|
||||
}
|
||||
this.source.skip(readShortLe);
|
||||
}
|
||||
if (((b >> 3) & 1) == 1) {
|
||||
long indexOf = this.source.indexOf(SECTION_HEADER);
|
||||
if (indexOf == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
if (z) {
|
||||
updateCrc(this.source.buffer(), 0L, indexOf + 1);
|
||||
}
|
||||
this.source.skip(indexOf + 1);
|
||||
}
|
||||
if (((b >> 4) & 1) == 1) {
|
||||
long indexOf2 = this.source.indexOf(SECTION_HEADER);
|
||||
if (indexOf2 == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
if (z) {
|
||||
updateCrc(this.source.buffer(), 0L, indexOf2 + 1);
|
||||
}
|
||||
this.source.skip(indexOf2 + 1);
|
||||
}
|
||||
if (z) {
|
||||
checkEqual("FHCRC", this.source.readShortLe(), (short) this.crc.getValue());
|
||||
this.crc.reset();
|
||||
}
|
||||
}
|
||||
|
||||
private void consumeTrailer() throws IOException {
|
||||
checkEqual("CRC", this.source.readIntLe(), (int) this.crc.getValue());
|
||||
checkEqual("ISIZE", this.source.readIntLe(), (int) this.inflater.getBytesWritten());
|
||||
}
|
||||
|
||||
private void updateCrc(Buffer buffer, long j, long j2) {
|
||||
Segment segment = buffer.head;
|
||||
while (true) {
|
||||
int i = segment.limit;
|
||||
int i2 = segment.pos;
|
||||
if (j < i - i2) {
|
||||
break;
|
||||
}
|
||||
j -= i - i2;
|
||||
segment = segment.next;
|
||||
}
|
||||
while (j2 > 0) {
|
||||
int min = (int) Math.min(segment.limit - r7, j2);
|
||||
this.crc.update(segment.data, (int) (segment.pos + j), min);
|
||||
j2 -= min;
|
||||
segment = segment.next;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
this.inflaterSource.close();
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
if (j < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + j);
|
||||
}
|
||||
if (j == 0) {
|
||||
return 0L;
|
||||
}
|
||||
if (this.section == 0) {
|
||||
consumeHeader();
|
||||
this.section = 1;
|
||||
}
|
||||
if (this.section == 1) {
|
||||
long j2 = buffer.size;
|
||||
long read = this.inflaterSource.read(buffer, j);
|
||||
if (read != -1) {
|
||||
updateCrc(buffer, j2, read);
|
||||
return read;
|
||||
}
|
||||
this.section = 2;
|
||||
}
|
||||
if (this.section == 2) {
|
||||
consumeTrailer();
|
||||
this.section = 3;
|
||||
if (!this.source.exhausted()) {
|
||||
throw new IOException("gzip finished without exhausting source");
|
||||
}
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public Timeout timeout() {
|
||||
return this.source.timeout();
|
||||
}
|
||||
}
|
89
sources/okio/HashingSink.java
Normal file
89
sources/okio/HashingSink.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class HashingSink extends ForwardingSink {
|
||||
private final Mac mac;
|
||||
private final MessageDigest messageDigest;
|
||||
|
||||
private HashingSink(Sink sink, String str) {
|
||||
super(sink);
|
||||
try {
|
||||
this.messageDigest = MessageDigest.getInstance(str);
|
||||
this.mac = null;
|
||||
} catch (NoSuchAlgorithmException unused) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public static HashingSink hmacSha1(Sink sink, ByteString byteString) {
|
||||
return new HashingSink(sink, byteString, "HmacSHA1");
|
||||
}
|
||||
|
||||
public static HashingSink hmacSha256(Sink sink, ByteString byteString) {
|
||||
return new HashingSink(sink, byteString, "HmacSHA256");
|
||||
}
|
||||
|
||||
public static HashingSink hmacSha512(Sink sink, ByteString byteString) {
|
||||
return new HashingSink(sink, byteString, "HmacSHA512");
|
||||
}
|
||||
|
||||
public static HashingSink md5(Sink sink) {
|
||||
return new HashingSink(sink, "MD5");
|
||||
}
|
||||
|
||||
public static HashingSink sha1(Sink sink) {
|
||||
return new HashingSink(sink, "SHA-1");
|
||||
}
|
||||
|
||||
public static HashingSink sha256(Sink sink) {
|
||||
return new HashingSink(sink, "SHA-256");
|
||||
}
|
||||
|
||||
public static HashingSink sha512(Sink sink) {
|
||||
return new HashingSink(sink, "SHA-512");
|
||||
}
|
||||
|
||||
public ByteString hash() {
|
||||
MessageDigest messageDigest = this.messageDigest;
|
||||
return ByteString.of(messageDigest != null ? messageDigest.digest() : this.mac.doFinal());
|
||||
}
|
||||
|
||||
@Override // okio.ForwardingSink, okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
Util.checkOffsetAndCount(buffer.size, 0L, j);
|
||||
Segment segment = buffer.head;
|
||||
long j2 = 0;
|
||||
while (j2 < j) {
|
||||
int min = (int) Math.min(j - j2, segment.limit - segment.pos);
|
||||
MessageDigest messageDigest = this.messageDigest;
|
||||
if (messageDigest != null) {
|
||||
messageDigest.update(segment.data, segment.pos, min);
|
||||
} else {
|
||||
this.mac.update(segment.data, segment.pos, min);
|
||||
}
|
||||
j2 += min;
|
||||
segment = segment.next;
|
||||
}
|
||||
super.write(buffer, j);
|
||||
}
|
||||
|
||||
private HashingSink(Sink sink, ByteString byteString, String str) {
|
||||
super(sink);
|
||||
try {
|
||||
this.mac = Mac.getInstance(str);
|
||||
this.mac.init(new SecretKeySpec(byteString.toByteArray(), str));
|
||||
this.messageDigest = null;
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
} catch (NoSuchAlgorithmException unused) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
89
sources/okio/HashingSource.java
Normal file
89
sources/okio/HashingSource.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class HashingSource extends ForwardingSource {
|
||||
private final Mac mac;
|
||||
private final MessageDigest messageDigest;
|
||||
|
||||
private HashingSource(Source source, String str) {
|
||||
super(source);
|
||||
try {
|
||||
this.messageDigest = MessageDigest.getInstance(str);
|
||||
this.mac = null;
|
||||
} catch (NoSuchAlgorithmException unused) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public static HashingSource hmacSha1(Source source, ByteString byteString) {
|
||||
return new HashingSource(source, byteString, "HmacSHA1");
|
||||
}
|
||||
|
||||
public static HashingSource hmacSha256(Source source, ByteString byteString) {
|
||||
return new HashingSource(source, byteString, "HmacSHA256");
|
||||
}
|
||||
|
||||
public static HashingSource md5(Source source) {
|
||||
return new HashingSource(source, "MD5");
|
||||
}
|
||||
|
||||
public static HashingSource sha1(Source source) {
|
||||
return new HashingSource(source, "SHA-1");
|
||||
}
|
||||
|
||||
public static HashingSource sha256(Source source) {
|
||||
return new HashingSource(source, "SHA-256");
|
||||
}
|
||||
|
||||
public ByteString hash() {
|
||||
MessageDigest messageDigest = this.messageDigest;
|
||||
return ByteString.of(messageDigest != null ? messageDigest.digest() : this.mac.doFinal());
|
||||
}
|
||||
|
||||
@Override // okio.ForwardingSource, okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
long read = super.read(buffer, j);
|
||||
if (read != -1) {
|
||||
long j2 = buffer.size;
|
||||
long j3 = j2 - read;
|
||||
Segment segment = buffer.head;
|
||||
while (j2 > j3) {
|
||||
segment = segment.prev;
|
||||
j2 -= segment.limit - segment.pos;
|
||||
}
|
||||
while (j2 < buffer.size) {
|
||||
int i = (int) ((segment.pos + j3) - j2);
|
||||
MessageDigest messageDigest = this.messageDigest;
|
||||
if (messageDigest != null) {
|
||||
messageDigest.update(segment.data, i, segment.limit - i);
|
||||
} else {
|
||||
this.mac.update(segment.data, i, segment.limit - i);
|
||||
}
|
||||
j3 = (segment.limit - segment.pos) + j2;
|
||||
segment = segment.next;
|
||||
j2 = j3;
|
||||
}
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
private HashingSource(Source source, ByteString byteString, String str) {
|
||||
super(source);
|
||||
try {
|
||||
this.mac = Mac.getInstance(str);
|
||||
this.mac.init(new SecretKeySpec(byteString.toByteArray(), str));
|
||||
this.messageDigest = null;
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
} catch (NoSuchAlgorithmException unused) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
112
sources/okio/InflaterSource.java
Normal file
112
sources/okio/InflaterSource.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package okio;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class InflaterSource implements Source {
|
||||
private int bufferBytesHeldByInflater;
|
||||
private boolean closed;
|
||||
private final Inflater inflater;
|
||||
private final BufferedSource source;
|
||||
|
||||
public InflaterSource(Source source, Inflater inflater) {
|
||||
this(Okio.buffer(source), inflater);
|
||||
}
|
||||
|
||||
private void releaseInflatedBytes() throws IOException {
|
||||
int i = this.bufferBytesHeldByInflater;
|
||||
if (i == 0) {
|
||||
return;
|
||||
}
|
||||
int remaining = i - this.inflater.getRemaining();
|
||||
this.bufferBytesHeldByInflater -= remaining;
|
||||
this.source.skip(remaining);
|
||||
}
|
||||
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.inflater.end();
|
||||
this.closed = true;
|
||||
this.source.close();
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
boolean refill;
|
||||
if (j < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + j);
|
||||
}
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
if (j == 0) {
|
||||
return 0L;
|
||||
}
|
||||
do {
|
||||
refill = refill();
|
||||
try {
|
||||
Segment writableSegment = buffer.writableSegment(1);
|
||||
int inflate = this.inflater.inflate(writableSegment.data, writableSegment.limit, (int) Math.min(j, 8192 - writableSegment.limit));
|
||||
if (inflate > 0) {
|
||||
writableSegment.limit += inflate;
|
||||
long j2 = inflate;
|
||||
buffer.size += j2;
|
||||
return j2;
|
||||
}
|
||||
if (!this.inflater.finished() && !this.inflater.needsDictionary()) {
|
||||
}
|
||||
releaseInflatedBytes();
|
||||
if (writableSegment.pos != writableSegment.limit) {
|
||||
return -1L;
|
||||
}
|
||||
buffer.head = writableSegment.pop();
|
||||
SegmentPool.recycle(writableSegment);
|
||||
return -1L;
|
||||
} catch (DataFormatException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
} while (!refill);
|
||||
throw new EOFException("source exhausted prematurely");
|
||||
}
|
||||
|
||||
public boolean refill() throws IOException {
|
||||
if (!this.inflater.needsInput()) {
|
||||
return false;
|
||||
}
|
||||
releaseInflatedBytes();
|
||||
if (this.inflater.getRemaining() != 0) {
|
||||
throw new IllegalStateException("?");
|
||||
}
|
||||
if (this.source.exhausted()) {
|
||||
return true;
|
||||
}
|
||||
Segment segment = this.source.buffer().head;
|
||||
int i = segment.limit;
|
||||
int i2 = segment.pos;
|
||||
this.bufferBytesHeldByInflater = i - i2;
|
||||
this.inflater.setInput(segment.data, i2, this.bufferBytesHeldByInflater);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public Timeout timeout() {
|
||||
return this.source.timeout();
|
||||
}
|
||||
|
||||
InflaterSource(BufferedSource bufferedSource, Inflater inflater) {
|
||||
if (bufferedSource == null) {
|
||||
throw new IllegalArgumentException("source == null");
|
||||
}
|
||||
if (inflater == null) {
|
||||
throw new IllegalArgumentException("inflater == null");
|
||||
}
|
||||
this.source = bufferedSource;
|
||||
this.inflater = inflater;
|
||||
}
|
||||
}
|
249
sources/okio/Okio.java
Normal file
249
sources/okio/Okio.java
Normal file
@@ -0,0 +1,249 @@
|
||||
package okio;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class Okio {
|
||||
static final Logger logger = Logger.getLogger(Okio.class.getName());
|
||||
|
||||
private Okio() {
|
||||
}
|
||||
|
||||
public static Sink appendingSink(File file) throws FileNotFoundException {
|
||||
if (file != null) {
|
||||
return sink(new FileOutputStream(file, true));
|
||||
}
|
||||
throw new IllegalArgumentException("file == null");
|
||||
}
|
||||
|
||||
public static Sink blackhole() {
|
||||
return new Sink() { // from class: okio.Okio.3
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return Timeout.NONE;
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
buffer.skip(j);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static BufferedSource buffer(Source source) {
|
||||
return new RealBufferedSource(source);
|
||||
}
|
||||
|
||||
static boolean isAndroidGetsocknameError(AssertionError assertionError) {
|
||||
return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true;
|
||||
}
|
||||
|
||||
public static Sink sink(OutputStream outputStream) {
|
||||
return sink(outputStream, new Timeout());
|
||||
}
|
||||
|
||||
public static Source source(InputStream inputStream) {
|
||||
return source(inputStream, new Timeout());
|
||||
}
|
||||
|
||||
private static AsyncTimeout timeout(final Socket socket) {
|
||||
return new AsyncTimeout() { // from class: okio.Okio.4
|
||||
@Override // okio.AsyncTimeout
|
||||
protected IOException newTimeoutException(IOException iOException) {
|
||||
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
|
||||
if (iOException != null) {
|
||||
socketTimeoutException.initCause(iOException);
|
||||
}
|
||||
return socketTimeoutException;
|
||||
}
|
||||
|
||||
@Override // okio.AsyncTimeout
|
||||
protected void timedOut() {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (AssertionError e) {
|
||||
if (!Okio.isAndroidGetsocknameError(e)) {
|
||||
throw e;
|
||||
}
|
||||
Okio.logger.log(Level.WARNING, "Failed to close timed out socket " + socket, (Throwable) e);
|
||||
} catch (Exception e2) {
|
||||
Okio.logger.log(Level.WARNING, "Failed to close timed out socket " + socket, (Throwable) e2);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static BufferedSink buffer(Sink sink) {
|
||||
return new RealBufferedSink(sink);
|
||||
}
|
||||
|
||||
private static Sink sink(final OutputStream outputStream, final Timeout timeout) {
|
||||
if (outputStream == null) {
|
||||
throw new IllegalArgumentException("out == null");
|
||||
}
|
||||
if (timeout != null) {
|
||||
return new Sink() { // from class: okio.Okio.1
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return Timeout.this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "sink(" + outputStream + ")";
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
Util.checkOffsetAndCount(buffer.size, 0L, j);
|
||||
while (j > 0) {
|
||||
Timeout.this.throwIfReached();
|
||||
Segment segment = buffer.head;
|
||||
int min = (int) Math.min(j, segment.limit - segment.pos);
|
||||
outputStream.write(segment.data, segment.pos, min);
|
||||
segment.pos += min;
|
||||
long j2 = min;
|
||||
j -= j2;
|
||||
buffer.size -= j2;
|
||||
if (segment.pos == segment.limit) {
|
||||
buffer.head = segment.pop();
|
||||
SegmentPool.recycle(segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
throw new IllegalArgumentException("timeout == null");
|
||||
}
|
||||
|
||||
private static Source source(final InputStream inputStream, final Timeout timeout) {
|
||||
if (inputStream == null) {
|
||||
throw new IllegalArgumentException("in == null");
|
||||
}
|
||||
if (timeout != null) {
|
||||
return new Source() { // from class: okio.Okio.2
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
if (j < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + j);
|
||||
}
|
||||
if (j == 0) {
|
||||
return 0L;
|
||||
}
|
||||
try {
|
||||
Timeout.this.throwIfReached();
|
||||
Segment writableSegment = buffer.writableSegment(1);
|
||||
int read = inputStream.read(writableSegment.data, writableSegment.limit, (int) Math.min(j, 8192 - writableSegment.limit));
|
||||
if (read == -1) {
|
||||
return -1L;
|
||||
}
|
||||
writableSegment.limit += read;
|
||||
long j2 = read;
|
||||
buffer.size += j2;
|
||||
return j2;
|
||||
} catch (AssertionError e) {
|
||||
if (Okio.isAndroidGetsocknameError(e)) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public Timeout timeout() {
|
||||
return Timeout.this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "source(" + inputStream + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
throw new IllegalArgumentException("timeout == null");
|
||||
}
|
||||
|
||||
public static Sink sink(Socket socket) throws IOException {
|
||||
if (socket != null) {
|
||||
if (socket.getOutputStream() != null) {
|
||||
AsyncTimeout timeout = timeout(socket);
|
||||
return timeout.sink(sink(socket.getOutputStream(), timeout));
|
||||
}
|
||||
throw new IOException("socket's output stream == null");
|
||||
}
|
||||
throw new IllegalArgumentException("socket == null");
|
||||
}
|
||||
|
||||
public static Source source(File file) throws FileNotFoundException {
|
||||
if (file != null) {
|
||||
return source(new FileInputStream(file));
|
||||
}
|
||||
throw new IllegalArgumentException("file == null");
|
||||
}
|
||||
|
||||
public static Source source(Path path, OpenOption... openOptionArr) throws IOException {
|
||||
if (path != null) {
|
||||
return source(Files.newInputStream(path, openOptionArr));
|
||||
}
|
||||
throw new IllegalArgumentException("path == null");
|
||||
}
|
||||
|
||||
public static Source source(Socket socket) throws IOException {
|
||||
if (socket != null) {
|
||||
if (socket.getInputStream() != null) {
|
||||
AsyncTimeout timeout = timeout(socket);
|
||||
return timeout.source(source(socket.getInputStream(), timeout));
|
||||
}
|
||||
throw new IOException("socket's input stream == null");
|
||||
}
|
||||
throw new IllegalArgumentException("socket == null");
|
||||
}
|
||||
|
||||
public static Sink sink(File file) throws FileNotFoundException {
|
||||
if (file != null) {
|
||||
return sink(new FileOutputStream(file));
|
||||
}
|
||||
throw new IllegalArgumentException("file == null");
|
||||
}
|
||||
|
||||
public static Sink sink(Path path, OpenOption... openOptionArr) throws IOException {
|
||||
if (path != null) {
|
||||
return sink(Files.newOutputStream(path, openOptionArr));
|
||||
}
|
||||
throw new IllegalArgumentException("path == null");
|
||||
}
|
||||
}
|
27
sources/okio/Options.java
Normal file
27
sources/okio/Options.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package okio;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class Options extends AbstractList<ByteString> implements RandomAccess {
|
||||
final ByteString[] byteStrings;
|
||||
|
||||
private Options(ByteString[] byteStringArr) {
|
||||
this.byteStrings = byteStringArr;
|
||||
}
|
||||
|
||||
public static Options of(ByteString... byteStringArr) {
|
||||
return new Options((ByteString[]) byteStringArr.clone());
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public int size() {
|
||||
return this.byteStrings.length;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public ByteString get(int i) {
|
||||
return this.byteStrings[i];
|
||||
}
|
||||
}
|
128
sources/okio/Pipe.java
Normal file
128
sources/okio/Pipe.java
Normal file
@@ -0,0 +1,128 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class Pipe {
|
||||
final long maxBufferSize;
|
||||
boolean sinkClosed;
|
||||
boolean sourceClosed;
|
||||
final Buffer buffer = new Buffer();
|
||||
private final Sink sink = new PipeSink();
|
||||
private final Source source = new PipeSource();
|
||||
|
||||
final class PipeSink implements Sink {
|
||||
final Timeout timeout = new Timeout();
|
||||
|
||||
PipeSink() {
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
synchronized (Pipe.this.buffer) {
|
||||
if (Pipe.this.sinkClosed) {
|
||||
return;
|
||||
}
|
||||
if (Pipe.this.sourceClosed && Pipe.this.buffer.size() > 0) {
|
||||
throw new IOException("source is closed");
|
||||
}
|
||||
Pipe.this.sinkClosed = true;
|
||||
Pipe.this.buffer.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
synchronized (Pipe.this.buffer) {
|
||||
if (Pipe.this.sinkClosed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
if (Pipe.this.sourceClosed && Pipe.this.buffer.size() > 0) {
|
||||
throw new IOException("source is closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return this.timeout;
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
synchronized (Pipe.this.buffer) {
|
||||
if (Pipe.this.sinkClosed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
while (j > 0) {
|
||||
if (Pipe.this.sourceClosed) {
|
||||
throw new IOException("source is closed");
|
||||
}
|
||||
long size = Pipe.this.maxBufferSize - Pipe.this.buffer.size();
|
||||
if (size == 0) {
|
||||
this.timeout.waitUntilNotified(Pipe.this.buffer);
|
||||
} else {
|
||||
long min = Math.min(size, j);
|
||||
Pipe.this.buffer.write(buffer, min);
|
||||
j -= min;
|
||||
Pipe.this.buffer.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class PipeSource implements Source {
|
||||
final Timeout timeout = new Timeout();
|
||||
|
||||
PipeSource() {
|
||||
}
|
||||
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
synchronized (Pipe.this.buffer) {
|
||||
Pipe.this.sourceClosed = true;
|
||||
Pipe.this.buffer.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
synchronized (Pipe.this.buffer) {
|
||||
if (Pipe.this.sourceClosed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
while (Pipe.this.buffer.size() == 0) {
|
||||
if (Pipe.this.sinkClosed) {
|
||||
return -1L;
|
||||
}
|
||||
this.timeout.waitUntilNotified(Pipe.this.buffer);
|
||||
}
|
||||
long read = Pipe.this.buffer.read(buffer, j);
|
||||
Pipe.this.buffer.notifyAll();
|
||||
return read;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public Timeout timeout() {
|
||||
return this.timeout;
|
||||
}
|
||||
}
|
||||
|
||||
public Pipe(long j) {
|
||||
if (j >= 1) {
|
||||
this.maxBufferSize = j;
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("maxBufferSize < 1: " + j);
|
||||
}
|
||||
|
||||
public Sink sink() {
|
||||
return this.sink;
|
||||
}
|
||||
|
||||
public Source source() {
|
||||
return this.source;
|
||||
}
|
||||
}
|
350
sources/okio/RealBufferedSink.java
Normal file
350
sources/okio/RealBufferedSink.java
Normal file
@@ -0,0 +1,350 @@
|
||||
package okio;
|
||||
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class RealBufferedSink implements BufferedSink {
|
||||
public final Buffer buffer = new Buffer();
|
||||
boolean closed;
|
||||
public final Sink sink;
|
||||
|
||||
RealBufferedSink(Sink sink) {
|
||||
if (sink == null) {
|
||||
throw new NullPointerException("sink == null");
|
||||
}
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public Buffer buffer() {
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
Throwable th = null;
|
||||
try {
|
||||
if (this.buffer.size > 0) {
|
||||
this.sink.write(this.buffer, this.buffer.size);
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
try {
|
||||
this.sink.close();
|
||||
} catch (Throwable th3) {
|
||||
if (th == null) {
|
||||
th = th3;
|
||||
}
|
||||
}
|
||||
this.closed = true;
|
||||
if (th != null) {
|
||||
Util.sneakyRethrow(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink emit() throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
long size = this.buffer.size();
|
||||
if (size > 0) {
|
||||
this.sink.write(this.buffer, size);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink emitCompleteSegments() throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
long completeSegmentByteCount = this.buffer.completeSegmentByteCount();
|
||||
if (completeSegmentByteCount > 0) {
|
||||
this.sink.write(this.buffer, completeSegmentByteCount);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink, okio.Sink, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
Buffer buffer = this.buffer;
|
||||
long j = buffer.size;
|
||||
if (j > 0) {
|
||||
this.sink.write(buffer, j);
|
||||
}
|
||||
this.sink.flush();
|
||||
}
|
||||
|
||||
@Override // java.nio.channels.Channel
|
||||
public boolean isOpen() {
|
||||
return !this.closed;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public OutputStream outputStream() {
|
||||
return new OutputStream() { // from class: okio.RealBufferedSink.1
|
||||
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
RealBufferedSink.this.close();
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream, java.io.Flushable
|
||||
public void flush() throws IOException {
|
||||
RealBufferedSink realBufferedSink = RealBufferedSink.this;
|
||||
if (realBufferedSink.closed) {
|
||||
return;
|
||||
}
|
||||
realBufferedSink.flush();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return RealBufferedSink.this + ".outputStream()";
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream
|
||||
public void write(int i) throws IOException {
|
||||
RealBufferedSink realBufferedSink = RealBufferedSink.this;
|
||||
if (realBufferedSink.closed) {
|
||||
throw new IOException("closed");
|
||||
}
|
||||
realBufferedSink.buffer.writeByte((int) ((byte) i));
|
||||
RealBufferedSink.this.emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // java.io.OutputStream
|
||||
public void write(byte[] bArr, int i, int i2) throws IOException {
|
||||
RealBufferedSink realBufferedSink = RealBufferedSink.this;
|
||||
if (!realBufferedSink.closed) {
|
||||
realBufferedSink.buffer.write(bArr, i, i2);
|
||||
RealBufferedSink.this.emitCompleteSegments();
|
||||
return;
|
||||
}
|
||||
throw new IOException("closed");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public Timeout timeout() {
|
||||
return this.sink.timeout();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "buffer(" + this.sink + ")";
|
||||
}
|
||||
|
||||
@Override // okio.Sink
|
||||
public void write(Buffer buffer, long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.write(buffer, j);
|
||||
emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public long writeAll(Source source) throws IOException {
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("source == null");
|
||||
}
|
||||
long j = 0;
|
||||
while (true) {
|
||||
long read = source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI);
|
||||
if (read == -1) {
|
||||
return j;
|
||||
}
|
||||
j += read;
|
||||
emitCompleteSegments();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeByte(int i) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeByte(i);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeDecimalLong(long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeDecimalLong(j);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeHexadecimalUnsignedLong(long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeHexadecimalUnsignedLong(j);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeInt(int i) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeInt(i);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeIntLe(int i) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeIntLe(i);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeLong(long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeLong(j);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeLongLe(long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeLongLe(j);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeShort(int i) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeShort(i);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeShortLe(int i) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeShortLe(i);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeString(String str, Charset charset) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeString(str, charset);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeUtf8(String str) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeUtf8(str);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeUtf8CodePoint(int i) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
this.buffer.writeUtf8CodePoint(i);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink write(ByteString byteString) throws IOException {
|
||||
if (!this.closed) {
|
||||
this.buffer.write(byteString);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeString(String str, int i, int i2, Charset charset) throws IOException {
|
||||
if (!this.closed) {
|
||||
this.buffer.writeString(str, i, i2, charset);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink writeUtf8(String str, int i, int i2) throws IOException {
|
||||
if (!this.closed) {
|
||||
this.buffer.writeUtf8(str, i, i2);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink write(byte[] bArr) throws IOException {
|
||||
if (!this.closed) {
|
||||
this.buffer.write(bArr);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink write(byte[] bArr, int i, int i2) throws IOException {
|
||||
if (!this.closed) {
|
||||
this.buffer.write(bArr, i, i2);
|
||||
return emitCompleteSegments();
|
||||
}
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
|
||||
@Override // java.nio.channels.WritableByteChannel
|
||||
public int write(ByteBuffer byteBuffer) throws IOException {
|
||||
if (!this.closed) {
|
||||
int write = this.buffer.write(byteBuffer);
|
||||
emitCompleteSegments();
|
||||
return write;
|
||||
}
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSink
|
||||
public BufferedSink write(Source source, long j) throws IOException {
|
||||
while (j > 0) {
|
||||
long read = source.read(this.buffer, j);
|
||||
if (read != -1) {
|
||||
j -= read;
|
||||
emitCompleteSegments();
|
||||
} else {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
609
sources/okio/RealBufferedSource.java
Normal file
609
sources/okio/RealBufferedSource.java
Normal file
@@ -0,0 +1,609 @@
|
||||
package okio;
|
||||
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class RealBufferedSource implements BufferedSource {
|
||||
public final Buffer buffer = new Buffer();
|
||||
boolean closed;
|
||||
public final Source source;
|
||||
|
||||
RealBufferedSource(Source source) {
|
||||
if (source == null) {
|
||||
throw new NullPointerException("source == null");
|
||||
}
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource, okio.BufferedSink
|
||||
public Buffer buffer() {
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.closed = true;
|
||||
this.source.close();
|
||||
this.buffer.clear();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public boolean exhausted() throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
return this.buffer.exhausted() && this.source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long indexOf(byte b) throws IOException {
|
||||
return indexOf(b, 0L, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long indexOfElement(ByteString byteString) throws IOException {
|
||||
return indexOfElement(byteString, 0L);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public InputStream inputStream() {
|
||||
return new InputStream() { // from class: okio.RealBufferedSource.1
|
||||
@Override // java.io.InputStream
|
||||
public int available() throws IOException {
|
||||
RealBufferedSource realBufferedSource = RealBufferedSource.this;
|
||||
if (realBufferedSource.closed) {
|
||||
throw new IOException("closed");
|
||||
}
|
||||
return (int) Math.min(realBufferedSource.buffer.size, 2147483647L);
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
RealBufferedSource.this.close();
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int read() throws IOException {
|
||||
RealBufferedSource realBufferedSource = RealBufferedSource.this;
|
||||
if (realBufferedSource.closed) {
|
||||
throw new IOException("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;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return RealBufferedSource.this + ".inputStream()";
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int read(byte[] bArr, int i, int i2) throws IOException {
|
||||
if (!RealBufferedSource.this.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);
|
||||
}
|
||||
throw new IOException("closed");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // java.nio.channels.Channel
|
||||
public boolean isOpen() {
|
||||
return !this.closed;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public boolean rangeEquals(long j, ByteString byteString) throws IOException {
|
||||
return rangeEquals(j, byteString, 0, byteString.size());
|
||||
}
|
||||
|
||||
@Override // okio.Source
|
||||
public long read(Buffer buffer, long j) throws IOException {
|
||||
if (buffer == null) {
|
||||
throw new IllegalArgumentException("sink == null");
|
||||
}
|
||||
if (j < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + j);
|
||||
}
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("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 long readAll(Sink sink) throws IOException {
|
||||
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 byte readByte() throws IOException {
|
||||
require(1L);
|
||||
return this.buffer.readByte();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public byte[] readByteArray() throws IOException {
|
||||
this.buffer.writeAll(this.source);
|
||||
return this.buffer.readByteArray();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public ByteString readByteString() throws IOException {
|
||||
this.buffer.writeAll(this.source);
|
||||
return this.buffer.readByteString();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long readDecimalLong() throws IOException {
|
||||
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();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public void readFully(byte[] bArr) throws IOException {
|
||||
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) {
|
||||
throw e;
|
||||
}
|
||||
int read = buffer.read(bArr, i, (int) j);
|
||||
if (read == -1) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
i += read;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:20:0x0032, code lost:
|
||||
|
||||
if (r1 == 0) goto L21;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:22:0x0049, 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(r3)));
|
||||
*/
|
||||
@Override // okio.BufferedSource
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public long readHexadecimalUnsignedLong() throws java.io.IOException {
|
||||
/*
|
||||
r6 = this;
|
||||
r0 = 1
|
||||
r6.require(r0)
|
||||
r0 = 0
|
||||
r1 = 0
|
||||
L7:
|
||||
int r2 = r1 + 1
|
||||
long r3 = (long) r2
|
||||
boolean r3 = r6.request(r3)
|
||||
if (r3 == 0) goto L4a
|
||||
okio.Buffer r3 = r6.buffer
|
||||
long r4 = (long) r1
|
||||
byte r3 = r3.getByte(r4)
|
||||
r4 = 48
|
||||
if (r3 < r4) goto L1f
|
||||
r4 = 57
|
||||
if (r3 <= r4) goto L30
|
||||
L1f:
|
||||
r4 = 97
|
||||
if (r3 < r4) goto L27
|
||||
r4 = 102(0x66, float:1.43E-43)
|
||||
if (r3 <= r4) goto L30
|
||||
L27:
|
||||
r4 = 65
|
||||
if (r3 < r4) goto L32
|
||||
r4 = 70
|
||||
if (r3 <= r4) goto L30
|
||||
goto L32
|
||||
L30:
|
||||
r1 = r2
|
||||
goto L7
|
||||
L32:
|
||||
if (r1 == 0) goto L35
|
||||
goto L4a
|
||||
L35:
|
||||
java.lang.NumberFormatException r1 = new java.lang.NumberFormatException
|
||||
r2 = 1
|
||||
java.lang.Object[] r2 = new java.lang.Object[r2]
|
||||
java.lang.Byte r3 = java.lang.Byte.valueOf(r3)
|
||||
r2[r0] = r3
|
||||
java.lang.String r0 = "Expected leading [0-9a-fA-F] character but was %#x"
|
||||
java.lang.String r0 = java.lang.String.format(r0, r2)
|
||||
r1.<init>(r0)
|
||||
throw r1
|
||||
L4a:
|
||||
okio.Buffer r0 = r6.buffer
|
||||
long r0 = r0.readHexadecimalUnsignedLong()
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: okio.RealBufferedSource.readHexadecimalUnsignedLong():long");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public int readInt() throws IOException {
|
||||
require(4L);
|
||||
return this.buffer.readInt();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public int readIntLe() throws IOException {
|
||||
require(4L);
|
||||
return this.buffer.readIntLe();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long readLong() throws IOException {
|
||||
require(8L);
|
||||
return this.buffer.readLong();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long readLongLe() throws IOException {
|
||||
require(8L);
|
||||
return this.buffer.readLongLe();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public short readShort() throws IOException {
|
||||
require(2L);
|
||||
return this.buffer.readShort();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public short readShortLe() throws IOException {
|
||||
require(2L);
|
||||
return this.buffer.readShortLe();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readString(Charset charset) throws IOException {
|
||||
if (charset == null) {
|
||||
throw new IllegalArgumentException("charset == null");
|
||||
}
|
||||
this.buffer.writeAll(this.source);
|
||||
return this.buffer.readString(charset);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readUtf8() throws IOException {
|
||||
this.buffer.writeAll(this.source);
|
||||
return this.buffer.readUtf8();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public int readUtf8CodePoint() throws IOException {
|
||||
require(1L);
|
||||
byte b = this.buffer.getByte(0L);
|
||||
if ((b & 224) == 192) {
|
||||
require(2L);
|
||||
} else if ((b & 240) == 224) {
|
||||
require(3L);
|
||||
} else if ((b & 248) == 240) {
|
||||
require(4L);
|
||||
}
|
||||
return this.buffer.readUtf8CodePoint();
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readUtf8Line() throws IOException {
|
||||
long indexOf = indexOf((byte) 10);
|
||||
if (indexOf != -1) {
|
||||
return this.buffer.readUtf8Line(indexOf);
|
||||
}
|
||||
long j = this.buffer.size;
|
||||
if (j != 0) {
|
||||
return readUtf8(j);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readUtf8LineStrict() throws IOException {
|
||||
return readUtf8LineStrict(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public boolean request(long j) throws IOException {
|
||||
Buffer buffer;
|
||||
if (j < 0) {
|
||||
throw new IllegalArgumentException("byteCount < 0: " + j);
|
||||
}
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("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 void require(long j) throws IOException {
|
||||
if (!request(j)) {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public int select(Options options) throws IOException {
|
||||
Buffer buffer;
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
do {
|
||||
int selectPrefix = this.buffer.selectPrefix(options);
|
||||
if (selectPrefix == -1) {
|
||||
return -1;
|
||||
}
|
||||
long size = options.byteStrings[selectPrefix].size();
|
||||
buffer = this.buffer;
|
||||
if (size <= buffer.size) {
|
||||
buffer.skip(size);
|
||||
return selectPrefix;
|
||||
}
|
||||
} while (this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public void skip(long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("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.Source
|
||||
public Timeout timeout() {
|
||||
return this.source.timeout();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "buffer(" + this.source + ")";
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long indexOf(byte b, long j) throws IOException {
|
||||
return indexOf(b, j, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long indexOfElement(ByteString byteString, long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
while (true) {
|
||||
long indexOfElement = this.buffer.indexOfElement(byteString, j);
|
||||
if (indexOfElement != -1) {
|
||||
return indexOfElement;
|
||||
}
|
||||
Buffer buffer = this.buffer;
|
||||
long j2 = buffer.size;
|
||||
if (this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
||||
return -1L;
|
||||
}
|
||||
j = Math.max(j, j2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public boolean rangeEquals(long j, ByteString byteString, int i, int i2) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
if (j < 0 || i < 0 || i2 < 0 || byteString.size() - i < i2) {
|
||||
return false;
|
||||
}
|
||||
for (int i3 = 0; i3 < i2; i3++) {
|
||||
long j2 = i3 + j;
|
||||
if (!request(1 + j2) || this.buffer.getByte(j2) != byteString.getByte(i + i3)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readUtf8LineStrict(long j) throws IOException {
|
||||
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 long indexOf(byte b, long j, long j2) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("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 byte[] readByteArray(long j) throws IOException {
|
||||
require(j);
|
||||
return this.buffer.readByteArray(j);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public ByteString readByteString(long j) throws IOException {
|
||||
require(j);
|
||||
return this.buffer.readByteString(j);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readUtf8(long j) throws IOException {
|
||||
require(j);
|
||||
return this.buffer.readUtf8(j);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public String readString(long j, Charset charset) throws IOException {
|
||||
require(j);
|
||||
if (charset != null) {
|
||||
return this.buffer.readString(j, charset);
|
||||
}
|
||||
throw new IllegalArgumentException("charset == null");
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public void readFully(Buffer buffer, long j) throws IOException {
|
||||
try {
|
||||
require(j);
|
||||
this.buffer.readFully(buffer, j);
|
||||
} catch (EOFException e) {
|
||||
buffer.writeAll(this.buffer);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public int read(byte[] bArr) throws IOException {
|
||||
return read(bArr, 0, bArr.length);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public int read(byte[] bArr, int i, int i2) throws IOException {
|
||||
long j = i2;
|
||||
Util.checkOffsetAndCount(bArr.length, i, j);
|
||||
Buffer buffer = this.buffer;
|
||||
if (buffer.size == 0 && this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
||||
return -1;
|
||||
}
|
||||
return this.buffer.read(bArr, i, (int) Math.min(j, this.buffer.size));
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long indexOf(ByteString byteString) throws IOException {
|
||||
return indexOf(byteString, 0L);
|
||||
}
|
||||
|
||||
@Override // okio.BufferedSource
|
||||
public long indexOf(ByteString byteString, long j) throws IOException {
|
||||
if (this.closed) {
|
||||
throw new IllegalStateException("closed");
|
||||
}
|
||||
while (true) {
|
||||
long indexOf = this.buffer.indexOf(byteString, j);
|
||||
if (indexOf != -1) {
|
||||
return indexOf;
|
||||
}
|
||||
Buffer buffer = this.buffer;
|
||||
long j2 = buffer.size;
|
||||
if (this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
|
||||
return -1L;
|
||||
}
|
||||
j = Math.max(j, (j2 - byteString.size()) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.nio.channels.ReadableByteChannel
|
||||
public int read(ByteBuffer byteBuffer) throws IOException {
|
||||
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);
|
||||
}
|
||||
}
|
114
sources/okio/Segment.java
Normal file
114
sources/okio/Segment.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package okio;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class Segment {
|
||||
static final int SHARE_MINIMUM = 1024;
|
||||
static final int SIZE = 8192;
|
||||
final byte[] data;
|
||||
int limit;
|
||||
Segment next;
|
||||
boolean owner;
|
||||
int pos;
|
||||
Segment prev;
|
||||
boolean shared;
|
||||
|
||||
Segment() {
|
||||
this.data = new byte[8192];
|
||||
this.owner = true;
|
||||
this.shared = false;
|
||||
}
|
||||
|
||||
public void compact() {
|
||||
Segment segment = this.prev;
|
||||
if (segment == this) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (segment.owner) {
|
||||
int i = this.limit - this.pos;
|
||||
if (i > (8192 - segment.limit) + (segment.shared ? 0 : segment.pos)) {
|
||||
return;
|
||||
}
|
||||
writeTo(this.prev, i);
|
||||
pop();
|
||||
SegmentPool.recycle(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Segment pop() {
|
||||
Segment segment = this.next;
|
||||
if (segment == this) {
|
||||
segment = null;
|
||||
}
|
||||
Segment segment2 = this.prev;
|
||||
segment2.next = this.next;
|
||||
this.next.prev = segment2;
|
||||
this.next = null;
|
||||
this.prev = null;
|
||||
return segment;
|
||||
}
|
||||
|
||||
public Segment push(Segment segment) {
|
||||
segment.prev = this;
|
||||
segment.next = this.next;
|
||||
this.next.prev = segment;
|
||||
this.next = segment;
|
||||
return segment;
|
||||
}
|
||||
|
||||
Segment sharedCopy() {
|
||||
this.shared = true;
|
||||
return new Segment(this.data, this.pos, this.limit, true, false);
|
||||
}
|
||||
|
||||
public Segment split(int i) {
|
||||
Segment take;
|
||||
if (i <= 0 || i > this.limit - this.pos) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (i >= 1024) {
|
||||
take = sharedCopy();
|
||||
} else {
|
||||
take = SegmentPool.take();
|
||||
System.arraycopy(this.data, this.pos, take.data, 0, i);
|
||||
}
|
||||
take.limit = take.pos + i;
|
||||
this.pos += i;
|
||||
this.prev.push(take);
|
||||
return take;
|
||||
}
|
||||
|
||||
Segment unsharedCopy() {
|
||||
return new Segment((byte[]) this.data.clone(), this.pos, this.limit, false, true);
|
||||
}
|
||||
|
||||
public void writeTo(Segment segment, int i) {
|
||||
if (!segment.owner) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
int i2 = segment.limit;
|
||||
if (i2 + i > 8192) {
|
||||
if (segment.shared) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
int i3 = segment.pos;
|
||||
if ((i2 + i) - i3 > 8192) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
byte[] bArr = segment.data;
|
||||
System.arraycopy(bArr, i3, bArr, 0, i2 - i3);
|
||||
segment.limit -= segment.pos;
|
||||
segment.pos = 0;
|
||||
}
|
||||
System.arraycopy(this.data, this.pos, segment.data, segment.limit, i);
|
||||
segment.limit += i;
|
||||
this.pos += i;
|
||||
}
|
||||
|
||||
Segment(byte[] bArr, int i, int i2, boolean z, boolean z2) {
|
||||
this.data = bArr;
|
||||
this.pos = i;
|
||||
this.limit = i2;
|
||||
this.shared = z;
|
||||
this.owner = z2;
|
||||
}
|
||||
}
|
45
sources/okio/SegmentPool.java
Normal file
45
sources/okio/SegmentPool.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package okio;
|
||||
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class SegmentPool {
|
||||
static final long MAX_SIZE = 65536;
|
||||
static long byteCount;
|
||||
static Segment next;
|
||||
|
||||
private SegmentPool() {
|
||||
}
|
||||
|
||||
static void recycle(Segment segment) {
|
||||
if (segment.next != null || segment.prev != null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (segment.shared) {
|
||||
return;
|
||||
}
|
||||
synchronized (SegmentPool.class) {
|
||||
if (byteCount + PlaybackStateCompat.ACTION_PLAY_FROM_URI > 65536) {
|
||||
return;
|
||||
}
|
||||
byteCount += PlaybackStateCompat.ACTION_PLAY_FROM_URI;
|
||||
segment.next = next;
|
||||
segment.limit = 0;
|
||||
segment.pos = 0;
|
||||
next = segment;
|
||||
}
|
||||
}
|
||||
|
||||
static Segment take() {
|
||||
synchronized (SegmentPool.class) {
|
||||
if (next == null) {
|
||||
return new Segment();
|
||||
}
|
||||
Segment segment = next;
|
||||
next = segment.next;
|
||||
segment.next = null;
|
||||
byteCount -= PlaybackStateCompat.ACTION_PLAY_FROM_URI;
|
||||
return segment;
|
||||
}
|
||||
}
|
||||
}
|
318
sources/okio/SegmentedByteString.java
Normal file
318
sources/okio/SegmentedByteString.java
Normal file
@@ -0,0 +1,318 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class SegmentedByteString extends ByteString {
|
||||
final transient int[] directory;
|
||||
final transient byte[][] segments;
|
||||
|
||||
SegmentedByteString(Buffer buffer, int i) {
|
||||
super(null);
|
||||
Util.checkOffsetAndCount(buffer.size, 0L, i);
|
||||
int i2 = 0;
|
||||
Segment segment = buffer.head;
|
||||
int i3 = 0;
|
||||
int i4 = 0;
|
||||
while (i3 < i) {
|
||||
int i5 = segment.limit;
|
||||
int i6 = segment.pos;
|
||||
if (i5 == i6) {
|
||||
throw new AssertionError("s.limit == s.pos");
|
||||
}
|
||||
i3 += i5 - i6;
|
||||
i4++;
|
||||
segment = segment.next;
|
||||
}
|
||||
this.segments = new byte[i4][];
|
||||
this.directory = new int[i4 * 2];
|
||||
Segment segment2 = buffer.head;
|
||||
int i7 = 0;
|
||||
while (i2 < i) {
|
||||
this.segments[i7] = segment2.data;
|
||||
i2 += segment2.limit - segment2.pos;
|
||||
if (i2 > i) {
|
||||
i2 = i;
|
||||
}
|
||||
int[] iArr = this.directory;
|
||||
iArr[i7] = i2;
|
||||
iArr[this.segments.length + i7] = segment2.pos;
|
||||
segment2.shared = true;
|
||||
i7++;
|
||||
segment2 = segment2.next;
|
||||
}
|
||||
}
|
||||
|
||||
private int segment(int i) {
|
||||
int binarySearch = Arrays.binarySearch(this.directory, 0, this.segments.length, i + 1);
|
||||
return binarySearch >= 0 ? binarySearch : ~binarySearch;
|
||||
}
|
||||
|
||||
private ByteString toByteString() {
|
||||
return new ByteString(toByteArray());
|
||||
}
|
||||
|
||||
private Object writeReplace() {
|
||||
return toByteString();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteBuffer asByteBuffer() {
|
||||
return ByteBuffer.wrap(toByteArray()).asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public String base64() {
|
||||
return toByteString().base64();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public String base64Url() {
|
||||
return toByteString().base64Url();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ByteString) {
|
||||
ByteString byteString = (ByteString) obj;
|
||||
if (byteString.size() == size() && rangeEquals(0, byteString, 0, size())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public byte getByte(int i) {
|
||||
Util.checkOffsetAndCount(this.directory[this.segments.length - 1], i, 1L);
|
||||
int segment = segment(i);
|
||||
int i2 = segment == 0 ? 0 : this.directory[segment - 1];
|
||||
int[] iArr = this.directory;
|
||||
byte[][] bArr = this.segments;
|
||||
return bArr[segment][(i - i2) + iArr[bArr.length + segment]];
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public int hashCode() {
|
||||
int i = this.hashCode;
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
int length = this.segments.length;
|
||||
int i2 = 0;
|
||||
int i3 = 1;
|
||||
int i4 = 0;
|
||||
while (i2 < length) {
|
||||
byte[] bArr = this.segments[i2];
|
||||
int[] iArr = this.directory;
|
||||
int i5 = iArr[length + i2];
|
||||
int i6 = iArr[i2];
|
||||
int i7 = (i6 - i4) + i5;
|
||||
while (i5 < i7) {
|
||||
i3 = (i3 * 31) + bArr[i5];
|
||||
i5++;
|
||||
}
|
||||
i2++;
|
||||
i4 = i6;
|
||||
}
|
||||
this.hashCode = i3;
|
||||
return i3;
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public String hex() {
|
||||
return toByteString().hex();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString hmacSha1(ByteString byteString) {
|
||||
return toByteString().hmacSha1(byteString);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString hmacSha256(ByteString byteString) {
|
||||
return toByteString().hmacSha256(byteString);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public int indexOf(byte[] bArr, int i) {
|
||||
return toByteString().indexOf(bArr, i);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
byte[] internalArray() {
|
||||
return toByteArray();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public int lastIndexOf(byte[] bArr, int i) {
|
||||
return toByteString().lastIndexOf(bArr, i);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString md5() {
|
||||
return toByteString().md5();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public boolean rangeEquals(int i, ByteString byteString, int i2, int i3) {
|
||||
if (i < 0 || i > size() - i3) {
|
||||
return false;
|
||||
}
|
||||
int segment = segment(i);
|
||||
while (i3 > 0) {
|
||||
int i4 = segment == 0 ? 0 : this.directory[segment - 1];
|
||||
int min = Math.min(i3, ((this.directory[segment] - i4) + i4) - i);
|
||||
int[] iArr = this.directory;
|
||||
byte[][] bArr = this.segments;
|
||||
if (!byteString.rangeEquals(i2, bArr[segment], (i - i4) + iArr[bArr.length + segment], min)) {
|
||||
return false;
|
||||
}
|
||||
i += min;
|
||||
i2 += min;
|
||||
i3 -= min;
|
||||
segment++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString sha1() {
|
||||
return toByteString().sha1();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString sha256() {
|
||||
return toByteString().sha256();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public int size() {
|
||||
return this.directory[this.segments.length - 1];
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public String string(Charset charset) {
|
||||
return toByteString().string(charset);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString substring(int i) {
|
||||
return toByteString().substring(i);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString toAsciiLowercase() {
|
||||
return toByteString().toAsciiLowercase();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString toAsciiUppercase() {
|
||||
return toByteString().toAsciiUppercase();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public byte[] toByteArray() {
|
||||
int[] iArr = this.directory;
|
||||
byte[][] bArr = this.segments;
|
||||
byte[] bArr2 = new byte[iArr[bArr.length - 1]];
|
||||
int length = bArr.length;
|
||||
int i = 0;
|
||||
int i2 = 0;
|
||||
while (i < length) {
|
||||
int[] iArr2 = this.directory;
|
||||
int i3 = iArr2[length + i];
|
||||
int i4 = iArr2[i];
|
||||
System.arraycopy(this.segments[i], i3, bArr2, i2, i4 - i2);
|
||||
i++;
|
||||
i2 = i4;
|
||||
}
|
||||
return bArr2;
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public String toString() {
|
||||
return toByteString().toString();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public String utf8() {
|
||||
return toByteString().utf8();
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
if (outputStream == null) {
|
||||
throw new IllegalArgumentException("out == null");
|
||||
}
|
||||
int length = this.segments.length;
|
||||
int i = 0;
|
||||
int i2 = 0;
|
||||
while (i < length) {
|
||||
int[] iArr = this.directory;
|
||||
int i3 = iArr[length + i];
|
||||
int i4 = iArr[i];
|
||||
outputStream.write(this.segments[i], i3, i4 - i2);
|
||||
i++;
|
||||
i2 = i4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public ByteString substring(int i, int i2) {
|
||||
return toByteString().substring(i, i2);
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
void write(Buffer buffer) {
|
||||
int length = this.segments.length;
|
||||
int i = 0;
|
||||
int i2 = 0;
|
||||
while (i < length) {
|
||||
int[] iArr = this.directory;
|
||||
int i3 = iArr[length + i];
|
||||
int i4 = iArr[i];
|
||||
Segment segment = new Segment(this.segments[i], i3, (i3 + i4) - i2, true, false);
|
||||
Segment segment2 = buffer.head;
|
||||
if (segment2 == null) {
|
||||
segment.prev = segment;
|
||||
segment.next = segment;
|
||||
buffer.head = segment;
|
||||
} else {
|
||||
segment2.prev.push(segment);
|
||||
}
|
||||
i++;
|
||||
i2 = i4;
|
||||
}
|
||||
buffer.size += i2;
|
||||
}
|
||||
|
||||
@Override // okio.ByteString
|
||||
public boolean rangeEquals(int i, byte[] bArr, int i2, int i3) {
|
||||
if (i < 0 || i > size() - i3 || i2 < 0 || i2 > bArr.length - i3) {
|
||||
return false;
|
||||
}
|
||||
int segment = segment(i);
|
||||
while (i3 > 0) {
|
||||
int i4 = segment == 0 ? 0 : this.directory[segment - 1];
|
||||
int min = Math.min(i3, ((this.directory[segment] - i4) + i4) - i);
|
||||
int[] iArr = this.directory;
|
||||
byte[][] bArr2 = this.segments;
|
||||
if (!Util.arrayRangeEquals(bArr2[segment], (i - i4) + iArr[bArr2.length + segment], bArr, i2, min)) {
|
||||
return false;
|
||||
}
|
||||
i += min;
|
||||
i2 += min;
|
||||
i3 -= min;
|
||||
segment++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
17
sources/okio/Sink.java
Normal file
17
sources/okio/Sink.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package okio;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.Flushable;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Sink extends Closeable, Flushable {
|
||||
@Override // java.io.Closeable, java.lang.AutoCloseable
|
||||
void close() throws IOException;
|
||||
|
||||
void flush() throws IOException;
|
||||
|
||||
Timeout timeout();
|
||||
|
||||
void write(Buffer buffer, long j) throws IOException;
|
||||
}
|
14
sources/okio/Source.java
Normal file
14
sources/okio/Source.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package okio;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Source extends Closeable {
|
||||
@Override // java.io.Closeable, java.lang.AutoCloseable
|
||||
void close() throws IOException;
|
||||
|
||||
long read(Buffer buffer, long j) throws IOException;
|
||||
|
||||
Timeout timeout();
|
||||
}
|
117
sources/okio/Timeout.java
Normal file
117
sources/okio/Timeout.java
Normal file
@@ -0,0 +1,117 @@
|
||||
package okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Timeout {
|
||||
public static final Timeout NONE = new Timeout() { // from class: okio.Timeout.1
|
||||
@Override // okio.Timeout
|
||||
public Timeout deadlineNanoTime(long j) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public void throwIfReached() throws IOException {
|
||||
}
|
||||
|
||||
@Override // okio.Timeout
|
||||
public Timeout timeout(long j, TimeUnit timeUnit) {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
private long deadlineNanoTime;
|
||||
private boolean hasDeadline;
|
||||
private long timeoutNanos;
|
||||
|
||||
public Timeout clearDeadline() {
|
||||
this.hasDeadline = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Timeout clearTimeout() {
|
||||
this.timeoutNanos = 0L;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Timeout deadline(long j, TimeUnit timeUnit) {
|
||||
if (j > 0) {
|
||||
if (timeUnit != null) {
|
||||
return deadlineNanoTime(System.nanoTime() + timeUnit.toNanos(j));
|
||||
}
|
||||
throw new IllegalArgumentException("unit == null");
|
||||
}
|
||||
throw new IllegalArgumentException("duration <= 0: " + j);
|
||||
}
|
||||
|
||||
public long deadlineNanoTime() {
|
||||
if (this.hasDeadline) {
|
||||
return this.deadlineNanoTime;
|
||||
}
|
||||
throw new IllegalStateException("No deadline");
|
||||
}
|
||||
|
||||
public boolean hasDeadline() {
|
||||
return this.hasDeadline;
|
||||
}
|
||||
|
||||
public void throwIfReached() throws IOException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedIOException("thread interrupted");
|
||||
}
|
||||
if (this.hasDeadline && this.deadlineNanoTime - System.nanoTime() <= 0) {
|
||||
throw new InterruptedIOException("deadline reached");
|
||||
}
|
||||
}
|
||||
|
||||
public Timeout timeout(long j, TimeUnit timeUnit) {
|
||||
if (j >= 0) {
|
||||
if (timeUnit == null) {
|
||||
throw new IllegalArgumentException("unit == null");
|
||||
}
|
||||
this.timeoutNanos = timeUnit.toNanos(j);
|
||||
return this;
|
||||
}
|
||||
throw new IllegalArgumentException("timeout < 0: " + j);
|
||||
}
|
||||
|
||||
public long timeoutNanos() {
|
||||
return this.timeoutNanos;
|
||||
}
|
||||
|
||||
public final void waitUntilNotified(Object obj) throws InterruptedIOException {
|
||||
try {
|
||||
boolean hasDeadline = hasDeadline();
|
||||
long timeoutNanos = timeoutNanos();
|
||||
long j = 0;
|
||||
if (!hasDeadline && timeoutNanos == 0) {
|
||||
obj.wait();
|
||||
return;
|
||||
}
|
||||
long nanoTime = System.nanoTime();
|
||||
if (hasDeadline && timeoutNanos != 0) {
|
||||
timeoutNanos = Math.min(timeoutNanos, deadlineNanoTime() - nanoTime);
|
||||
} else if (hasDeadline) {
|
||||
timeoutNanos = deadlineNanoTime() - nanoTime;
|
||||
}
|
||||
if (timeoutNanos > 0) {
|
||||
long j2 = timeoutNanos / 1000000;
|
||||
Long.signum(j2);
|
||||
obj.wait(j2, (int) (timeoutNanos - (1000000 * j2)));
|
||||
j = System.nanoTime() - nanoTime;
|
||||
}
|
||||
if (j >= timeoutNanos) {
|
||||
throw new InterruptedIOException("timeout");
|
||||
}
|
||||
} catch (InterruptedException unused) {
|
||||
throw new InterruptedIOException("interrupted");
|
||||
}
|
||||
}
|
||||
|
||||
public Timeout deadlineNanoTime(long j) {
|
||||
this.hasDeadline = true;
|
||||
this.deadlineNanoTime = j;
|
||||
return this;
|
||||
}
|
||||
}
|
53
sources/okio/Utf8.java
Normal file
53
sources/okio/Utf8.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package okio;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class Utf8 {
|
||||
private Utf8() {
|
||||
}
|
||||
|
||||
public static long size(String str) {
|
||||
return size(str, 0, str.length());
|
||||
}
|
||||
|
||||
public static long size(String str, int i, int i2) {
|
||||
long j;
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("string == null");
|
||||
}
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("beginIndex < 0: " + i);
|
||||
}
|
||||
if (i2 < i) {
|
||||
throw new IllegalArgumentException("endIndex < beginIndex: " + i2 + " < " + i);
|
||||
}
|
||||
if (i2 > str.length()) {
|
||||
throw new IllegalArgumentException("endIndex > string.length: " + i2 + " > " + str.length());
|
||||
}
|
||||
long j2 = 0;
|
||||
while (i < i2) {
|
||||
char charAt = str.charAt(i);
|
||||
if (charAt < 128) {
|
||||
j2++;
|
||||
} else {
|
||||
if (charAt < 2048) {
|
||||
j = 2;
|
||||
} else if (charAt < 55296 || charAt > 57343) {
|
||||
j = 3;
|
||||
} else {
|
||||
int i3 = i + 1;
|
||||
char charAt2 = i3 < i2 ? str.charAt(i3) : (char) 0;
|
||||
if (charAt > 56319 || charAt2 < 56320 || charAt2 > 57343) {
|
||||
j2++;
|
||||
i = i3;
|
||||
} else {
|
||||
j2 += 4;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
j2 += j;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return j2;
|
||||
}
|
||||
}
|
47
sources/okio/Util.java
Normal file
47
sources/okio/Util.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package okio;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class Util {
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private Util() {
|
||||
}
|
||||
|
||||
public static boolean arrayRangeEquals(byte[] bArr, int i, byte[] bArr2, int i2, int i3) {
|
||||
for (int i4 = 0; i4 < i3; i4++) {
|
||||
if (bArr[i4 + i] != bArr2[i4 + i2]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void checkOffsetAndCount(long j, long j2, long j3) {
|
||||
if ((j2 | j3) < 0 || j2 > j || j - j2 < j3) {
|
||||
throw new ArrayIndexOutOfBoundsException(String.format("size=%s offset=%s byteCount=%s", Long.valueOf(j), Long.valueOf(j2), Long.valueOf(j3)));
|
||||
}
|
||||
}
|
||||
|
||||
public static int reverseBytesInt(int i) {
|
||||
return ((i & 255) << 24) | (((-16777216) & i) >>> 24) | ((16711680 & i) >>> 8) | ((65280 & i) << 8);
|
||||
}
|
||||
|
||||
public static long reverseBytesLong(long j) {
|
||||
return ((j & 255) << 56) | (((-72057594037927936L) & j) >>> 56) | ((71776119061217280L & j) >>> 40) | ((280375465082880L & j) >>> 24) | ((1095216660480L & j) >>> 8) | ((4278190080L & j) << 8) | ((16711680 & j) << 24) | ((65280 & j) << 40);
|
||||
}
|
||||
|
||||
public static short reverseBytesShort(short s) {
|
||||
int i = s & 65535;
|
||||
return (short) (((i & 255) << 8) | ((65280 & i) >>> 8));
|
||||
}
|
||||
|
||||
public static void sneakyRethrow(Throwable th) {
|
||||
sneakyThrow2(th);
|
||||
}
|
||||
|
||||
private static <T extends Throwable> void sneakyThrow2(Throwable th) throws Throwable {
|
||||
throw th;
|
||||
}
|
||||
}
|
3
sources/okio/package-info.java
Normal file
3
sources/okio/package-info.java
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
package okio;
|
||||
|
Reference in New Issue
Block a user