Chromium.apk(点击下载) / CallableC5656wt0.java


package defpackage;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;

/* renamed from: wt0  reason: default package and case insensitive filesystem */
/* compiled from: chromium-ChromePublic.apk-stable-447210115 */
public class CallableC5656wt0 implements Callable {
    public final File a;
    public final File b;
    public final AbstractC5371vE c;
    public final C0376Ft0 d;

    public CallableC5656wt0(File file, File file2, AbstractC5371vE vEVar) {
        C0376Ft0 ft0 = new C0376Ft0();
        this.a = file;
        this.b = file2;
        this.d = ft0;
        this.c = vEVar;
    }

    public final void a(String str, String str2) {
        FileWriter fileWriter = new FileWriter(this.b, true);
        StringBuilder sb = new StringBuilder();
        sb.append(System.currentTimeMillis() / 1000);
        sb.append(",");
        sb.append(str2);
        if (str != null) {
            sb.append(",");
            sb.append(str);
        }
        sb.append('\n');
        try {
            fileWriter.write(sb.toString());
        } finally {
            fileWriter.close();
        }
    }

    /* JADX INFO: finally extract failed */
    /* JADX WARNING: Code restructure failed: missing block: B:72:0x0131, code lost:
        r0 = e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:73:0x0133, code lost:
        r0 = e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:74:0x0134, code lost:
        r0 = defpackage.C0312Et0.a(r0.toString());
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x00cc A[Catch:{ all -> 0x010d, all -> 0x0112 }] */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x00f9  */
    /* JADX WARNING: Removed duplicated region for block: B:72:0x0131 A[ExcHandler: RuntimeException (e java.lang.RuntimeException), Splitter:B:19:0x0078] */
    /* JADX WARNING: Removed duplicated region for block: B:77:0x0140  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0142  */
    /* JADX WARNING: Removed duplicated region for block: B:80:0x0145  */
    /* JADX WARNING: Removed duplicated region for block: B:90:0x0192  */
    /* renamed from: b */
    public Integer call() {
        C0312Et0 et0;
        int i;
        HttpURLConnection httpURLConnection;
        boolean z;
        String str;
        if (this.c.b()) {
            AbstractC5452vj0.d("MDUploadCallable", "Minidump upload enabled for tests, skipping other checks.", new Object[0]);
        } else {
            File file = this.a;
            Pattern pattern = C4849sE.b;
            if (!file.getName().contains(".forced")) {
                if (!this.c.d()) {
                    AbstractC5452vj0.d("MDUploadCallable", "Minidump upload is not permitted by user. Marking file as skipped for cleanup to prevent future uploads.", new Object[0]);
                    C4849sE.j(this.a, ".skipped");
                    return 2;
                } else if (!this.c.c()) {
                    AbstractC5452vj0.d("MDUploadCallable", "Minidump upload skipped due to sampling.  Marking file as skipped for cleanup to prevent future uploads.", new Object[0]);
                    C4849sE.j(this.a, ".skipped");
                    return 3;
                } else if (!this.c.a()) {
                    AbstractC5452vj0.d("MDUploadCallable", "Minidump cannot currently be uploaded due to network constraints.", new Object[0]);
                    return 1;
                }
            }
        }
        C0376Ft0 ft0 = this.d;
        File file2 = this.a;
        Objects.requireNonNull(ft0);
        String str2 = null;
        if (file2 != null) {
            try {
                if (file2.exists()) {
                    Objects.requireNonNull(ft0.a);
                    httpURLConnection = (HttpURLConnection) new URL("https://clients2.google.com/cr/report").openConnection();
                    if (httpURLConnection == null) {
                        et0 = C0312Et0.a("Failed to create connection");
                    } else {
                        ft0.a(httpURLConnection, ft0.b(file2));
                        try {
                            FileInputStream fileInputStream = new FileInputStream(file2);
                            try {
                                GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(httpURLConnection.getOutputStream());
                                try {
                                    ft0.c(fileInputStream, gZIPOutputStream);
                                    int responseCode = httpURLConnection.getResponseCode();
                                    if (!(responseCode == 200 || responseCode == 201)) {
                                        if (responseCode != 202) {
                                            z = false;
                                            if (!z) {
                                                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                                                ft0.c(httpURLConnection.getInputStream(), byteArrayOutputStream);
                                                if (byteArrayOutputStream.size() == 0) {
                                                    str = null;
                                                } else {
                                                    str = byteArrayOutputStream.toString();
                                                }
                                                if (str == null) {
                                                    str = "unknown";
                                                }
                                                C0312Et0 et02 = new C0312Et0(0, str);
                                                gZIPOutputStream.close();
                                                fileInputStream.close();
                                                httpURLConnection.disconnect();
                                                et0 = et02;
                                            } else {
                                                C0312Et0 et03 = new C0312Et0(responseCode, httpURLConnection.getResponseMessage());
                                                gZIPOutputStream.close();
                                                fileInputStream.close();
                                                httpURLConnection.disconnect();
                                                et0 = et03;
                                            }
                                        }
                                    }
                                    z = true;
                                    if (!z) {
                                    }
                                } catch (Throwable th) {
                                    Eq1.a.a(th, th);
                                }
                            } catch (Throwable th2) {
                                Eq1.a.a(th, th2);
                            }
                        } catch (Throwable th3) {
                            httpURLConnection.disconnect();
                            throw th3;
                        }
                    }
                    i = et0.a;
                    if (!(i != 0)) {
                        String str3 = et0.b;
                        String name = this.a.getName();
                        AbstractC5452vj0.d("MDUploadCallable", "Minidump " + name + " uploaded successfully, id: " + str3, new Object[0]);
                        C4849sE.j(this.a, ".up");
                        try {
                            Matcher matcher = C4849sE.b.matcher(name);
                            if (matcher.find()) {
                                str2 = matcher.group(1);
                            }
                            a(str2, str3);
                        } catch (IOException unused) {
                            AbstractC5452vj0.a("MDUploadCallable", "Fail to write uploaded entry to log file", new Object[0]);
                        }
                        return 0;
                    }
                    if (i > 0) {
                        AbstractC5452vj0.d("MDUploadCallable", String.format(Locale.US, "Failed to upload %s with code: %d (%s).", this.a.getName(), Integer.valueOf(et0.a), et0.b), new Object[0]);
                    } else {
                        StringBuilder a2 = AbstractC5933yT0.a("Local error while uploading ");
                        a2.append(this.a.getName());
                        a2.append(": ");
                        a2.append(et0.b);
                        AbstractC5452vj0.a("MDUploadCallable", a2.toString(), new Object[0]);
                    }
                    return 1;
                }
            } catch (IOException unused2) {
                httpURLConnection = null;
            } catch (RuntimeException e) {
            }
        }
        et0 = C0312Et0.a("Crash report does not exist");
        i = et0.a;
        if (!(i != 0)) {
        }
        throw th;
        throw th;
    }
}