package ඓ.ⁱ.K.㸾;

import android.util.Log;
import com.facebook.AccessToken;
import com.facebook.internal.FileLruCache;
import com.facebook.internal.NativeProtocol;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.CRC32;
import org.json.JSONObject;
import ඓ.ⁱ.K.ʬ.C1240;
import ඓ.ⁱ.K.ʬ.C1241;
import ඓ.ⁱ.K.ʬ.C1243;
import ඓ.ⁱ.K.ʬ.C1248;
import ඓ.ⁱ.K.ඓ.C1250;
import ඓ.ⁱ.K.ඓ.C1252;
import ඓ.ⁱ.K.ῲ.AbstractC1258;
import ඓ.ⁱ.K.K.C1260;
import ඓ.K.K.K.C1293;
import ῲ.ᨨ.㳳.C1841;

/* renamed from: ඓ.ⁱ.K.㸾.䁗  reason: contains not printable characters */
/* compiled from: UploadManager */
public final class C1288 {

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C1243 f5032;

    /* renamed from: K  reason: contains not printable characters */
    public final C1272 f5033;

    /* renamed from: ඓ.ⁱ.K.㸾.䁗$ῲ  reason: contains not printable characters */
    /* compiled from: UploadManager */
    public static class C1289 implements AbstractC1278 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final long f5034;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final long f5035 = System.currentTimeMillis();

        /* renamed from: K  reason: contains not printable characters */
        public final AbstractC1278 f5036;

        /* renamed from: ඓ.ⁱ.K.㸾.䁗$ῲ$ῲ  reason: contains not printable characters */
        /* compiled from: UploadManager */
        public class RunnableC1290 implements Runnable {

            /* renamed from: ʬ  reason: contains not printable characters */
            public final /* synthetic */ C1248 f5037;

            /* renamed from: ῲ  reason: contains not printable characters */
            public final /* synthetic */ String f5039;

            /* renamed from: 㸾  reason: contains not printable characters */
            public final /* synthetic */ JSONObject f5040;

            public RunnableC1290(String str, C1248 r3, JSONObject jSONObject) {
                this.f5039 = str;
                this.f5037 = r3;
                this.f5040 = jSONObject;
            }

            public void run() {
                try {
                    C1289.this.f5036.m3385(this.f5039, this.f5037, this.f5040);
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
        }

        /* renamed from: ඓ.ⁱ.K.㸾.䁗$ῲ$K  reason: contains not printable characters */
        /* compiled from: UploadManager */
        public class C1291 extends C1260.AbstractC1261 {

            /* renamed from: ῲ  reason: contains not printable characters */
            public final /* synthetic */ long f5042;

            /* renamed from: K  reason: contains not printable characters */
            public final /* synthetic */ C1248 f5043;

            public C1291(C1248 r2, long j) {
                this.f5043 = r2;
                this.f5042 = j;
            }

            @Override // ඓ.ⁱ.K.K.C1260.AbstractC1261
            /* renamed from: K  reason: contains not printable characters */
            public String m3398() {
                C1248 r1 = this.f5043;
                return C1252.m3344(new String[]{this.f5043.f4904 + "", r1.f4902, r1.f4903, r1.f4910, this.f5043.f4901 + "", (this.f5042 - C1289.this.f5035) + "", this.f5043.f4905 + "", C1289.this.f5034 + "", "block", C1289.this.f5034 + ""}, ",");
            }
        }

        public C1289(AbstractC1278 r3, long j) {
            this.f5036 = r3;
            this.f5034 = j;
        }

        @Override // ඓ.ⁱ.K.㸾.AbstractC1278
        /* renamed from: K  reason: contains not printable characters */
        public void m3397(String str, C1248 r6, JSONObject jSONObject) {
            C1260.m3368(r6.f4898, new C1291(r6, System.currentTimeMillis()));
            C1841.m4795(new RunnableC1290(str, r6, jSONObject));
        }
    }

    public C1288(C1272 r3) {
        this.f5033 = r3;
        C1240 r1 = r3.f4969;
        this.f5032 = new C1243(r3.f4976, r3.f4973);
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x0024  */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x0041  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x007e  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0085  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x008a A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x008b  */
    /* renamed from: K  reason: contains not printable characters */
    public void m3396(File file, String str, String str2, AbstractC1278 r29, C1269 r30) {
        String str3;
        C1248 r1;
        boolean z;
        String str4;
        C1276 r4 = C1276.m3383(str2);
        if (r29 != null) {
            if (file == null) {
                str4 = "no input data";
            } else if (str2 == null || str2.equals("")) {
                str4 = "no token";
            } else {
                str3 = null;
                if (str3 == null) {
                    r1 = C1248.m3321(null, -4, "", "", "", "", "", "", 80, 0, 0, str3, r4, 0);
                } else if (r4 == C1276.f4987 || r4 == null) {
                    r1 = C1248.m3320("invalid token");
                } else {
                    r1 = (file == null || file.length() != 0) ? null : C1248.m3321(null, -6, "", "", "", "", "", "", 80, 0, 0, "file or data size is zero", r4, 0);
                }
                if (r1 == null) {
                    r29.m3385(str, r1, null);
                    z = true;
                } else {
                    z = false;
                }
                if (z) {
                    this.f5033.f4971.m3367(str2, new C1292(file, str, r4, r29, r30));
                    return;
                }
                return;
            }
            str3 = str4;
            if (str3 == null) {
            }
            if (r1 == null) {
            }
            if (z) {
            }
        } else {
            throw new IllegalArgumentException("no UpCompletionHandler");
        }
    }

    /* renamed from: ඓ.ⁱ.K.㸾.䁗$K  reason: contains not printable characters */
    /* compiled from: UploadManager */
    public class C1292 implements AbstractC1258.AbstractC1259 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ C1276 f5044;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final /* synthetic */ C1269 f5045;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ String f5046;

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ File f5047;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ AbstractC1278 f5049;

        public C1292(File file, String str, C1276 r4, AbstractC1278 r5, C1269 r6) {
            this.f5047 = file;
            this.f5046 = str;
            this.f5044 = r4;
            this.f5049 = r5;
            this.f5045 = r6;
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m3399() {
            long j;
            long length = this.f5047.length();
            C1288 r0 = C1288.this;
            C1272 r8 = r0.f5033;
            if (length <= ((long) r8.f4970)) {
                C1243 r2 = r0.f5032;
                File file = this.f5047;
                String str = this.f5046;
                C1276 r14 = this.f5044;
                AbstractC1278 r6 = this.f5049;
                C1269 r02 = this.f5045;
                C1250 r4 = new C1250();
                C1241 r15 = new C1241();
                if (str != null) {
                    r4.f4922.put(FileLruCache.HEADER_CACHEKEY_KEY, str);
                    r15.f4887 = str;
                } else {
                    r15.f4887 = "?";
                }
                if (file != null) {
                    r15.f4887 = file.getName();
                }
                r4.f4922.put(AccessToken.TOKEN_KEY, r14.f4990);
                if (r02 == null) {
                    r02 = new C1269(null, null, false, null, null);
                }
                r4.f4922.putAll(r02.f4967);
                if (file != null) {
                    try {
                        FileInputStream fileInputStream = new FileInputStream(file);
                        byte[] bArr = new byte[NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST];
                        CRC32 crc32 = new CRC32();
                        while (true) {
                            try {
                                int read = fileInputStream.read(bArr);
                                if (read == -1) {
                                    break;
                                }
                                crc32.update(bArr, 0, read);
                            } catch (Exception e) {
                                e.printStackTrace();
                            } catch (Throwable th) {
                                fileInputStream.close();
                                throw th;
                            }
                        }
                        fileInputStream.close();
                        j = crc32.getValue();
                    } catch (IOException e2) {
                        e2.printStackTrace();
                        j = 0;
                    }
                    r4.f4922.put("crc32", C1293.m3409("", j));
                    C1265 r03 = new C1265(r02, str);
                    r15.f4886 = null;
                    r15.f4885 = file;
                    r15.f4884 = r02.f4966;
                    r15.f4883 = r4;
                    String r3 = r8.f4971.m3364(r14.f4990, r8.f4975, (String) null);
                    Log.d("Qiniu.FormUploader", "upload use up host " + r3);
                    r2.m3313(r3, r15, r14, r03, new C1280(r02, r6, str, r8, r14, r3, r2, r15, r03), r02.f4968);
                    return;
                }
                throw null;
            }
            String r12 = ((C1275) r8.f4972).m3382(this.f5046, this.f5047);
            AbstractC1278 r04 = this.f5049;
            File file2 = this.f5047;
            C1289 r10 = new C1289(r04, file2 != null ? file2.length() : 0);
            C1288 r22 = C1288.this;
            C1841.m4795(new RunnableC1283(r22.f5032, r22.f5033, this.f5047, this.f5046, this.f5044, r10, this.f5045, r12));
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m3400(int i) {
            C1248 r1;
            if (i == -1 || i == -1003 || i == -1004 || i == -1001 || i == -1005) {
                r1 = C1248.m3321(null, i, "", "", "", "", "", "", 80, 0, 0, "Network error during preQuery", this.f5044, 0);
            } else {
                r1 = C1248.m3320("invalid token");
            }
            this.f5049.m3385(this.f5046, r1, null);
        }
    }
}
