Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,322 @@
package com.mbridge.msdk.thrid.okio;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.annotation.Nullable;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.TimeUnit;
/* loaded from: classes4.dex */
public class AsyncTimeout extends Timeout {
private static final long IDLE_TIMEOUT_MILLIS;
private static final long IDLE_TIMEOUT_NANOS;
private static final int TIMEOUT_WRITE_SIZE = 65536;
@Nullable
static AsyncTimeout head;
private boolean inQueue;
@Nullable
private AsyncTimeout next;
private long timeoutAt;
private long remainingNanos(long j) {
return this.timeoutAt - j;
}
public void timedOut() {
}
static {
long millis = TimeUnit.SECONDS.toMillis(60L);
IDLE_TIMEOUT_MILLIS = millis;
IDLE_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(millis);
}
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);
}
}
private static synchronized void scheduleTimeout(AsyncTimeout asyncTimeout, long j, boolean z) {
synchronized (AsyncTimeout.class) {
try {
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) {
asyncTimeout.timeoutAt = asyncTimeout.deadlineNanoTime();
} else {
throw new AssertionError();
}
long remainingNanos = asyncTimeout.remainingNanos(nanoTime);
AsyncTimeout asyncTimeout2 = head;
while (true) {
AsyncTimeout asyncTimeout3 = asyncTimeout2.next;
if (asyncTimeout3 == null || remainingNanos < asyncTimeout3.remainingNanos(nanoTime)) {
break;
} else {
asyncTimeout2 = asyncTimeout2.next;
}
}
asyncTimeout.next = asyncTimeout2.next;
asyncTimeout2.next = asyncTimeout;
if (asyncTimeout2 == head) {
AsyncTimeout.class.notify();
}
} catch (Throwable th) {
throw th;
}
}
}
public final boolean exit() {
if (!this.inQueue) {
return false;
}
this.inQueue = false;
return cancelScheduledTimeout(this);
}
private static synchronized boolean cancelScheduledTimeout(AsyncTimeout asyncTimeout) {
synchronized (AsyncTimeout.class) {
AsyncTimeout asyncTimeout2 = head;
while (asyncTimeout2 != null) {
AsyncTimeout asyncTimeout3 = asyncTimeout2.next;
if (asyncTimeout3 == asyncTimeout) {
asyncTimeout2.next = asyncTimeout.next;
asyncTimeout.next = null;
return false;
}
asyncTimeout2 = asyncTimeout3;
}
return true;
}
}
public final Sink sink(final Sink sink) {
return new Sink() { // from class: com.mbridge.msdk.thrid.okio.AsyncTimeout.1
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return AsyncTimeout.this;
}
@Override // com.mbridge.msdk.thrid.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;
}
}
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.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;
}
}
public String toString() {
return "AsyncTimeout.sink(" + sink + ")";
}
};
}
public final Source source(final Source source) {
return new Source() { // from class: com.mbridge.msdk.thrid.okio.AsyncTimeout.2
@Override // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return AsyncTimeout.this;
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.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;
}
}
public String toString() {
return "AsyncTimeout.source(" + source + ")";
}
};
}
public final void exit(boolean z) throws IOException {
if (exit() && z) {
throw newTimeoutException(null);
}
}
public final IOException exit(IOException iOException) throws IOException {
return !exit() ? iOException : newTimeoutException(iOException);
}
public IOException newTimeoutException(@Nullable IOException iOException) {
InterruptedIOException interruptedIOException = new InterruptedIOException("timeout");
if (iOException != null) {
interruptedIOException.initCause(iOException);
}
return interruptedIOException;
}
public static final class Watchdog extends Thread {
public Watchdog() {
super("Okio Watchdog");
setDaemon(true);
}
/* JADX WARN: Code restructure failed: missing block: B:19:0x0017, code lost:
r1.timedOut();
*/
@Override // java.lang.Thread, java.lang.Runnable
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void run() {
/*
r3 = this;
L0:
java.lang.Class<com.mbridge.msdk.thrid.okio.AsyncTimeout> r0 = com.mbridge.msdk.thrid.okio.AsyncTimeout.class
monitor-enter(r0) // Catch: java.lang.InterruptedException -> L0
com.mbridge.msdk.thrid.okio.AsyncTimeout r1 = com.mbridge.msdk.thrid.okio.AsyncTimeout.awaitTimeout() // Catch: java.lang.Throwable -> Lb
if (r1 != 0) goto Ld
monitor-exit(r0) // Catch: java.lang.Throwable -> Lb
goto L0
Lb:
r1 = move-exception
goto L1b
Ld:
com.mbridge.msdk.thrid.okio.AsyncTimeout r2 = com.mbridge.msdk.thrid.okio.AsyncTimeout.head // Catch: java.lang.Throwable -> Lb
if (r1 != r2) goto L16
r1 = 0
com.mbridge.msdk.thrid.okio.AsyncTimeout.head = r1 // Catch: java.lang.Throwable -> Lb
monitor-exit(r0) // Catch: java.lang.Throwable -> Lb
return
L16:
monitor-exit(r0) // Catch: java.lang.Throwable -> Lb
r1.timedOut() // Catch: java.lang.InterruptedException -> L0
goto L0
L1b:
monitor-exit(r0) // Catch: java.lang.Throwable -> Lb
throw r1 // Catch: java.lang.InterruptedException -> L0
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.thrid.okio.AsyncTimeout.Watchdog.run():void");
}
}
@Nullable
public 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;
}
}

View File

@@ -0,0 +1,118 @@
package com.mbridge.msdk.thrid.okio;
import com.applovin.exoplayer2.common.base.Ascii;
import java.io.UnsupportedEncodingException;
/* loaded from: classes4.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--;
}
int i2 = (int) ((length * 6) / 8);
byte[] bArr = new byte[i2];
int i3 = 0;
int i4 = 0;
int i5 = 0;
for (int i6 = 0; i6 < length; i6++) {
char charAt2 = str.charAt(i6);
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;
}
}
i4 = (i4 << 6) | ((byte) i);
i3++;
if (i3 % 4 == 0) {
bArr[i5] = (byte) (i4 >> 16);
int i7 = i5 + 2;
bArr[i5 + 1] = (byte) (i4 >> 8);
i5 += 3;
bArr[i7] = (byte) i4;
}
}
int i8 = i3 % 4;
if (i8 == 1) {
return null;
}
if (i8 == 2) {
bArr[i5] = (byte) ((i4 << 12) >> 16);
i5++;
} else if (i8 == 3) {
int i9 = i4 << 6;
int i10 = i5 + 1;
bArr[i5] = (byte) (i9 >> 16);
i5 += 2;
bArr[i10] = (byte) (i9 >> 8);
}
if (i5 == i2) {
return bArr;
}
byte[] bArr2 = new byte[i5];
System.arraycopy(bArr, 0, bArr2, 0, i5);
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) {
bArr3[i] = bArr2[(bArr[i2] & 255) >> 2];
int i3 = i2 + 1;
bArr3[i + 1] = bArr2[((bArr[i2] & 3) << 4) | ((bArr[i3] & 255) >> 4)];
int i4 = i + 3;
int i5 = (bArr[i3] & Ascii.SI) << 2;
int i6 = i2 + 2;
bArr3[i + 2] = bArr2[i5 | ((bArr[i6] & 255) >> 6)];
i += 4;
bArr3[i4] = bArr2[bArr[i6] & 63];
}
int length2 = bArr.length % 3;
if (length2 == 1) {
bArr3[i] = bArr2[(bArr[length] & 255) >> 2];
bArr3[i + 1] = bArr2[(bArr[length] & 3) << 4];
bArr3[i + 2] = 61;
bArr3[i + 3] = 61;
} else if (length2 == 2) {
bArr3[i] = bArr2[(bArr[length] & 255) >> 2];
int i7 = (bArr[length] & 3) << 4;
int i8 = length + 1;
bArr3[i + 1] = bArr2[((bArr[i8] & 255) >> 4) | i7];
bArr3[i + 2] = bArr2[(bArr[i8] & Ascii.SI) << 2];
bArr3[i + 3] = 61;
}
try {
return new String(bArr3, "US-ASCII");
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.channels.WritableByteChannel;
import java.nio.charset.Charset;
/* loaded from: classes4.dex */
public interface BufferedSink extends Sink, WritableByteChannel {
Buffer buffer();
BufferedSink emit() throws IOException;
BufferedSink emitCompleteSegments() throws IOException;
@Override // com.mbridge.msdk.thrid.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;
}

View File

@@ -0,0 +1,95 @@
package com.mbridge.msdk.thrid.okio;
import androidx.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
/* loaded from: classes4.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;
@Nullable
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;
}

View File

@@ -0,0 +1,513 @@
package com.mbridge.msdk.thrid.okio;
import androidx.annotation.Nullable;
import com.applovin.exoplayer2.common.base.Ascii;
import com.ironsource.v8;
import com.mbridge.msdk.foundation.tools.SameMD5;
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
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: classes4.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]);
public byte[] internalArray() {
return this.data;
}
public ByteString(byte[] bArr) {
this.data = bArr;
}
public static ByteString of(byte... bArr) {
if (bArr == null) {
throw new IllegalArgumentException("data == null");
}
return new ByteString((byte[]) bArr.clone());
}
public static ByteString of(byte[] bArr, int i, int i2) {
if (bArr == null) {
throw new IllegalArgumentException("data == null");
}
Util.checkOffsetAndCount(bArr.length, i, i2);
byte[] bArr2 = new byte[i2];
System.arraycopy(bArr, i, bArr2, 0, i2);
return new ByteString(bArr2);
}
public static ByteString of(ByteBuffer byteBuffer) {
if (byteBuffer == null) {
throw new IllegalArgumentException("data == null");
}
byte[] bArr = new byte[byteBuffer.remaining()];
byteBuffer.get(bArr);
return new ByteString(bArr);
}
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;
}
public static ByteString encodeString(String str, Charset charset) {
if (str == null) {
throw new IllegalArgumentException("s == null");
}
if (charset == null) {
throw new IllegalArgumentException("charset == null");
}
return new ByteString(str.getBytes(charset));
}
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 String string(Charset charset) {
if (charset == null) {
throw new IllegalArgumentException("charset == null");
}
return new String(this.data, charset);
}
public String base64() {
return Base64.encode(this.data);
}
public ByteString md5() {
return digest(SameMD5.TAG);
}
public ByteString sha1() {
return digest(AndroidStaticDeviceInfoDataSource.ALGORITHM_SHA1);
}
public ByteString sha256() {
return digest("SHA-256");
}
public ByteString sha512() {
return digest("SHA-512");
}
private ByteString digest(String str) {
try {
return of(MessageDigest.getInstance(str).digest(this.data));
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
}
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);
}
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 String base64Url() {
return Base64.encodeUrl(this.data);
}
@Nullable
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 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 += 2;
cArr[i2] = cArr2[b & Ascii.SI];
}
return new String(cArr);
}
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);
}
int length = str.length() / 2;
byte[] bArr = new byte[length];
for (int i = 0; i < 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';
}
if (c >= 'a' && c <= 'f') {
return c - 'W';
}
if (c >= 'A' && c <= 'F') {
return c - '7';
}
throw new IllegalArgumentException("Unexpected hex digit: " + c);
}
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);
}
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 ByteString substring(int i) {
return substring(i, this.data.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(bArr, i, bArr2, 0, i3);
return new ByteString(bArr2);
}
public byte getByte(int i) {
return this.data[i];
}
public int size() {
return this.data.length;
}
public byte[] toByteArray() {
return (byte[]) this.data.clone();
}
public ByteBuffer asByteBuffer() {
return ByteBuffer.wrap(this.data).asReadOnlyBuffer();
}
public void write(OutputStream outputStream) throws IOException {
if (outputStream == null) {
throw new IllegalArgumentException("out == null");
}
outputStream.write(this.data);
}
public void write(Buffer buffer) {
byte[] bArr = this.data;
buffer.write(bArr, 0, bArr.length);
}
public boolean rangeEquals(int i, ByteString byteString, int i2, int i3) {
return byteString.rangeEquals(i2, this.data, i, i3);
}
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(ByteString byteString) {
return rangeEquals(0, byteString, 0, byteString.size());
}
public final boolean startsWith(byte[] bArr) {
return rangeEquals(0, bArr, 0, bArr.length);
}
public final boolean endsWith(ByteString byteString) {
return rangeEquals(size() - byteString.size(), byteString, 0, byteString.size());
}
public final boolean endsWith(byte[] bArr) {
return rangeEquals(size() - bArr.length, bArr, 0, bArr.length);
}
public final int indexOf(ByteString byteString) {
return indexOf(byteString.internalArray(), 0);
}
public final int indexOf(ByteString byteString, int i) {
return indexOf(byteString.internalArray(), i);
}
public final int indexOf(byte[] bArr) {
return indexOf(bArr, 0);
}
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 final int lastIndexOf(ByteString byteString) {
return lastIndexOf(byteString.internalArray(), size());
}
public final int lastIndexOf(ByteString byteString, int i) {
return lastIndexOf(byteString.internalArray(), i);
}
public final int lastIndexOf(byte[] bArr) {
return lastIndexOf(bArr, size());
}
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 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 int hashCode() {
int i = this.hashCode;
if (i != 0) {
return i;
}
int hashCode = Arrays.hashCode(this.data);
this.hashCode = hashCode;
return hashCode;
}
@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 String toString() {
StringBuilder sb;
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() + v8.i.e;
}
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()) {
sb = new StringBuilder();
sb.append("[size=");
sb.append(this.data.length);
sb.append(" text=");
sb.append(replace);
sb.append("…]");
} else {
sb = new StringBuilder();
sb.append("[text=");
sb.append(replace);
sb.append(v8.i.e);
}
return sb.toString();
}
public 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();
}
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);
}
}

View File

@@ -0,0 +1,128 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
import java.util.zip.Deflater;
/* loaded from: classes4.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);
}
public 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;
}
@Override // com.mbridge.msdk.thrid.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;
int i = segment.pos + min;
segment.pos = i;
if (i == segment.limit) {
buffer.head = segment.pop();
SegmentPool.recycle(segment);
}
j -= j2;
}
}
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 // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
deflate(true);
this.sink.flush();
}
public void finishDeflate() throws IOException {
this.deflater.finish();
deflate(false);
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this.closed) {
return;
}
try {
finishDeflate();
th = null;
} catch (Throwable th) {
th = th;
}
try {
this.deflater.end();
} catch (Throwable th2) {
if (th == null) {
th = th2;
}
}
try {
this.sink.close();
} catch (Throwable th3) {
if (th == null) {
th = th3;
}
}
this.closed = true;
if (th != null) {
Util.sneakyRethrow(th);
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return this.sink.timeout();
}
public String toString() {
return "DeflaterSink(" + this.sink + ")";
}
}

View File

@@ -0,0 +1,43 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
/* loaded from: classes4.dex */
public abstract class ForwardingSink implements Sink {
private final Sink delegate;
public final Sink delegate() {
return this.delegate;
}
public ForwardingSink(Sink sink) {
if (sink == null) {
throw new IllegalArgumentException("delegate == null");
}
this.delegate = sink;
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public void write(Buffer buffer, long j) throws IOException {
this.delegate.write(buffer, j);
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
this.delegate.flush();
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return this.delegate.timeout();
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.delegate.close();
}
public String toString() {
return getClass().getSimpleName() + "(" + this.delegate.toString() + ")";
}
}

View File

@@ -0,0 +1,38 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
/* loaded from: classes4.dex */
public abstract class ForwardingSource implements Source {
private final Source delegate;
public final Source delegate() {
return this.delegate;
}
public ForwardingSource(Source source) {
if (source == null) {
throw new IllegalArgumentException("delegate == null");
}
this.delegate = source;
}
@Override // com.mbridge.msdk.thrid.okio.Source
public long read(Buffer buffer, long j) throws IOException {
return this.delegate.read(buffer, j);
}
@Override // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return this.delegate.timeout();
}
@Override // com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.delegate.close();
}
public String toString() {
return getClass().getSimpleName() + "(" + this.delegate.toString() + ")";
}
}

View File

@@ -0,0 +1,68 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/* loaded from: classes4.dex */
public class ForwardingTimeout extends Timeout {
private Timeout delegate;
public final Timeout delegate() {
return this.delegate;
}
public ForwardingTimeout(Timeout timeout) {
if (timeout == null) {
throw new IllegalArgumentException("delegate == null");
}
this.delegate = timeout;
}
public final ForwardingTimeout setDelegate(Timeout timeout) {
if (timeout == null) {
throw new IllegalArgumentException("delegate == null");
}
this.delegate = timeout;
return this;
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public Timeout timeout(long j, TimeUnit timeUnit) {
return this.delegate.timeout(j, timeUnit);
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public long timeoutNanos() {
return this.delegate.timeoutNanos();
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public boolean hasDeadline() {
return this.delegate.hasDeadline();
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public long deadlineNanoTime() {
return this.delegate.deadlineNanoTime();
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public Timeout deadlineNanoTime(long j) {
return this.delegate.deadlineNanoTime(j);
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public Timeout clearTimeout() {
return this.delegate.clearTimeout();
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public Timeout clearDeadline() {
return this.delegate.clearDeadline();
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public void throwIfReached() throws IOException {
this.delegate.throwIfReached();
}
}

View File

@@ -0,0 +1,109 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
/* loaded from: classes4.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 final Deflater deflater() {
return this.deflater;
}
public GzipSink(Sink sink) {
if (sink == null) {
throw new IllegalArgumentException("sink == null");
}
Deflater deflater = new Deflater(-1, true);
this.deflater = deflater;
BufferedSink buffer = Okio.buffer(sink);
this.sink = buffer;
this.deflaterSink = new DeflaterSink(buffer, deflater);
writeHeader();
}
@Override // com.mbridge.msdk.thrid.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);
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
this.deflaterSink.flush();
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return this.sink.timeout();
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this.closed) {
return;
}
try {
this.deflaterSink.finishDeflate();
writeFooter();
th = null;
} catch (Throwable th) {
th = th;
}
try {
this.deflater.end();
} catch (Throwable th2) {
if (th == null) {
th = th2;
}
}
try {
this.sink.close();
} catch (Throwable th3) {
if (th == null) {
th = th3;
}
}
this.closed = true;
if (th != null) {
Util.sneakyRethrow(th);
}
}
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);
}
private void writeFooter() throws IOException {
this.sink.writeIntLe((int) this.crc.getValue());
this.sink.writeIntLe((int) this.deflater.getBytesRead());
}
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;
}
}
}

View File

@@ -0,0 +1,153 @@
package com.mbridge.msdk.thrid.okio;
import java.io.EOFException;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Inflater;
/* loaded from: classes4.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");
}
Inflater inflater = new Inflater(true);
this.inflater = inflater;
BufferedSource buffer = Okio.buffer(source);
this.source = buffer;
this.inflaterSource = new InflaterSource(buffer, inflater);
}
@Override // com.mbridge.msdk.thrid.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;
}
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((byte) 0);
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((byte) 0);
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());
}
@Override // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return this.source.timeout();
}
@Override // com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.inflaterSource.close();
}
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 - r6, j2);
this.crc.update(segment.data, (int) (segment.pos + j), min);
j2 -= min;
segment = segment.next;
j = 0;
}
}
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)));
}
}
}

View File

@@ -0,0 +1,97 @@
package com.mbridge.msdk.thrid.okio;
import androidx.annotation.Nullable;
import com.mbridge.msdk.foundation.tools.SameMD5;
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
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: classes4.dex */
public final class HashingSink extends ForwardingSink {
@Nullable
private final Mac mac;
@Nullable
private final MessageDigest messageDigest;
public static HashingSink md5(Sink sink) {
return new HashingSink(sink, SameMD5.TAG);
}
public static HashingSink sha1(Sink sink) {
return new HashingSink(sink, AndroidStaticDeviceInfoDataSource.ALGORITHM_SHA1);
}
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 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");
}
private HashingSink(Sink sink, String str) {
super(sink);
try {
this.messageDigest = MessageDigest.getInstance(str);
this.mac = null;
} catch (NoSuchAlgorithmException unused) {
throw new AssertionError();
}
}
private HashingSink(Sink sink, ByteString byteString, String str) {
super(sink);
try {
Mac mac = Mac.getInstance(str);
this.mac = mac;
mac.init(new SecretKeySpec(byteString.toByteArray(), str));
this.messageDigest = null;
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e);
} catch (NoSuchAlgorithmException unused) {
throw new AssertionError();
}
}
@Override // com.mbridge.msdk.thrid.okio.ForwardingSink, com.mbridge.msdk.thrid.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);
}
public final ByteString hash() {
MessageDigest messageDigest = this.messageDigest;
return ByteString.of(messageDigest != null ? messageDigest.digest() : this.mac.doFinal());
}
}

View File

@@ -0,0 +1,92 @@
package com.mbridge.msdk.thrid.okio;
import com.mbridge.msdk.foundation.tools.SameMD5;
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
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: classes4.dex */
public final class HashingSource extends ForwardingSource {
private final Mac mac;
private final MessageDigest messageDigest;
public static HashingSource md5(Source source) {
return new HashingSource(source, SameMD5.TAG);
}
public static HashingSource sha1(Source source) {
return new HashingSource(source, AndroidStaticDeviceInfoDataSource.ALGORITHM_SHA1);
}
public static HashingSource sha256(Source source) {
return new HashingSource(source, "SHA-256");
}
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");
}
private HashingSource(Source source, String str) {
super(source);
try {
this.messageDigest = MessageDigest.getInstance(str);
this.mac = null;
} catch (NoSuchAlgorithmException unused) {
throw new AssertionError();
}
}
private HashingSource(Source source, ByteString byteString, String str) {
super(source);
try {
Mac mac = Mac.getInstance(str);
this.mac = mac;
mac.init(new SecretKeySpec(byteString.toByteArray(), str));
this.messageDigest = null;
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e);
} catch (NoSuchAlgorithmException unused) {
throw new AssertionError();
}
}
@Override // com.mbridge.msdk.thrid.okio.ForwardingSource, com.mbridge.msdk.thrid.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;
}
public final ByteString hash() {
MessageDigest messageDigest = this.messageDigest;
return ByteString.of(messageDigest != null ? messageDigest.digest() : this.mac.doFinal());
}
}

View File

@@ -0,0 +1,114 @@
package com.mbridge.msdk.thrid.okio;
import csdk.gluads.Consts;
import java.io.EOFException;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
/* loaded from: classes4.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);
}
public 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;
}
@Override // com.mbridge.msdk.thrid.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(Consts.PLACEMENT_STATUS_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 final 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;
int i3 = i - i2;
this.bufferBytesHeldByInflater = i3;
this.inflater.setInput(segment.data, i2, i3);
return false;
}
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 // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return this.source.timeout();
}
@Override // com.mbridge.msdk.thrid.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();
}
}

View File

@@ -0,0 +1,252 @@
package com.mbridge.msdk.thrid.okio;
import androidx.annotation.Nullable;
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: classes4.dex */
public final class Okio {
static final Logger logger = Logger.getLogger(Okio.class.getName());
private Okio() {
}
public static BufferedSource buffer(Source source) {
return new RealBufferedSource(source);
}
public static BufferedSink buffer(Sink sink) {
return new RealBufferedSink(sink);
}
public static Sink sink(OutputStream outputStream) {
return sink(outputStream, new Timeout());
}
private static Sink sink(final OutputStream outputStream, final Timeout timeout) {
if (outputStream == null) {
throw new IllegalArgumentException("out == null");
}
if (timeout == null) {
throw new IllegalArgumentException("timeout == null");
}
return new Sink() { // from class: com.mbridge.msdk.thrid.okio.Okio.1
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return Timeout.this;
}
@Override // com.mbridge.msdk.thrid.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);
int i = segment.pos + min;
segment.pos = i;
long j2 = min;
j -= j2;
buffer.size -= j2;
if (i == segment.limit) {
buffer.head = segment.pop();
SegmentPool.recycle(segment);
}
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
outputStream.flush();
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
outputStream.close();
}
public String toString() {
return "sink(" + outputStream + ")";
}
};
}
public static Sink sink(Socket socket) throws IOException {
if (socket == null) {
throw new IllegalArgumentException("socket == null");
}
if (socket.getOutputStream() == null) {
throw new IOException("socket's output stream == null");
}
AsyncTimeout timeout = timeout(socket);
return timeout.sink(sink(socket.getOutputStream(), timeout));
}
public static Source source(InputStream inputStream) {
return source(inputStream, new Timeout());
}
private static Source source(final InputStream inputStream, final Timeout timeout) {
if (inputStream == null) {
throw new IllegalArgumentException("in == null");
}
if (timeout == null) {
throw new IllegalArgumentException("timeout == null");
}
return new Source() { // from class: com.mbridge.msdk.thrid.okio.Okio.2
@Override // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return Timeout.this;
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
inputStream.close();
}
public String toString() {
return "source(" + inputStream + ")";
}
};
}
public static Source source(File file) throws FileNotFoundException {
if (file == null) {
throw new IllegalArgumentException("file == null");
}
return source(new FileInputStream(file));
}
public static Source source(Path path, OpenOption... openOptionArr) throws IOException {
if (path == null) {
throw new IllegalArgumentException("path == null");
}
return source(Files.newInputStream(path, openOptionArr));
}
public static Sink sink(File file) throws FileNotFoundException {
if (file == null) {
throw new IllegalArgumentException("file == null");
}
return sink(new FileOutputStream(file));
}
public static Sink appendingSink(File file) throws FileNotFoundException {
if (file == null) {
throw new IllegalArgumentException("file == null");
}
return sink(new FileOutputStream(file, true));
}
public static Sink sink(Path path, OpenOption... openOptionArr) throws IOException {
if (path == null) {
throw new IllegalArgumentException("path == null");
}
return sink(Files.newOutputStream(path, openOptionArr));
}
public static Sink blackhole() {
return new Sink() { // from class: com.mbridge.msdk.thrid.okio.Okio.3
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public void write(Buffer buffer, long j) throws IOException {
buffer.skip(j);
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return Timeout.NONE;
}
};
}
public static Source source(Socket socket) throws IOException {
if (socket == null) {
throw new IllegalArgumentException("socket == null");
}
if (socket.getInputStream() == null) {
throw new IOException("socket's input stream == null");
}
AsyncTimeout timeout = timeout(socket);
return timeout.source(source(socket.getInputStream(), timeout));
}
private static AsyncTimeout timeout(final Socket socket) {
return new AsyncTimeout() { // from class: com.mbridge.msdk.thrid.okio.Okio.4
@Override // com.mbridge.msdk.thrid.okio.AsyncTimeout
public IOException newTimeoutException(@Nullable IOException iOException) {
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
if (iOException != null) {
socketTimeoutException.initCause(iOException);
}
return socketTimeoutException;
}
@Override // com.mbridge.msdk.thrid.okio.AsyncTimeout
public void timedOut() {
try {
socket.close();
} catch (AssertionError e) {
if (Okio.isAndroidGetsocknameError(e)) {
Okio.logger.log(Level.WARNING, "Failed to close timed out socket " + socket, (Throwable) e);
return;
}
throw e;
} catch (Exception e2) {
Okio.logger.log(Level.WARNING, "Failed to close timed out socket " + socket, (Throwable) e2);
}
}
};
}
public static boolean isAndroidGetsocknameError(AssertionError assertionError) {
return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true;
}
}

View File

@@ -0,0 +1,153 @@
package com.mbridge.msdk.thrid.okio;
import java.util.AbstractList;
import java.util.List;
import java.util.RandomAccess;
/* loaded from: classes4.dex */
public final class Options extends AbstractList<ByteString> implements RandomAccess {
final ByteString[] byteStrings;
final int[] trie;
private Options(ByteString[] byteStringArr, int[] iArr) {
this.byteStrings = byteStringArr;
this.trie = iArr;
}
/* JADX WARN: Code restructure failed: missing block: B:40:0x00ba, code lost:
continue;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static com.mbridge.msdk.thrid.okio.Options of(com.mbridge.msdk.thrid.okio.ByteString... r11) {
/*
Method dump skipped, instructions count: 254
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.thrid.okio.Options.of(com.mbridge.msdk.thrid.okio.ByteString[]):com.mbridge.msdk.thrid.okio.Options");
}
private static void buildTrieRecursive(long j, Buffer buffer, int i, List<ByteString> list, int i2, int i3, List<Integer> list2) {
int i4;
int i5;
int i6;
int i7;
int i8;
Buffer buffer2;
if (i2 >= i3) {
throw new AssertionError();
}
for (int i9 = i2; i9 < i3; i9++) {
if (list.get(i9).size() < i) {
throw new AssertionError();
}
}
ByteString byteString = list.get(i2);
ByteString byteString2 = list.get(i3 - 1);
if (i == byteString.size()) {
int i10 = i2 + 1;
i5 = i10;
i4 = list2.get(i2).intValue();
byteString = list.get(i10);
} else {
i4 = -1;
i5 = i2;
}
if (byteString.getByte(i) != byteString2.getByte(i)) {
int i11 = 1;
for (int i12 = i5 + 1; i12 < i3; i12++) {
if (list.get(i12 - 1).getByte(i) != list.get(i12).getByte(i)) {
i11++;
}
}
long intCount = j + intCount(buffer) + 2 + (i11 * 2);
buffer.writeInt(i11);
buffer.writeInt(i4);
for (int i13 = i5; i13 < i3; i13++) {
byte b = list.get(i13).getByte(i);
if (i13 == i5 || b != list.get(i13 - 1).getByte(i)) {
buffer.writeInt(b & 255);
}
}
Buffer buffer3 = new Buffer();
int i14 = i5;
while (i14 < i3) {
byte b2 = list.get(i14).getByte(i);
int i15 = i14 + 1;
int i16 = i15;
while (true) {
if (i16 >= i3) {
i7 = i3;
break;
} else {
if (b2 != list.get(i16).getByte(i)) {
i7 = i16;
break;
}
i16++;
}
}
if (i15 == i7 && i + 1 == list.get(i14).size()) {
buffer.writeInt(list2.get(i14).intValue());
i8 = i7;
buffer2 = buffer3;
} else {
buffer.writeInt((int) ((intCount(buffer3) + intCount) * (-1)));
i8 = i7;
buffer2 = buffer3;
buildTrieRecursive(intCount, buffer3, i + 1, list, i14, i7, list2);
}
buffer3 = buffer2;
i14 = i8;
}
Buffer buffer4 = buffer3;
buffer.write(buffer4, buffer4.size());
return;
}
int min = Math.min(byteString.size(), byteString2.size());
int i17 = 0;
for (int i18 = i; i18 < min && byteString.getByte(i18) == byteString2.getByte(i18); i18++) {
i17++;
}
long intCount2 = 1 + j + intCount(buffer) + 2 + i17;
buffer.writeInt(-i17);
buffer.writeInt(i4);
int i19 = i;
while (true) {
i6 = i + i17;
if (i19 >= i6) {
break;
}
buffer.writeInt(byteString.getByte(i19) & 255);
i19++;
}
if (i5 + 1 == i3) {
if (i6 != list.get(i5).size()) {
throw new AssertionError();
}
buffer.writeInt(list2.get(i5).intValue());
} else {
Buffer buffer5 = new Buffer();
buffer.writeInt((int) ((intCount(buffer5) + intCount2) * (-1)));
buildTrieRecursive(intCount2, buffer5, i6, list, i5, i3, list2);
buffer.write(buffer5, buffer5.size());
}
}
@Override // java.util.AbstractList, java.util.List
public ByteString get(int i) {
return this.byteStrings[i];
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final int size() {
return this.byteStrings.length;
}
private static int intCount(Buffer buffer) {
return (int) (buffer.size() / 4);
}
}

View File

@@ -0,0 +1,150 @@
package com.mbridge.msdk.thrid.okio;
import csdk.gluads.Consts;
import java.io.IOException;
/* loaded from: classes4.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();
public final Sink sink() {
return this.sink;
}
public final Source source() {
return this.source;
}
public Pipe(long j) {
if (j >= 1) {
this.maxBufferSize = j;
return;
}
throw new IllegalArgumentException("maxBufferSize < 1: " + j);
}
public final class PipeSink implements Sink {
final Timeout timeout = new Timeout();
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return this.timeout;
}
public PipeSink() {
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public void write(Buffer buffer, long j) throws IOException {
synchronized (Pipe.this.buffer) {
try {
if (Pipe.this.sinkClosed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
while (j > 0) {
Pipe pipe = Pipe.this;
if (pipe.sourceClosed) {
throw new IOException("source is closed");
}
long size = pipe.maxBufferSize - pipe.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();
}
}
} catch (Throwable th) {
throw th;
}
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
synchronized (Pipe.this.buffer) {
try {
Pipe pipe = Pipe.this;
if (pipe.sinkClosed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (pipe.sourceClosed && pipe.buffer.size() > 0) {
throw new IOException("source is closed");
}
} finally {
}
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
synchronized (Pipe.this.buffer) {
try {
Pipe pipe = Pipe.this;
if (pipe.sinkClosed) {
return;
}
if (pipe.sourceClosed && pipe.buffer.size() > 0) {
throw new IOException("source is closed");
}
Pipe pipe2 = Pipe.this;
pipe2.sinkClosed = true;
pipe2.buffer.notifyAll();
} catch (Throwable th) {
throw th;
}
}
}
}
public final class PipeSource implements Source {
final Timeout timeout = new Timeout();
@Override // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return this.timeout;
}
public PipeSource() {
}
@Override // com.mbridge.msdk.thrid.okio.Source
public long read(Buffer buffer, long j) throws IOException {
synchronized (Pipe.this.buffer) {
try {
if (Pipe.this.sourceClosed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
while (Pipe.this.buffer.size() == 0) {
Pipe pipe = Pipe.this;
if (pipe.sinkClosed) {
return -1L;
}
this.timeout.waitUntilNotified(pipe.buffer);
}
long read = Pipe.this.buffer.read(buffer, j);
Pipe.this.buffer.notifyAll();
return read;
} catch (Throwable th) {
throw th;
}
}
}
@Override // com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
synchronized (Pipe.this.buffer) {
Pipe pipe = Pipe.this;
pipe.sourceClosed = true;
pipe.buffer.notifyAll();
}
}
}
}

View File

@@ -0,0 +1,351 @@
package com.mbridge.msdk.thrid.okio;
import android.support.v4.media.session.PlaybackStateCompat;
import csdk.gluads.Consts;
import java.io.EOFException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
/* loaded from: classes4.dex */
final class RealBufferedSink implements BufferedSink {
public final Buffer buffer = new Buffer();
boolean closed;
public final Sink sink;
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public Buffer buffer() {
return this.buffer;
}
@Override // java.nio.channels.Channel
public boolean isOpen() {
return !this.closed;
}
public RealBufferedSink(Sink sink) {
if (sink == null) {
throw new NullPointerException("sink == null");
}
this.sink = sink;
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public void write(Buffer buffer, long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.write(buffer, j);
emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink write(ByteString byteString) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.write(byteString);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeUtf8(String str) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeUtf8(str);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeUtf8(String str, int i, int i2) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeUtf8(str, i, i2);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeUtf8CodePoint(int i) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeUtf8CodePoint(i);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeString(String str, Charset charset) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeString(str, charset);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeString(String str, int i, int i2, Charset charset) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeString(str, i, i2, charset);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink write(byte[] bArr) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.write(bArr);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink write(byte[] bArr, int i, int i2) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.write(bArr, i, i2);
return emitCompleteSegments();
}
@Override // java.nio.channels.WritableByteChannel
public int write(ByteBuffer byteBuffer) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
int write = this.buffer.write(byteBuffer);
emitCompleteSegments();
return write;
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink write(Source source, long j) throws IOException {
while (j > 0) {
long read = source.read(this.buffer, j);
if (read == -1) {
throw new EOFException();
}
j -= read;
emitCompleteSegments();
}
return this;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeByte(int i) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeByte(i);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeShort(int i) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeShort(i);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeShortLe(int i) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeShortLe(i);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeInt(int i) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeInt(i);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeIntLe(int i) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeIntLe(i);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeLong(long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeLong(j);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeLongLe(long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeLongLe(j);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeDecimalLong(long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeDecimalLong(j);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink writeHexadecimalUnsignedLong(long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.buffer.writeHexadecimalUnsignedLong(j);
return emitCompleteSegments();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink emitCompleteSegments() throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
long completeSegmentByteCount = this.buffer.completeSegmentByteCount();
if (completeSegmentByteCount > 0) {
this.sink.write(this.buffer, completeSegmentByteCount);
}
return this;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public BufferedSink emit() throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
long size = this.buffer.size();
if (size > 0) {
this.sink.write(this.buffer, size);
}
return this;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink
public OutputStream outputStream() {
return new OutputStream() { // from class: com.mbridge.msdk.thrid.okio.RealBufferedSink.1
@Override // java.io.OutputStream
public void write(int i) throws IOException {
RealBufferedSink realBufferedSink = RealBufferedSink.this;
if (realBufferedSink.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_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) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
realBufferedSink.buffer.write(bArr, i, i2);
RealBufferedSink.this.emitCompleteSegments();
}
@Override // java.io.OutputStream, java.io.Flushable
public void flush() throws IOException {
RealBufferedSink realBufferedSink = RealBufferedSink.this;
if (realBufferedSink.closed) {
return;
}
realBufferedSink.flush();
}
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
RealBufferedSink.this.close();
}
public String toString() {
return RealBufferedSink.this + ".outputStream()";
}
};
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSink, com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
Buffer buffer = this.buffer;
long j = buffer.size;
if (j > 0) {
this.sink.write(buffer, j);
}
this.sink.flush();
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this.closed) {
return;
}
try {
Buffer buffer = this.buffer;
long j = buffer.size;
if (j > 0) {
this.sink.write(buffer, j);
}
th = null;
} catch (Throwable th) {
th = th;
}
try {
this.sink.close();
} catch (Throwable th2) {
if (th == null) {
th = th2;
}
}
this.closed = true;
if (th != null) {
Util.sneakyRethrow(th);
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return this.sink.timeout();
}
public String toString() {
return "buffer(" + this.sink + ")";
}
}

View File

@@ -0,0 +1,607 @@
package com.mbridge.msdk.thrid.okio;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.annotation.Nullable;
import csdk.gluads.Consts;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
/* loaded from: classes4.dex */
final class RealBufferedSource implements BufferedSource {
public final Buffer buffer = new Buffer();
boolean closed;
public final Source source;
@Override // com.mbridge.msdk.thrid.okio.BufferedSource, com.mbridge.msdk.thrid.okio.BufferedSink
public Buffer buffer() {
return this.buffer;
}
@Override // java.nio.channels.Channel
public boolean isOpen() {
return !this.closed;
}
public RealBufferedSource(Source source) {
if (source == null) {
throw new NullPointerException("source == null");
}
this.source = source;
}
@Override // com.mbridge.msdk.thrid.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(Consts.PLACEMENT_STATUS_CLOSED);
}
Buffer buffer2 = this.buffer;
if (buffer2.size == 0 && this.source.read(buffer2, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
return -1L;
}
return this.buffer.read(buffer, Math.min(j, this.buffer.size));
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public boolean exhausted() throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
return this.buffer.exhausted() && this.source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public void require(long j) throws IOException {
if (!request(j)) {
throw new EOFException();
}
}
@Override // com.mbridge.msdk.thrid.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(Consts.PLACEMENT_STATUS_CLOSED);
}
do {
buffer = this.buffer;
if (buffer.size >= j) {
return true;
}
} while (this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1);
return false;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public byte readByte() throws IOException {
require(1L);
return this.buffer.readByte();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public ByteString readByteString() throws IOException {
this.buffer.writeAll(this.source);
return this.buffer.readByteString();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public ByteString readByteString(long j) throws IOException {
require(j);
return this.buffer.readByteString(j);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public int select(Options options) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
do {
int selectPrefix = this.buffer.selectPrefix(options, true);
if (selectPrefix == -1) {
return -1;
}
if (selectPrefix != -2) {
this.buffer.skip(options.byteStrings[selectPrefix].size());
return selectPrefix;
}
} while (this.source.read(this.buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1);
return -1;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public byte[] readByteArray() throws IOException {
this.buffer.writeAll(this.source);
return this.buffer.readByteArray();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public byte[] readByteArray(long j) throws IOException {
require(j);
return this.buffer.readByteArray(j);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public int read(byte[] bArr) throws IOException {
return read(bArr, 0, bArr.length);
}
@Override // com.mbridge.msdk.thrid.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) {
int read = buffer.read(bArr, i, (int) j);
if (read == -1) {
throw new AssertionError();
}
i += read;
} else {
throw e;
}
}
}
}
@Override // com.mbridge.msdk.thrid.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 // 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);
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.BufferedSource
public String readUtf8() throws IOException {
this.buffer.writeAll(this.source);
return this.buffer.readUtf8();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public String readUtf8(long j) throws IOException {
require(j);
return this.buffer.readUtf8(j);
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.BufferedSource
public String readString(long j, Charset charset) throws IOException {
require(j);
if (charset == null) {
throw new IllegalArgumentException("charset == null");
}
return this.buffer.readString(j, charset);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
@Nullable
public String readUtf8Line() throws IOException {
long indexOf = indexOf((byte) 10);
if (indexOf == -1) {
long j = this.buffer.size;
if (j != 0) {
return readUtf8(j);
}
return null;
}
return this.buffer.readUtf8Line(indexOf);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public String readUtf8LineStrict() throws IOException {
return readUtf8LineStrict(Long.MAX_VALUE);
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.BufferedSource
public short readShort() throws IOException {
require(2L);
return this.buffer.readShort();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public short readShortLe() throws IOException {
require(2L);
return this.buffer.readShortLe();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public int readInt() throws IOException {
require(4L);
return this.buffer.readInt();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public int readIntLe() throws IOException {
require(4L);
return this.buffer.readIntLe();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long readLong() throws IOException {
require(8L);
return this.buffer.readLong();
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long readLongLe() throws IOException {
require(8L);
return this.buffer.readLongLe();
}
@Override // com.mbridge.msdk.thrid.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();
}
/* JADX WARN: Code restructure failed: missing block: B:20:0x0031, code lost:
if (r0 == 0) goto L21;
*/
/* JADX WARN: Code restructure failed: missing block: B:22:0x0047, code lost:
throw new java.lang.NumberFormatException(java.lang.String.format("Expected leading [0-9a-fA-F] character but was %#x", java.lang.Byte.valueOf(r2)));
*/
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public long readHexadecimalUnsignedLong() throws java.io.IOException {
/*
r5 = this;
r0 = 1
r5.require(r0)
r0 = 0
L6:
int r1 = r0 + 1
long r2 = (long) r1
boolean r2 = r5.request(r2)
if (r2 == 0) goto L48
com.mbridge.msdk.thrid.okio.Buffer r2 = r5.buffer
long r3 = (long) r0
byte r2 = r2.getByte(r3)
r3 = 48
if (r2 < r3) goto L1e
r3 = 57
if (r2 <= r3) goto L2f
L1e:
r3 = 97
if (r2 < r3) goto L26
r3 = 102(0x66, float:1.43E-43)
if (r2 <= r3) goto L2f
L26:
r3 = 65
if (r2 < r3) goto L31
r3 = 70
if (r2 <= r3) goto L2f
goto L31
L2f:
r0 = r1
goto L6
L31:
if (r0 == 0) goto L34
goto L48
L34:
java.lang.NumberFormatException r0 = new java.lang.NumberFormatException
java.lang.Byte r1 = java.lang.Byte.valueOf(r2)
java.lang.Object[] r1 = new java.lang.Object[]{r1}
java.lang.String r2 = "Expected leading [0-9a-fA-F] character but was %#x"
java.lang.String r1 = java.lang.String.format(r2, r1)
r0.<init>(r1)
throw r0
L48:
com.mbridge.msdk.thrid.okio.Buffer r0 = r5.buffer
long r0 = r0.readHexadecimalUnsignedLong()
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.thrid.okio.RealBufferedSource.readHexadecimalUnsignedLong():long");
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public void skip(long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
while (j > 0) {
Buffer buffer = this.buffer;
if (buffer.size == 0 && this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
throw new EOFException();
}
long min = Math.min(j, this.buffer.size());
this.buffer.skip(min);
j -= min;
}
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOf(byte b) throws IOException {
return indexOf(b, 0L, Long.MAX_VALUE);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOf(byte b, long j) throws IOException {
return indexOf(b, j, Long.MAX_VALUE);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOf(byte b, long j, long j2) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (j < 0 || j2 < j) {
throw new IllegalArgumentException(String.format("fromIndex=%s toIndex=%s", Long.valueOf(j), Long.valueOf(j2)));
}
while (j < j2) {
long indexOf = this.buffer.indexOf(b, j, j2);
if (indexOf == -1) {
Buffer buffer = this.buffer;
long j3 = buffer.size;
if (j3 >= j2 || this.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
break;
}
j = Math.max(j, j3);
} else {
return indexOf;
}
}
return -1L;
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOf(ByteString byteString) throws IOException {
return indexOf(byteString, 0L);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOf(ByteString byteString, long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_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 // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOfElement(ByteString byteString) throws IOException {
return indexOfElement(byteString, 0L);
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public long indexOfElement(ByteString byteString, long j) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_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 // com.mbridge.msdk.thrid.okio.BufferedSource
public boolean rangeEquals(long j, ByteString byteString) throws IOException {
return rangeEquals(j, byteString, 0, byteString.size());
}
@Override // com.mbridge.msdk.thrid.okio.BufferedSource
public boolean rangeEquals(long j, ByteString byteString, int i, int i2) throws IOException {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_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 // com.mbridge.msdk.thrid.okio.BufferedSource
public InputStream inputStream() {
return new InputStream() { // from class: com.mbridge.msdk.thrid.okio.RealBufferedSource.1
@Override // java.io.InputStream
public int read() throws IOException {
RealBufferedSource realBufferedSource = RealBufferedSource.this;
if (realBufferedSource.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
Buffer buffer = realBufferedSource.buffer;
if (buffer.size == 0 && realBufferedSource.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
return -1;
}
return RealBufferedSource.this.buffer.readByte() & 255;
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
if (RealBufferedSource.this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
Util.checkOffsetAndCount(bArr.length, i, i2);
RealBufferedSource realBufferedSource = RealBufferedSource.this;
Buffer buffer = realBufferedSource.buffer;
if (buffer.size == 0 && realBufferedSource.source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) == -1) {
return -1;
}
return RealBufferedSource.this.buffer.read(bArr, i, i2);
}
@Override // java.io.InputStream
public int available() throws IOException {
RealBufferedSource realBufferedSource = RealBufferedSource.this;
if (realBufferedSource.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
return (int) Math.min(realBufferedSource.buffer.size, 2147483647L);
}
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
RealBufferedSource.this.close();
}
public String toString() {
return RealBufferedSource.this + ".inputStream()";
}
};
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return this.source.timeout();
}
public String toString() {
return "buffer(" + this.source + ")";
}
}

View File

@@ -0,0 +1,115 @@
package com.mbridge.msdk.thrid.okio;
import androidx.annotation.Nullable;
/* loaded from: classes4.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;
public Segment() {
this.data = new byte[8192];
this.owner = true;
this.shared = false;
}
public 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;
}
public final Segment sharedCopy() {
this.shared = true;
return new Segment(this.data, this.pos, this.limit, true, false);
}
public final Segment unsharedCopy() {
return new Segment((byte[]) this.data.clone(), this.pos, this.limit, false, true);
}
@Nullable
public final Segment pop() {
Segment segment = this.next;
Segment segment2 = segment != this ? segment : null;
Segment segment3 = this.prev;
segment3.next = segment;
this.next.prev = segment3;
this.next = null;
this.prev = null;
return segment2;
}
public final Segment push(Segment segment) {
segment.prev = this;
segment.next = this.next;
this.next.prev = segment;
this.next = segment;
return segment;
}
public final 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;
}
public final 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(segment, i);
pop();
SegmentPool.recycle(this);
}
}
public final 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;
}
}

View File

@@ -0,0 +1,57 @@
package com.mbridge.msdk.thrid.okio;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.annotation.Nullable;
/* loaded from: classes4.dex */
final class SegmentPool {
static final long MAX_SIZE = 65536;
static long byteCount;
@Nullable
static Segment next;
private SegmentPool() {
}
public static Segment take() {
synchronized (SegmentPool.class) {
try {
Segment segment = next;
if (segment != null) {
next = segment.next;
segment.next = null;
byteCount -= PlaybackStateCompat.ACTION_PLAY_FROM_URI;
return segment;
}
return new Segment();
} catch (Throwable th) {
throw th;
}
}
}
public static void recycle(Segment segment) {
if (segment.next != null || segment.prev != null) {
throw new IllegalArgumentException();
}
if (segment.shared) {
return;
}
synchronized (SegmentPool.class) {
try {
long j = byteCount;
if (j + PlaybackStateCompat.ACTION_PLAY_FROM_URI > 65536) {
return;
}
byteCount = j + PlaybackStateCompat.ACTION_PLAY_FROM_URI;
segment.next = next;
segment.limit = 0;
segment.pos = 0;
next = segment;
} catch (Throwable th) {
throw th;
}
}
}
}

View File

@@ -0,0 +1,322 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
/* loaded from: classes4.dex */
final class SegmentedByteString extends ByteString {
final transient int[] directory;
final transient byte[][] segments;
public SegmentedByteString(Buffer buffer, int i) {
super(null);
Util.checkOffsetAndCount(buffer.size, 0L, i);
Segment segment = buffer.head;
int i2 = 0;
int i3 = 0;
int i4 = 0;
while (i3 < i) {
int i5 = segment.limit;
int i6 = segment.pos;
if (i5 != i6) {
i3 += i5 - i6;
i4++;
segment = segment.next;
} else {
throw new AssertionError("s.limit == s.pos");
}
}
this.segments = new byte[i4][];
this.directory = new int[i4 * 2];
Segment segment2 = buffer.head;
int i7 = 0;
while (i2 < i) {
byte[][] bArr = this.segments;
bArr[i7] = segment2.data;
int i8 = segment2.limit;
int i9 = segment2.pos;
i2 += i8 - i9;
if (i2 > i) {
i2 = i;
}
int[] iArr = this.directory;
iArr[i7] = i2;
iArr[bArr.length + i7] = i9;
segment2.shared = true;
i7++;
segment2 = segment2.next;
}
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public String utf8() {
return toByteString().utf8();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public String string(Charset charset) {
return toByteString().string(charset);
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public String base64() {
return toByteString().base64();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public String hex() {
return toByteString().hex();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString toAsciiLowercase() {
return toByteString().toAsciiLowercase();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString toAsciiUppercase() {
return toByteString().toAsciiUppercase();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString md5() {
return toByteString().md5();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString sha1() {
return toByteString().sha1();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString sha256() {
return toByteString().sha256();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString hmacSha1(ByteString byteString) {
return toByteString().hmacSha1(byteString);
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString hmacSha256(ByteString byteString) {
return toByteString().hmacSha256(byteString);
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public String base64Url() {
return toByteString().base64Url();
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString substring(int i) {
return toByteString().substring(i);
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public ByteString substring(int i, int i2) {
return toByteString().substring(i, i2);
}
@Override // com.mbridge.msdk.thrid.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]];
}
private int segment(int i) {
int binarySearch = Arrays.binarySearch(this.directory, 0, this.segments.length, i + 1);
return binarySearch >= 0 ? binarySearch : ~binarySearch;
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public int size() {
return this.directory[this.segments.length - 1];
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.ByteString
public ByteBuffer asByteBuffer() {
return ByteBuffer.wrap(toByteArray()).asReadOnlyBuffer();
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.ByteString
public 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 // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.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;
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public int indexOf(byte[] bArr, int i) {
return toByteString().indexOf(bArr, i);
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public int lastIndexOf(byte[] bArr, int i) {
return toByteString().lastIndexOf(bArr, i);
}
private ByteString toByteString() {
return new ByteString(toByteArray());
}
@Override // com.mbridge.msdk.thrid.okio.ByteString
public byte[] internalArray() {
return toByteArray();
}
@Override // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.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 // com.mbridge.msdk.thrid.okio.ByteString
public String toString() {
return toByteString().toString();
}
private Object writeReplace() {
return toByteString();
}
}

View File

@@ -0,0 +1,17 @@
package com.mbridge.msdk.thrid.okio;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
/* loaded from: classes4.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;
}

View File

@@ -0,0 +1,14 @@
package com.mbridge.msdk.thrid.okio;
import java.io.Closeable;
import java.io.IOException;
/* loaded from: classes4.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();
}

View File

@@ -0,0 +1,118 @@
package com.mbridge.msdk.thrid.okio;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.TimeUnit;
/* loaded from: classes4.dex */
public class Timeout {
public static final Timeout NONE = new Timeout() { // from class: com.mbridge.msdk.thrid.okio.Timeout.1
@Override // com.mbridge.msdk.thrid.okio.Timeout
public Timeout deadlineNanoTime(long j) {
return this;
}
@Override // com.mbridge.msdk.thrid.okio.Timeout
public void throwIfReached() throws IOException {
}
@Override // com.mbridge.msdk.thrid.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 Timeout deadlineNanoTime(long j) {
this.hasDeadline = true;
this.deadlineNanoTime = j;
return this;
}
public boolean hasDeadline() {
return this.hasDeadline;
}
public long timeoutNanos() {
return this.timeoutNanos;
}
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 deadlineNanoTime() {
if (this.hasDeadline) {
return this.deadlineNanoTime;
}
throw new IllegalStateException("No deadline");
}
public final Timeout deadline(long j, TimeUnit timeUnit) {
if (j > 0) {
if (timeUnit == null) {
throw new IllegalArgumentException("unit == null");
}
return deadlineNanoTime(System.nanoTime() + timeUnit.toNanos(j));
}
throw new IllegalArgumentException("duration <= 0: " + j);
}
public void throwIfReached() throws IOException {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
throw new InterruptedIOException("interrupted");
}
if (this.hasDeadline && this.deadlineNanoTime - System.nanoTime() <= 0) {
throw new InterruptedIOException("deadline reached");
}
}
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;
obj.wait(j2, (int) (timeoutNanos - (1000000 * j2)));
j = System.nanoTime() - nanoTime;
}
if (j >= timeoutNanos) {
throw new InterruptedIOException("timeout");
}
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
throw new InterruptedIOException("interrupted");
}
}
}

View File

@@ -0,0 +1,53 @@
package com.mbridge.msdk.thrid.okio;
/* loaded from: classes4.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;
}
}

View File

@@ -0,0 +1,46 @@
package com.mbridge.msdk.thrid.okio;
import java.nio.charset.Charset;
/* loaded from: classes4.dex */
final class Util {
public static final Charset UTF_8 = Charset.forName("UTF-8");
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) {
return (short) (((s & 255) << 8) | ((65280 & s) >>> 8));
}
private Util() {
}
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 void sneakyRethrow(Throwable th) {
sneakyThrow2(th);
}
private static <T extends Throwable> void sneakyThrow2(Throwable th) throws Throwable {
throw th;
}
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;
}
}

View File

@@ -0,0 +1,2 @@
package com.mbridge.msdk.thrid.okio;