package com.ironsource; import android.text.TextUtils; import com.ironsource.sdk.utils.IronSourceStorageUtils; import com.ironsource.sdk.utils.Logger; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.Callable; /* loaded from: classes2.dex */ class jc implements Callable { private static final String d = "FileWorkerThread"; private static final String e = "X-Android-Protocols"; private static final String f = "http/1.1,h2"; private final oa a; private final String b; private long c; public jc(oa oaVar, String str, long j) { this.a = oaVar; this.b = str; this.c = j; } public int a(byte[] bArr, String str) throws Exception { return IronSourceStorageUtils.saveFile(bArr, str); } @Override // java.util.concurrent.Callable /* renamed from: a, reason: merged with bridge method [inline-methods] */ public pa call() { int i; if (this.c == 0) { this.c = 1L; } pa paVar = null; for (int i2 = 0; i2 < this.c; i2++) { paVar = a(this.a.e(), i2, this.a.a(), this.a.c(), this.a.f()); int b = paVar.b(); if (b != 1008 && b != 1009) { break; } } if (paVar != null && paVar.a() != null) { StringBuilder sb = new StringBuilder(); sb.append(this.b); String str = File.separator; sb.append(str); sb.append(this.a.b().getName()); String sb2 = sb.toString(); String str2 = this.a.d() + str + x8.E + this.a.b().getName(); try { if (a(paVar.a(), str2) == 0) { paVar.a(1006); } else if (!a(str2, sb2)) { paVar.a(1014); } } catch (FileNotFoundException e2) { i9.d().a(e2); i = 1018; paVar.a(i); } catch (Error e3) { i9.d().a(e3); if (!TextUtils.isEmpty(e3.getMessage())) { Logger.i(d, e3.getMessage()); } i = 1019; paVar.a(i); } catch (Exception e4) { i9.d().a(e4); if (!TextUtils.isEmpty(e4.getMessage())) { Logger.i(d, e4.getMessage()); } paVar.a(1009); } } return paVar; } /* JADX WARN: Code restructure failed: missing block: B:38:0x0136, code lost: if (r4 != null) goto L74; */ /* JADX WARN: Code restructure failed: missing block: B:40:0x0124, code lost: r4.disconnect(); */ /* JADX WARN: Code restructure failed: missing block: B:48:0x00e5, code lost: if (r4 != null) goto L40; */ /* JADX WARN: Code restructure failed: missing block: B:54:0x0169, code lost: if (r4 != null) goto L74; */ /* JADX WARN: Code restructure failed: missing block: B:60:0x0147, code lost: if (r4 != null) goto L74; */ /* JADX WARN: Code restructure failed: missing block: B:66:0x0158, code lost: if (r4 != null) goto L74; */ /* JADX WARN: Code restructure failed: missing block: B:74:0x0122, code lost: if (r4 != null) goto L74; */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:21:0x00a2 A[Catch: all -> 0x00a6, TRY_ENTER, TryCatch #4 {all -> 0x00a6, blocks: (B:21:0x00a2, B:22:0x00a8, B:47:0x00e2), top: B:7:0x0018 }] */ /* JADX WARN: Removed duplicated region for block: B:81:0x018d A[Catch: all -> 0x0189, TRY_LEAVE, TryCatch #6 {all -> 0x0189, blocks: (B:89:0x0185, B:81:0x018d), top: B:88:0x0185 }] */ /* JADX WARN: Removed duplicated region for block: B:88:0x0185 A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public com.ironsource.pa a(java.lang.String r7, int r8, int r9, int r10, boolean r11) { /* Method dump skipped, instructions count: 424 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.ironsource.jc.a(java.lang.String, int, int, int, boolean):com.ironsource.pa"); } public boolean a(String str, String str2) throws Exception { return IronSourceStorageUtils.renameFile(str, str2); } public byte[] a(InputStream inputStream) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bArr = new byte[8192]; while (true) { int read = inputStream.read(bArr, 0, 8192); if (read == -1) { byteArrayOutputStream.flush(); return byteArrayOutputStream.toByteArray(); } byteArrayOutputStream.write(bArr, 0, read); } } }