package okhttp3.internal.cache; import android.graphics.Color; import android.text.TextUtils; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.ViewConfiguration; import android.widget.ExpandableListView; import com.google.common.base.Ascii; import java.io.IOException; import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; import net.sf.scuba.smartcards.ISO7816; import net.sf.scuba.smartcards.ISOFileInfo; import o.C14953gcr; import o.C14957gcv; import o.C15111ghZ; import o.C15139giB; import o.C15160gio; import o.DFY; import o.InterfaceC15148gic; import o.InterfaceC15149gid; import o.InterfaceC15168giw; import o.gdZ; import o.giD; import o.xzZ; import okhttp3.Cache; import okhttp3.Call; import okhttp3.EventListener; import okhttp3.Headers; import okhttp3.Interceptor; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.internal.Util; import okhttp3.internal.cache.CacheStrategy; import okhttp3.internal.connection.RealCall; import okhttp3.internal.http.HttpHeaders; import okhttp3.internal.http.HttpMethod; import okhttp3.internal.http.RealResponseBody; import okhttp3.internal.http2.Http2Connection; import org.bouncycastle.crypto.tls.CipherSuite; /* loaded from: classes.dex */ public final class CacheInterceptor implements Interceptor { public static final Companion Companion = new Companion(null); private final Cache cache; public CacheInterceptor(Cache cache) { this.cache = cache; } @Override // okhttp3.Interceptor public final Response intercept(Interceptor.Chain chain) throws IOException { ResponseBody body; ResponseBody body2; C14957gcv.e(chain, ""); Call call = chain.call(); Cache cache = this.cache; Response response = cache == null ? null : cache.get$okhttp(chain.request()); CacheStrategy compute = new CacheStrategy.Factory(System.currentTimeMillis(), chain.request(), response).compute(); Request networkRequest = compute.getNetworkRequest(); Response cacheResponse = compute.getCacheResponse(); Cache cache2 = this.cache; if (cache2 != null) { cache2.trackResponse$okhttp(compute); } RealCall realCall = call instanceof RealCall ? (RealCall) call : null; EventListener eventListener$okhttp = realCall != null ? realCall.getEventListener$okhttp() : null; if (eventListener$okhttp == null) { eventListener$okhttp = EventListener.NONE; } if (response != null && cacheResponse == null && (body2 = response.body()) != null) { Util.closeQuietly(body2); } if (networkRequest == null && cacheResponse == null) { Response build = new Response.Builder().request(chain.request()).protocol(Protocol.HTTP_1_1).code(504).message("Unsatisfiable Request (only-if-cached)").body(Util.EMPTY_RESPONSE).sentRequestAtMillis(-1L).receivedResponseAtMillis(System.currentTimeMillis()).build(); eventListener$okhttp.satisfactionFailure(call, build); return build; } if (networkRequest == null) { C14957gcv.e(cacheResponse); Response build2 = cacheResponse.newBuilder().cacheResponse(Companion.access$stripBody(Companion, cacheResponse)).build(); eventListener$okhttp.cacheHit(call, build2); return build2; } if (cacheResponse != null) { eventListener$okhttp.cacheConditionalHit(call, cacheResponse); } else if (this.cache != null) { eventListener$okhttp.cacheMiss(call); } try { Response proceed = chain.proceed(networkRequest); if (proceed == null && response != null && body != null) { } if (cacheResponse != null) { if (proceed != null && proceed.code() == 304) { Response.Builder newBuilder = cacheResponse.newBuilder(); Companion companion = Companion; Response build3 = newBuilder.headers(Companion.access$combine(companion, cacheResponse.headers(), proceed.headers())).sentRequestAtMillis(proceed.sentRequestAtMillis()).receivedResponseAtMillis(proceed.receivedResponseAtMillis()).cacheResponse(Companion.access$stripBody(companion, cacheResponse)).networkResponse(Companion.access$stripBody(companion, proceed)).build(); ResponseBody body3 = proceed.body(); C14957gcv.e(body3); body3.close(); Cache cache3 = this.cache; C14957gcv.e(cache3); cache3.trackConditionalCacheHit$okhttp(); this.cache.update$okhttp(cacheResponse, build3); eventListener$okhttp.cacheHit(call, build3); return build3; } ResponseBody body4 = cacheResponse.body(); if (body4 != null) { Util.closeQuietly(body4); } } C14957gcv.e(proceed); Response.Builder newBuilder2 = proceed.newBuilder(); Companion companion2 = Companion; Response build4 = newBuilder2.cacheResponse(Companion.access$stripBody(companion2, cacheResponse)).networkResponse(Companion.access$stripBody(companion2, proceed)).build(); if (this.cache != null) { if (HttpHeaders.promisesBody(build4) && CacheStrategy.Companion.isCacheable(build4, networkRequest)) { Response cacheWritingResponse = cacheWritingResponse(this.cache.put$okhttp(build4), build4); if (cacheResponse != null) { eventListener$okhttp.cacheMiss(call); } return cacheWritingResponse; } if (HttpMethod.INSTANCE.invalidatesCache(networkRequest.method())) { try { this.cache.remove$okhttp(networkRequest); } catch (IOException unused) { } } } return build4; } finally { if (response != null && (body = response.body()) != null) { Util.closeQuietly(body); } } } private final Response cacheWritingResponse(final CacheRequest cacheRequest, Response response) throws IOException { if (cacheRequest == null) { return response; } InterfaceC15168giw body = cacheRequest.body(); ResponseBody body2 = response.body(); C14957gcv.e(body2); final InterfaceC15149gid source = body2.source(); final InterfaceC15148gic c = C15160gio.c(body); giD gid = new giD(source, cacheRequest, c) { // from class: okhttp3.internal.cache.CacheInterceptor$cacheWritingResponse$cacheWritingSource$1 final InterfaceC15148gic $cacheBody; final CacheRequest $cacheRequest; final InterfaceC15149gid $source; private boolean cacheRequestClosed; /* JADX INFO: Access modifiers changed from: package-private */ { this.$source = source; this.$cacheRequest = cacheRequest; this.$cacheBody = c; } @Override // o.giD public final long read(C15111ghZ c15111ghZ, long j) throws IOException { C14957gcv.e(c15111ghZ, ""); try { long read = this.$source.read(c15111ghZ, j); if (read != -1) { c15111ghZ.c(this.$cacheBody.i(), c15111ghZ.c - read, read); this.$cacheBody.b(); return read; } if (!this.cacheRequestClosed) { this.cacheRequestClosed = true; this.$cacheBody.close(); } return -1L; } catch (IOException e) { if (!this.cacheRequestClosed) { this.cacheRequestClosed = true; this.$cacheRequest.abort(); } throw e; } } @Override // o.giD public final C15139giB timeout() { return this.$source.timeout(); } @Override // o.giD, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { if (!this.cacheRequestClosed && !Util.discard(this, 100, TimeUnit.MILLISECONDS)) { this.cacheRequestClosed = true; this.$cacheRequest.abort(); } this.$source.close(); } }; return response.newBuilder().body(new RealResponseBody(Response.header$default(response, com.google.common.net.HttpHeaders.CONTENT_TYPE, null, 2, null), response.body().contentLength(), C15160gio.c(gid))).build(); } /* loaded from: classes.dex */ public static final class Companion { private static short[] d; private static final byte[] $$a = {ISO7816.INS_CHANGE_CHV, ISOFileInfo.A1, ISO7816.INS_ENVELOPE, -12}; private static final int $$b = CipherSuite.TLS_DHE_PSK_WITH_AES_128_GCM_SHA256; private static int $10 = 0; private static int $11 = 1; private static int f = 0; private static int i = 1; private static int e = 2040817653; private static int c = 1406017128; private static int b = -1404641965; private static byte[] a = {Ascii.NAK}; /* JADX WARN: Removed duplicated region for block: B:10:0x0027 */ /* JADX WARN: Removed duplicated region for block: B:7:0x001f */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:10:0x0027 -> B:4:0x002c). Please report as a decompilation issue!!! */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static void h(int r7, int r8, short r9, java.lang.Object[] r10) { /* byte[] r0 = okhttp3.internal.cache.CacheInterceptor.Companion.$$a int r8 = r8 * 2 int r8 = 110 - r8 int r7 = r7 * 4 int r7 = r7 + 1 int r9 = r9 + 4 byte[] r1 = new byte[r7] r2 = 0 if (r0 != 0) goto L15 r8 = r7 r3 = r9 r5 = r2 goto L2c L15: r3 = r2 L16: byte r4 = (byte) r8 int r9 = r9 + 1 int r5 = r3 + 1 r1[r3] = r4 if (r5 != r7) goto L27 java.lang.String r7 = new java.lang.String r7.(r1, r2) r10[r2] = r7 return L27: r3 = r0[r9] r6 = r3 r3 = r9 r9 = r6 L2c: int r9 = -r9 int r8 = r8 + r9 r9 = r3 r3 = r5 goto L16 */ throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.cache.CacheInterceptor.Companion.h(int, int, short, java.lang.Object[]):void"); } private Companion() { } public static final /* synthetic */ Headers access$combine(Companion companion, Headers headers, Headers headers2) { int i2 = 2 % 2; int i3 = f + 47; i = i3 % 128; int i4 = i3 % 2; Headers combine = companion.combine(headers, headers2); int i5 = f + 89; i = i5 % 128; if (i5 % 2 == 0) { int i6 = 31 / 0; } return combine; } public static final /* synthetic */ Response access$stripBody(Companion companion, Response response) { int i2 = 2 % 2; int i3 = i + 73; f = i3 % 128; if (i3 % 2 != 0) { companion.stripBody(response); Object obj = null; obj.hashCode(); throw null; } Response stripBody = companion.stripBody(response); int i4 = i + 77; f = i4 % 128; int i5 = i4 % 2; return stripBody; } private final Response stripBody(Response response) { ResponseBody body; int i2 = 2 % 2; int i3 = i + 85; int i4 = i3 % 128; f = i4; int i5 = i3 % 2; if (response == null) { int i6 = i4 + 109; i = i6 % 128; if (i6 % 2 == 0) { throw null; } body = null; } else { body = response.body(); int i7 = i + 95; f = i7 % 128; int i8 = i7 % 2; } return body != null ? response.newBuilder().body(null).build() : response; } private static void g(short s, byte b2, int i2, int i3, int i4, Object[] objArr) { int i5; boolean z; int i6 = 2; int i7 = 2 % 2; DFY dfy = new DFY(); StringBuilder sb = new StringBuilder(); try { Object[] objArr2 = {Integer.valueOf(i2), Integer.valueOf(c)}; Object obj = xzZ.y.get(-2092856797); char c2 = '0'; if (obj == null) { Class cls = (Class) xzZ.c(337 - View.MeasureSpec.getMode(0), TextUtils.lastIndexOf("", '0', 0, 0) + 6, (char) ExpandableListView.getPackedPositionType(0L)); byte b3 = (byte) 0; byte b4 = b3; Object[] objArr3 = new Object[1]; h(b3, b4, (byte) (b4 - 1), objArr3); obj = cls.getMethod((String) objArr3[0], Integer.TYPE, Integer.TYPE); xzZ.y.put(-2092856797, obj); } int intValue = ((Integer) ((Method) obj).invoke(null, objArr2)).intValue(); if (intValue == -1) { int i8 = $11 + 119; $10 = i8 % 128; int i9 = i8 % 2; i5 = 1; } else { i5 = 0; } if (i5 != 0) { byte[] bArr = a; if (bArr != null) { int length = bArr.length; byte[] bArr2 = new byte[length]; int i10 = 0; while (i10 < length) { int i11 = $10 + 87; $11 = i11 % 128; int i12 = i11 % i6; Object[] objArr4 = {Integer.valueOf(bArr[i10])}; Object obj2 = xzZ.y.get(-1648115392); if (obj2 == null) { Class cls2 = (Class) xzZ.c((ViewConfiguration.getScrollBarFadeDuration() >> 16) + 60, TextUtils.getOffsetBefore("", 0) + 5, (char) (TextUtils.indexOf("", c2) + 1)); byte b5 = (byte) 0; byte b6 = (byte) (b5 + 1); Object[] objArr5 = new Object[1]; h(b5, b6, (byte) (-b6), objArr5); obj2 = cls2.getMethod((String) objArr5[0], Integer.TYPE); xzZ.y.put(-1648115392, obj2); } bArr2[i10] = ((Byte) ((Method) obj2).invoke(null, objArr4)).byteValue(); i10++; i6 = 2; c2 = '0'; } bArr = bArr2; } if (bArr != null) { byte[] bArr3 = a; Object[] objArr6 = {Integer.valueOf(i3), Integer.valueOf(e)}; Object obj3 = xzZ.y.get(-2092856797); if (obj3 == null) { Class cls3 = (Class) xzZ.c(337 - Gravity.getAbsoluteGravity(0, 0), 5 - View.MeasureSpec.getMode(0), (char) (Color.rgb(0, 0, 0) + Http2Connection.OKHTTP_CLIENT_WINDOW_SIZE)); byte b7 = (byte) 0; byte b8 = b7; Object[] objArr7 = new Object[1]; h(b7, b8, (byte) (b8 - 1), objArr7); obj3 = cls3.getMethod((String) objArr7[0], Integer.TYPE, Integer.TYPE); xzZ.y.put(-2092856797, obj3); } intValue = (byte) (((byte) (bArr3[((Integer) ((Method) obj3).invoke(null, objArr6)).intValue()] ^ (-7303220121662775787L))) + ((int) (c ^ (-7303220121662775787L)))); } else { intValue = (short) (((short) (d[i3 + ((int) (e ^ (-7303220121662775787L)))] ^ (-7303220121662775787L))) + ((int) (c ^ (-7303220121662775787L)))); } } if (intValue > 0) { int i13 = $10 + 125; $11 = i13 % 128; int i14 = i13 % 2; dfy.c = ((i3 + intValue) - 2) + ((int) (e ^ (-7303220121662775787L))) + i5; Object[] objArr8 = {dfy, Integer.valueOf(i4), Integer.valueOf(b), sb}; Object obj4 = xzZ.y.get(1546973421); if (obj4 == null) { obj4 = ((Class) xzZ.c(KeyEvent.getDeadChar(0, 0) + 748, 4 - TextUtils.lastIndexOf("", '0'), (char) KeyEvent.keyCodeFromString(""))).getMethod("q", Object.class, Integer.TYPE, Integer.TYPE, Object.class); xzZ.y.put(1546973421, obj4); } ((StringBuilder) ((Method) obj4).invoke(null, objArr8)).append(dfy.a); dfy.e = dfy.a; byte[] bArr4 = a; if (bArr4 != null) { int length2 = bArr4.length; byte[] bArr5 = new byte[length2]; for (int i15 = 0; i15 < length2; i15++) { bArr5[i15] = (byte) (bArr4[i15] ^ (-7303220121662775787L)); } bArr4 = bArr5; } if (bArr4 != null) { int i16 = $11 + 33; $10 = i16 % 128; int i17 = i16 % 2; z = true; } else { z = false; } dfy.d = 1; while (dfy.d < intValue) { int i18 = $11 + 3; $10 = i18 % 128; if (i18 % 2 != 0) { throw null; } if (z) { byte[] bArr6 = a; dfy.c = dfy.c - 1; dfy.a = (char) (dfy.e + (((byte) (((byte) (bArr6[r7] ^ (-7303220121662775787L))) + s)) ^ b2)); int i19 = $11 + 81; $10 = i19 % 128; int i20 = i19 % 2; } else { short[] sArr = d; dfy.c = dfy.c - 1; dfy.a = (char) (dfy.e + (((short) (((short) (sArr[r9] ^ (-7303220121662775787L))) + s)) ^ b2)); } sb.append(dfy.a); dfy.e = dfy.a; dfy.d++; } } objArr[0] = sb.toString(); } catch (Throwable th) { Throwable cause = th.getCause(); if (cause == null) { throw th; } throw cause; } } private final Headers combine(Headers headers, Headers headers2) { int i2; int i3 = 2 % 2; Headers.Builder builder = new Headers.Builder(); int size = headers.size(); for (0; i2 < size; i2 + 1) { int i4 = f + 35; i = i4 % 128; int i5 = i4 % 2; String name = headers.name(i2); String value = headers.value(i2); if (gdZ.a(com.google.common.net.HttpHeaders.WARNING, name, true)) { int i6 = f + 33; i = i6 % 128; int i7 = i6 % 2; Object[] objArr = new Object[1]; g((short) TextUtils.getOffsetAfter("", 0), (byte) (69 - TextUtils.getTrimmedLength("")), (ViewConfiguration.getMinimumFlingVelocity() >> 16) - 124, View.MeasureSpec.getMode(0) - 711621088, Color.argb(0, 0, 0, 0) + 7814379, objArr); i2 = gdZ.e(value, ((String) objArr[0]).intern(), false) ? i2 + 1 : 0; } if (!isContentSpecificHeader(name)) { int i8 = i + 101; f = i8 % 128; int i9 = i8 % 2; if (isEndToEnd(name) && headers2.get(name) != null) { } } builder.addLenient$okhttp(name, value); } int size2 = headers2.size(); for (int i10 = 0; i10 < size2; i10++) { int i11 = f + 51; i = i11 % 128; if (i11 % 2 == 0) { isContentSpecificHeader(headers2.name(i10)); throw null; } String name2 = headers2.name(i10); if ((!isContentSpecificHeader(name2)) && isEndToEnd(name2)) { builder.addLenient$okhttp(name2, headers2.value(i10)); int i12 = i + 1; f = i12 % 128; if (i12 % 2 != 0) { int i13 = 3 / 3; } } } return builder.build(); } private final boolean isEndToEnd(String str) { int i2 = 2 % 2; if (!gdZ.a(com.google.common.net.HttpHeaders.CONNECTION, str, true)) { int i3 = i + 111; f = i3 % 128; int i4 = i3 % 2; if (!gdZ.a("Keep-Alive", str, true) && !gdZ.a(com.google.common.net.HttpHeaders.PROXY_AUTHENTICATE, str, true) && !gdZ.a(com.google.common.net.HttpHeaders.PROXY_AUTHORIZATION, str, true)) { int i5 = f + 45; i = i5 % 128; if (i5 % 2 != 0 ? !gdZ.a(com.google.common.net.HttpHeaders.TE, str, true) : !gdZ.a(com.google.common.net.HttpHeaders.TE, str, true)) { if (!gdZ.a("Trailers", str, true) && !gdZ.a(com.google.common.net.HttpHeaders.TRANSFER_ENCODING, str, true)) { int i6 = i + 105; f = i6 % 128; int i7 = i6 % 2; if (!gdZ.a(com.google.common.net.HttpHeaders.UPGRADE, str, true)) { return true; } } } } } int i8 = i + 47; f = i8 % 128; int i9 = i8 % 2; return false; } private final boolean isContentSpecificHeader(String str) { int i2 = 2 % 2; int i3 = f + 13; i = i3 % 128; int i4 = i3 % 2; if (gdZ.a(com.google.common.net.HttpHeaders.CONTENT_LENGTH, str, true)) { return true; } int i5 = f + 77; i = i5 % 128; int i6 = i5 % 2; if (!(!gdZ.a(com.google.common.net.HttpHeaders.CONTENT_ENCODING, str, true))) { return true; } if (gdZ.a(com.google.common.net.HttpHeaders.CONTENT_TYPE, str, true)) { int i7 = i + 111; f = i7 % 128; int i8 = i7 % 2; return true; } int i9 = f + 89; i = i9 % 128; int i10 = i9 % 2; return false; } public /* synthetic */ Companion(C14953gcr c14953gcr) { this(); } } public final Cache getCache$okhttp() { return this.cache; } }