京东到家.apk(点击下载) / r.java


package com.tencent.bugly.proguard;

import android.util.Pair;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.client.utils.URLEncodedUtils;
import org.json.JSONArray;
import org.json.JSONObject;

/* compiled from: BUGLY */
public final class r {
    public final Pair<Integer, String> a(List<String> list) {
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("Atta-Type", "batch-report");
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("attaid", "0d000062340").put("token", "2273782735").put("type", "batch").put("version", "v1.0.0");
            JSONArray jSONArray = new JSONArray();
            for (String str : list) {
                jSONArray.put(str);
            }
            jSONObject.put("datas", jSONArray);
            return a("https://h.trace.qq.com/kv", jSONObject.toString(), hashMap);
        } catch (Throwable th) {
            y.b(th);
            return new Pair<>(-1, th.getMessage());
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:45:0x00c7 A[SYNTHETIC, Splitter:B:45:0x00c7] */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x00d2 A[SYNTHETIC, Splitter:B:50:0x00d2] */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x00dc  */
    /* JADX WARNING: Removed duplicated region for block: B:60:0x00ed A[SYNTHETIC, Splitter:B:60:0x00ed] */
    /* JADX WARNING: Removed duplicated region for block: B:65:0x00f8 A[SYNTHETIC, Splitter:B:65:0x00f8] */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x0102  */
    private Pair<Integer, String> a(String str, String str2, Map<String, String> map) {
        HttpURLConnection httpURLConnection;
        Throwable th;
        InputStream inputStream;
        String str3;
        Throwable th2;
        byte[] bytes;
        DataOutputStream dataOutputStream;
        InputStream inputStream2;
        DataOutputStream dataOutputStream2 = null;
        int i = -1;
        try {
            HttpURLConnection httpURLConnection2 = (HttpURLConnection) new URL(str).openConnection();
            try {
                httpURLConnection2.setRequestMethod("POST");
                httpURLConnection2.setDoOutput(true);
                httpURLConnection2.setDoInput(true);
                httpURLConnection2.setUseCaches(false);
                httpURLConnection2.setRequestProperty("Content-Type", URLEncodedUtils.CONTENT_TYPE);
                a(httpURLConnection2, map);
                httpURLConnection2.setConnectTimeout(5000);
                httpURLConnection2.setReadTimeout(5000);
                httpURLConnection2.connect();
                bytes = str2.getBytes("UTF-8");
                dataOutputStream = new DataOutputStream(httpURLConnection2.getOutputStream());
            } catch (Throwable th3) {
                th = th3;
                httpURLConnection = httpURLConnection2;
                inputStream = null;
                if (dataOutputStream2 != null) {
                }
                if (inputStream != null) {
                }
                if (httpURLConnection != null) {
                }
                throw th;
            }
            try {
                dataOutputStream.write(bytes);
                dataOutputStream.flush();
                dataOutputStream.close();
                i = httpURLConnection2.getResponseCode();
                if (i >= 400) {
                    inputStream2 = httpURLConnection2.getErrorStream();
                } else {
                    inputStream2 = httpURLConnection2.getInputStream();
                }
                try {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream2, "UTF-8"));
                    StringBuilder sb = new StringBuilder();
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        sb.append(readLine);
                        sb.append("\r\n");
                    }
                    bufferedReader.close();
                    String sb2 = sb.toString();
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (Exception e) {
                            y.b(e);
                        }
                    }
                    if (httpURLConnection2 != null) {
                        httpURLConnection2.disconnect();
                    }
                    str3 = sb2;
                } catch (Throwable th4) {
                    httpURLConnection = httpURLConnection2;
                    inputStream = inputStream2;
                    th = th4;
                    if (dataOutputStream2 != null) {
                    }
                    if (inputStream != null) {
                    }
                    if (httpURLConnection != null) {
                    }
                    throw th;
                }
            } catch (Throwable th5) {
                th = th5;
                httpURLConnection = httpURLConnection2;
                inputStream = null;
                dataOutputStream2 = dataOutputStream;
                if (dataOutputStream2 != null) {
                }
                if (inputStream != null) {
                }
                if (httpURLConnection != null) {
                }
                throw th;
            }
        } catch (Throwable th6) {
            th = th6;
            inputStream = null;
            httpURLConnection = null;
            if (dataOutputStream2 != null) {
                try {
                    dataOutputStream2.close();
                } catch (Exception e2) {
                    y.b(e2);
                }
            }
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (Exception e3) {
                    y.b(e3);
                }
            }
            if (httpURLConnection != null) {
                httpURLConnection.disconnect();
            }
            throw th;
        }
        return new Pair<>(Integer.valueOf(i), str3);
    }

    private static void a(HttpURLConnection httpURLConnection, Map<String, String> map) {
        if (!(httpURLConnection == null || map == null || map.isEmpty())) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
            }
        }
    }
}