翰林优商.apk(点击下载) / b.java


package com.tencent.smtt.sdk.stat;

import MTT.ThirdAppInfoNew;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.text.TextUtils;
import com.baidu.mobads.sdk.internal.ae;
import com.tencent.smtt.sdk.QbSdk;
import com.tencent.smtt.sdk.TbsConfig;
import com.tencent.smtt.sdk.TbsCoreLoadStat;
import com.tencent.smtt.sdk.TbsDownloadConfig;
import com.tencent.smtt.sdk.TbsDownloader;
import com.tencent.smtt.sdk.TbsLogReport;
import com.tencent.smtt.sdk.TbsPVConfig;
import com.tencent.smtt.sdk.TbsShareManager;
import com.tencent.smtt.utils.TbsLog;
import com.tencent.smtt.utils.g;
import com.tencent.smtt.utils.k;
import com.tencent.smtt.utils.n;
import com.tencent.smtt.utils.r;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import kotlin.UByte;
import org.json.JSONObject;

public class b {
    public static byte[] a;
    private static ThirdAppInfoNew b;

    static {
        try {
            a = "65dRa93L".getBytes("utf-8");
        } catch (UnsupportedEncodingException unused) {
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:35:0x0090 A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x0093  */
    private static String a(Context context) {
        JSONObject jSONObject;
        JSONObject jSONObject2 = null;
        try {
            jSONObject = new JSONObject();
            try {
                jSONObject.put("cpuabi", com.tencent.smtt.utils.b.c() ? "64" : "32");
                jSONObject.put("ex5i", r.m(context));
                if (TbsShareManager.isThirdPartyApp(context)) {
                    jSONObject.put("canReadSDCard", com.tencent.smtt.utils.b.l(context));
                    if (r.c(context)) {
                        String replace = r.b().replace(",", "-");
                        if (!TextUtils.isEmpty(replace)) {
                            jSONObject.put("coreUpdate", replace);
                        }
                    }
                }
                r.c();
                if (TbsShareManager.isThirdPartyApp(context) && r.i(context)) {
                    String d = r.d();
                    if (!TextUtils.isEmpty(d)) {
                        jSONObject.put("destroyCode", d);
                    }
                }
                if (TbsShareManager.isThirdPartyApp(context) && r.h(context)) {
                    String j = r.j(context);
                    if (!TextUtils.isEmpty(j)) {
                        jSONObject.put("coreSource", j);
                        r.a(QbSdk.getTbsVersion(context));
                    }
                }
            } catch (Throwable unused) {
                jSONObject2 = jSONObject;
                jSONObject = jSONObject2;
                if (jSONObject == null) {
                }
            }
        } catch (Throwable unused2) {
            jSONObject = jSONObject2;
            if (jSONObject == null) {
            }
        }
        return jSONObject == null ? "" : jSONObject.toString();
    }

    public static void a(ThirdAppInfoNew thirdAppInfoNew, Context context) {
        a(thirdAppInfoNew, context, null, null);
    }

    public static void a(final ThirdAppInfoNew thirdAppInfoNew, final Context context, final String str, final String str2) {
        new Thread("HttpUtils") {
            /* class com.tencent.smtt.sdk.stat.b.AnonymousClass1 */

            public void run() {
                String str;
                String str2;
                String str3;
                String str4;
                com.tencent.smtt.utils.b.b(context, thirdAppInfoNew.sGuid);
                thirdAppInfoNew.sCpu = com.tencent.smtt.utils.b.a();
                if (Build.VERSION.SDK_INT >= 8) {
                    JSONObject jSONObject = null;
                    if (b.a == null) {
                        try {
                            b.a = "65dRa93L".getBytes("utf-8");
                        } catch (UnsupportedEncodingException unused) {
                            b.a = null;
                            TbsLog.e("sdkreport", "Post failed -- get POST_DATA_KEY failed!");
                        }
                    }
                    if (b.a == null) {
                        TbsLog.e("sdkreport", "Post failed -- POST_DATA_KEY is null!");
                        return;
                    }
                    String string = TbsDownloadConfig.getInstance(context).mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_DESkEY_TOKEN, "");
                    if (!TextUtils.isEmpty(string)) {
                        str = string.substring(0, string.indexOf("&"));
                        str2 = string.substring(string.indexOf("&") + 1, string.length());
                    } else {
                        str2 = "";
                        str = str2;
                    }
                    boolean z = TextUtils.isEmpty(str) || str.length() != 96 || TextUtils.isEmpty(str2) || str2.length() != 24;
                    try {
                        n a2 = n.a();
                        if (z) {
                            str3 = a2.b() + g.a().b();
                        } else {
                            str3 = a2.i() + str;
                        }
                        TbsLog.i("sdkreport", "Post post_url is " + str3);
                        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str3).openConnection();
                        httpURLConnection.setRequestMethod(ae.b);
                        httpURLConnection.setDoOutput(true);
                        httpURLConnection.setDoInput(true);
                        httpURLConnection.setUseCaches(false);
                        httpURLConnection.setConnectTimeout(20000);
                        if (Build.VERSION.SDK_INT > 13) {
                            httpURLConnection.setRequestProperty("Connection", "close");
                        }
                        try {
                            jSONObject = b.c(thirdAppInfoNew, context);
                        } catch (Exception e) {
                            TbsLog.i(e);
                        }
                        if (jSONObject == null) {
                            TbsLog.e("sdkreport", "post -- jsonData is null!");
                            return;
                        }
                        try {
                            if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
                                try {
                                    JSONObject jSONObject2 = new JSONObject();
                                    jSONObject2.put(str, str2);
                                    str4 = jSONObject2.toString();
                                } catch (Throwable unused2) {
                                    str4 = "";
                                }
                                jSONObject.put("EXT_INFO", str4);
                                jSONObject.put("PV", 0);
                            }
                        } catch (Exception e2) {
                            TbsLog.i(e2);
                        }
                        try {
                            TbsLog.i("sdkreport", "Post jsonData.toString() is " + jSONObject.toString());
                            byte[] bytes = jSONObject.toString().getBytes("utf-8");
                            byte[] a3 = z ? g.a().a(bytes) : g.a(bytes, str2);
                            httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                            httpURLConnection.setRequestProperty("Content-Length", String.valueOf(a3.length));
                            try {
                                OutputStream outputStream = httpURLConnection.getOutputStream();
                                outputStream.write(a3);
                                outputStream.flush();
                                if (httpURLConnection.getResponseCode() == 200) {
                                    TbsLog.i("SDKPVReport", "Post successful!");
                                    TbsLog.i("SDKPVReport", "SIGNATURE is " + jSONObject.getString("SIGNATURE"));
                                    b.b(context, b.b(httpURLConnection, str2, z));
                                    return;
                                }
                                TbsLog.e("SDKPVReport", "Post failed -- not 200 code is " + httpURLConnection.getResponseCode());
                                TbsLogReport.TbsLogInfo tbsLogInfo = TbsLogReport.getInstance(context).tbsLogInfo();
                                tbsLogInfo.setErrorCode(126);
                                tbsLogInfo.setFailDetail("" + httpURLConnection.getResponseCode());
                                TbsLogReport.getInstance(context).eventReport(TbsLogReport.EventType.TYPE_PV_UPLOAD_STAT, tbsLogInfo);
                            } catch (Throwable th) {
                                TbsLog.e("SDKPVReport", "Post failed -- exceptions:" + th.getMessage());
                                TbsLogReport.TbsLogInfo tbsLogInfo2 = TbsLogReport.getInstance(context).tbsLogInfo();
                                tbsLogInfo2.setErrorCode(126);
                                tbsLogInfo2.setFailDetail(th);
                                TbsLogReport.getInstance(context).eventReport(TbsLogReport.EventType.TYPE_PV_UPLOAD_STAT, tbsLogInfo2);
                            }
                        } catch (Throwable unused3) {
                        }
                    } catch (IOException e3) {
                        TbsLog.e("sdkreport", "Post failed -- IOException:" + e3);
                    } catch (AssertionError e4) {
                        TbsLog.e("sdkreport", "Post failed -- AssertionError:" + e4);
                    } catch (NoClassDefFoundError e5) {
                        TbsLog.e("sdkreport", "Post failed -- NoClassDefFoundError:" + e5);
                    } catch (Exception e6) {
                        TbsLog.e("sdkreport", "Post failed -- Exception:" + e6);
                    }
                }
            }
        }.start();
    }

    public static void a(Context context, String str, String str2) {
        if (b == null) {
            ThirdAppInfoNew thirdAppInfoNew = new ThirdAppInfoNew();
            thirdAppInfoNew.sAppName = context.getApplicationContext().getApplicationInfo().packageName;
            n.a(context);
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+08"));
            thirdAppInfoNew.sTime = simpleDateFormat.format(Calendar.getInstance().getTime());
            thirdAppInfoNew.sVersionCode = com.tencent.smtt.utils.b.e(context);
            String a2 = com.tencent.smtt.utils.b.a(context, TbsDownloader.TBS_METADATA);
            if (!TextUtils.isEmpty(a2)) {
                thirdAppInfoNew.sMetaData = a2;
            }
            thirdAppInfoNew.sGuid = "";
            thirdAppInfoNew.sQua2 = k.a(context, "" + QbSdk.getTbsVersion(context));
            thirdAppInfoNew.sLc = "";
            String j = com.tencent.smtt.utils.b.j(context);
            String h = com.tencent.smtt.utils.b.h(context);
            String i = com.tencent.smtt.utils.b.i(context);
            String k = com.tencent.smtt.utils.b.k(context);
            if (h != null && !"".equals(h)) {
                thirdAppInfoNew.sImei = h;
            }
            if (i != null && !"".equals(i)) {
                thirdAppInfoNew.sImsi = i;
            }
            if (!TextUtils.isEmpty(k)) {
                thirdAppInfoNew.sAndroidID = k;
            }
            if (j != null && !"".equals(j)) {
                thirdAppInfoNew.sMac = j;
            }
            thirdAppInfoNew.iPv = 0;
            if (QbSdk.getTbsVersion(context) > 0) {
                thirdAppInfoNew.iCoreType = 1;
            } else {
                thirdAppInfoNew.iCoreType = 0;
                thirdAppInfoNew.localCoreVersion = QbSdk.getTbsVersion(context);
            }
            thirdAppInfoNew.sAppVersionName = context.getApplicationInfo().packageName;
            thirdAppInfoNew.sAppSignature = b(context);
            b = thirdAppInfoNew;
        }
        a(b, context, str, str2);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:53:0x0139, code lost:
        if (r15 != false) goto L_0x013b;
     */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x00b7 A[Catch:{ all -> 0x016f }] */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x00bd A[Catch:{ all -> 0x016f }] */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x00c2 A[Catch:{ all -> 0x016f }] */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x0114 A[Catch:{ all -> 0x016f }] */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x012b A[Catch:{ all -> 0x016f }] */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x0141 A[Catch:{ all -> 0x016f }] */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x0155 A[Catch:{ all -> 0x016f }] */
    public static void a(Context context, String str, String str2, String str3, int i, boolean z, long j, boolean z2) {
        String str4;
        ThirdAppInfoNew thirdAppInfoNew;
        String a2;
        String j2;
        String h;
        String i2;
        String k;
        Exception e;
        if (QbSdk.getSettings() == null || !QbSdk.getSettings().containsKey(QbSdk.KEY_SET_SENDREQUEST_AND_UPLOAD) || !QbSdk.getSettings().get(QbSdk.KEY_SET_SENDREQUEST_AND_UPLOAD).equals("false")) {
            int i3 = 0;
            try {
                ApplicationInfo applicationInfo = context.getApplicationInfo();
                if (TbsConfig.APP_QQ.equals(applicationInfo.packageName)) {
                    str4 = context.getPackageManager().getPackageInfo(applicationInfo.packageName, 0).versionName;
                    try {
                        if (!TextUtils.isEmpty(QbSdk.getQQBuildNumber())) {
                            str4 = str4 + "." + QbSdk.getQQBuildNumber();
                        }
                    } catch (Exception e2) {
                        e = e2;
                        TbsLog.i(e);
                        thirdAppInfoNew = new ThirdAppInfoNew();
                        thirdAppInfoNew.sAppName = context.getApplicationContext().getApplicationInfo().packageName;
                        n.a(context);
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+08"));
                        thirdAppInfoNew.sTime = simpleDateFormat.format(Calendar.getInstance().getTime());
                        thirdAppInfoNew.sVersionCode = com.tencent.smtt.utils.b.e(context);
                        a2 = com.tencent.smtt.utils.b.a(context, TbsDownloader.TBS_METADATA);
                        if (!TextUtils.isEmpty(a2)) {
                        }
                        thirdAppInfoNew.sGuid = str;
                        if (z) {
                        }
                        thirdAppInfoNew.sLc = str3;
                        j2 = com.tencent.smtt.utils.b.j(context);
                        h = com.tencent.smtt.utils.b.h(context);
                        TbsLog.i("sdkreport", "HttpUtils.doReport(): getImeiEnable = " + com.tencent.smtt.utils.b.g(context) + " imei is " + h);
                        i2 = com.tencent.smtt.utils.b.i(context);
                        k = com.tencent.smtt.utils.b.k(context);
                        thirdAppInfoNew.sImei = h;
                        thirdAppInfoNew.sImsi = i2;
                        if (!TextUtils.isEmpty(k)) {
                        }
                        thirdAppInfoNew.sMac = j2;
                        thirdAppInfoNew.iPv = (long) i;
                        if (TbsShareManager.isThirdPartyApp(context)) {
                        }
                        thirdAppInfoNew.iCoreType = 3;
                        thirdAppInfoNew.sAppVersionName = str4;
                        thirdAppInfoNew.sAppSignature = b(context);
                        if (!z) {
                        }
                        b = thirdAppInfoNew;
                        r.a(context, "pv_report", "");
                        r.l(context);
                        a(thirdAppInfoNew, context.getApplicationContext());
                    }
                } else {
                    str4 = "";
                }
            } catch (Exception e3) {
                e = e3;
                str4 = "";
                TbsLog.i(e);
                thirdAppInfoNew = new ThirdAppInfoNew();
                thirdAppInfoNew.sAppName = context.getApplicationContext().getApplicationInfo().packageName;
                n.a(context);
                SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("GMT+08"));
                thirdAppInfoNew.sTime = simpleDateFormat2.format(Calendar.getInstance().getTime());
                thirdAppInfoNew.sVersionCode = com.tencent.smtt.utils.b.e(context);
                a2 = com.tencent.smtt.utils.b.a(context, TbsDownloader.TBS_METADATA);
                if (!TextUtils.isEmpty(a2)) {
                }
                thirdAppInfoNew.sGuid = str;
                if (z) {
                }
                thirdAppInfoNew.sLc = str3;
                j2 = com.tencent.smtt.utils.b.j(context);
                h = com.tencent.smtt.utils.b.h(context);
                TbsLog.i("sdkreport", "HttpUtils.doReport(): getImeiEnable = " + com.tencent.smtt.utils.b.g(context) + " imei is " + h);
                i2 = com.tencent.smtt.utils.b.i(context);
                k = com.tencent.smtt.utils.b.k(context);
                thirdAppInfoNew.sImei = h;
                thirdAppInfoNew.sImsi = i2;
                if (!TextUtils.isEmpty(k)) {
                }
                thirdAppInfoNew.sMac = j2;
                thirdAppInfoNew.iPv = (long) i;
                if (TbsShareManager.isThirdPartyApp(context)) {
                }
                thirdAppInfoNew.iCoreType = 3;
                thirdAppInfoNew.sAppVersionName = str4;
                thirdAppInfoNew.sAppSignature = b(context);
                if (!z) {
                }
                b = thirdAppInfoNew;
                r.a(context, "pv_report", "");
                r.l(context);
                a(thirdAppInfoNew, context.getApplicationContext());
            }
            try {
                thirdAppInfoNew = new ThirdAppInfoNew();
                thirdAppInfoNew.sAppName = context.getApplicationContext().getApplicationInfo().packageName;
                n.a(context);
                SimpleDateFormat simpleDateFormat22 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                simpleDateFormat22.setTimeZone(TimeZone.getTimeZone("GMT+08"));
                thirdAppInfoNew.sTime = simpleDateFormat22.format(Calendar.getInstance().getTime());
                thirdAppInfoNew.sVersionCode = com.tencent.smtt.utils.b.e(context);
                a2 = com.tencent.smtt.utils.b.a(context, TbsDownloader.TBS_METADATA);
                if (!TextUtils.isEmpty(a2)) {
                    thirdAppInfoNew.sMetaData = a2;
                }
                thirdAppInfoNew.sGuid = str;
                if (z) {
                    thirdAppInfoNew.sQua2 = str2;
                    thirdAppInfoNew.bIsSandboxMode = z2;
                } else {
                    thirdAppInfoNew.sQua2 = k.a(context);
                }
                thirdAppInfoNew.sLc = str3;
                j2 = com.tencent.smtt.utils.b.j(context);
                h = com.tencent.smtt.utils.b.h(context);
                TbsLog.i("sdkreport", "HttpUtils.doReport(): getImeiEnable = " + com.tencent.smtt.utils.b.g(context) + " imei is " + h);
                i2 = com.tencent.smtt.utils.b.i(context);
                k = com.tencent.smtt.utils.b.k(context);
                if (h != null && !"".equals(h)) {
                    thirdAppInfoNew.sImei = h;
                }
                if (i2 != null && !"".equals(i2)) {
                    thirdAppInfoNew.sImsi = i2;
                }
                if (!TextUtils.isEmpty(k)) {
                    thirdAppInfoNew.sAndroidID = k;
                }
                if (j2 != null && !"".equals(j2)) {
                    thirdAppInfoNew.sMac = j2;
                }
                thirdAppInfoNew.iPv = (long) i;
                if (TbsShareManager.isThirdPartyApp(context)) {
                    if (!z) {
                        thirdAppInfoNew.iCoreType = 0;
                    } else if (TbsShareManager.getCoreFormOwn()) {
                        thirdAppInfoNew.iCoreType = 2;
                    } else {
                        thirdAppInfoNew.iCoreType = 1;
                    }
                    thirdAppInfoNew.sAppVersionName = str4;
                    thirdAppInfoNew.sAppSignature = b(context);
                    if (!z) {
                        thirdAppInfoNew.sWifiConnectedTime = j;
                        thirdAppInfoNew.localCoreVersion = QbSdk.getTbsVersion(context);
                    }
                    b = thirdAppInfoNew;
                    r.a(context, "pv_report", "");
                    r.l(context);
                    a(thirdAppInfoNew, context.getApplicationContext());
                }
                if (z) {
                    i3 = 1;
                }
                thirdAppInfoNew.iCoreType = i3;
                if (z && z2) {
                }
                thirdAppInfoNew.sAppVersionName = str4;
                thirdAppInfoNew.sAppSignature = b(context);
                if (!z) {
                }
                b = thirdAppInfoNew;
                r.a(context, "pv_report", "");
                r.l(context);
                a(thirdAppInfoNew, context.getApplicationContext());
                thirdAppInfoNew.iCoreType = 3;
                thirdAppInfoNew.sAppVersionName = str4;
                thirdAppInfoNew.sAppSignature = b(context);
                if (!z) {
                }
                b = thirdAppInfoNew;
                r.a(context, "pv_report", "");
                r.l(context);
                a(thirdAppInfoNew, context.getApplicationContext());
            } catch (Throwable th) {
                TbsLog.i(th);
            }
        } else {
            TbsLog.i("sdkreport", "[HttpUtils.doReport] -- SET_SENDREQUEST_AND_UPLOAD is false");
        }
    }

    private static String b(Context context) {
        try {
            byte[] byteArray = context.getPackageManager().getPackageInfo(context.getPackageName(), 64).signatures[0].toByteArray();
            if (byteArray != null) {
                MessageDigest instance = MessageDigest.getInstance("SHA-1");
                instance.update(byteArray);
                byte[] digest = instance.digest();
                if (digest != null) {
                    StringBuilder sb = new StringBuilder("");
                    if (digest != null) {
                        if (digest.length > 0) {
                            for (int i = 0; i < digest.length; i++) {
                                String upperCase = Integer.toHexString(digest[i] & UByte.MAX_VALUE).toUpperCase();
                                if (i > 0) {
                                    sb.append(":");
                                }
                                if (upperCase.length() < 2) {
                                    sb.append(0);
                                }
                                sb.append(upperCase);
                            }
                            return sb.toString();
                        }
                    }
                    return null;
                }
            }
        } catch (Exception e) {
            TbsLog.i(e);
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0040 A[Catch:{ Exception -> 0x007e, all -> 0x007a }, LOOP:0: B:17:0x0039->B:19:0x0040, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0047 A[Catch:{ Exception -> 0x007e, all -> 0x007a }] */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x0059 A[Catch:{ Exception -> 0x007e, all -> 0x007a }] */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0071 A[SYNTHETIC, Splitter:B:29:0x0071] */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x008e A[SYNTHETIC, Splitter:B:45:0x008e] */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x0098 A[SYNTHETIC, Splitter:B:50:0x0098] */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x00c4 A[SYNTHETIC, Splitter:B:59:0x00c4] */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00ce A[SYNTHETIC, Splitter:B:64:0x00ce] */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x0045 A[EDGE_INSN: B:69:0x0045->B:20:0x0045 ?: BREAK  , SYNTHETIC] */
    public static String b(HttpURLConnection httpURLConnection, String str, boolean z) {
        Throwable th;
        InputStream inputStream;
        String str2;
        Exception e;
        ByteArrayOutputStream byteArrayOutputStream;
        byte[] bArr;
        int read;
        InputStream inflaterInputStream;
        ByteArrayOutputStream byteArrayOutputStream2 = null;
        try {
            inputStream = httpURLConnection.getInputStream();
            String contentEncoding = httpURLConnection.getContentEncoding();
            if (contentEncoding == null || !contentEncoding.equalsIgnoreCase("gzip")) {
                if (contentEncoding != null && contentEncoding.equalsIgnoreCase("deflate")) {
                    inflaterInputStream = new InflaterInputStream(inputStream, new Inflater(true));
                }
                byteArrayOutputStream = new ByteArrayOutputStream();
                try {
                    bArr = new byte[128];
                    while (true) {
                        read = inputStream.read(bArr);
                        if (read != -1) {
                            break;
                        }
                        byteArrayOutputStream.write(bArr, 0, read);
                    }
                    str2 = !z ? new String(g.a().c(byteArrayOutputStream.toByteArray())) : new String(g.b(byteArrayOutputStream.toByteArray(), str));
                    try {
                        byteArrayOutputStream.close();
                    } catch (IOException e2) {
                        TbsLog.i(e2);
                    }
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e3) {
                            TbsLog.i(e3);
                        }
                    }
                } catch (Exception e4) {
                    byteArrayOutputStream2 = byteArrayOutputStream;
                    e = e4;
                    try {
                        TbsLog.i(e);
                        if (byteArrayOutputStream2 != null) {
                        }
                        if (inputStream != null) {
                        }
                        str2 = "";
                        TbsLog.i("HttpUtils", "getResponseFromConnection,response=" + str2 + ";isUseRSA=" + z);
                        return str2;
                    } catch (Throwable th2) {
                        th = th2;
                        if (byteArrayOutputStream2 != null) {
                            try {
                                byteArrayOutputStream2.close();
                            } catch (IOException e5) {
                                TbsLog.i(e5);
                            }
                        }
                        if (inputStream != null) {
                            try {
                                inputStream.close();
                            } catch (IOException e6) {
                                TbsLog.i(e6);
                            }
                        }
                        throw th;
                    }
                } catch (Throwable th3) {
                    byteArrayOutputStream2 = byteArrayOutputStream;
                    th = th3;
                    if (byteArrayOutputStream2 != null) {
                    }
                    if (inputStream != null) {
                    }
                    throw th;
                }
                TbsLog.i("HttpUtils", "getResponseFromConnection,response=" + str2 + ";isUseRSA=" + z);
                return str2;
            }
            inflaterInputStream = new GZIPInputStream(inputStream);
            inputStream = inflaterInputStream;
            try {
                byteArrayOutputStream = new ByteArrayOutputStream();
                bArr = new byte[128];
                while (true) {
                    read = inputStream.read(bArr);
                    if (read != -1) {
                    }
                    byteArrayOutputStream.write(bArr, 0, read);
                }
                if (!z) {
                }
                byteArrayOutputStream.close();
                if (inputStream != null) {
                }
            } catch (Exception e7) {
                e = e7;
                TbsLog.i(e);
                if (byteArrayOutputStream2 != null) {
                    try {
                        byteArrayOutputStream2.close();
                    } catch (IOException e8) {
                        TbsLog.i(e8);
                    }
                }
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (IOException e9) {
                        TbsLog.i(e9);
                    }
                }
                str2 = "";
                TbsLog.i("HttpUtils", "getResponseFromConnection,response=" + str2 + ";isUseRSA=" + z);
                return str2;
            }
        } catch (Exception e10) {
            e = e10;
            inputStream = null;
            TbsLog.i(e);
            if (byteArrayOutputStream2 != null) {
            }
            if (inputStream != null) {
            }
            str2 = "";
            TbsLog.i("HttpUtils", "getResponseFromConnection,response=" + str2 + ";isUseRSA=" + z);
            return str2;
        } catch (Throwable th4) {
            th = th4;
            inputStream = null;
            if (byteArrayOutputStream2 != null) {
            }
            if (inputStream != null) {
            }
            throw th;
        }
        TbsLog.i("HttpUtils", "getResponseFromConnection,response=" + str2 + ";isUseRSA=" + z);
        return str2;
    }

    /* access modifiers changed from: private */
    public static void b(Context context, String str) {
        try {
            TbsPVConfig.releaseInstance();
            TbsPVConfig.getInstance(context).clear();
            if (!TextUtils.isEmpty(str)) {
                for (String str2 : str.split("\\|")) {
                    try {
                        String[] split = str2.split("=");
                        if (split.length == 2) {
                            b(context, split[0], split[1]);
                        }
                    } catch (Exception e) {
                        TbsLog.i(e);
                    }
                }
                TbsPVConfig.getInstance(context).commit();
            }
        } catch (Exception e2) {
            TbsLog.i(e2);
        }
    }

    private static void b(Context context, String str, String str2) {
        TbsLog.i("HttpUtils", "PV Config Receive. Key: " + str + ", value: " + str2);
        if ("reset".equals(str) && "true".equals(str2)) {
            QbSdk.reset(context);
        } else if (!"resetCfg24".equals(str) || !"true".equals(str2)) {
            TbsPVConfig.getInstance(context).putData(str, str2);
        } else {
            c(context);
        }
    }

    /* access modifiers changed from: private */
    public static JSONObject c(ThirdAppInfoNew thirdAppInfoNew, Context context) {
        String tid;
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("APPNAME", thirdAppInfoNew.sAppName);
            jSONObject.put("TIME", thirdAppInfoNew.sTime);
            jSONObject.put("QUA2", thirdAppInfoNew.sQua2);
            jSONObject.put("LC", thirdAppInfoNew.sLc);
            jSONObject.put("GUID", thirdAppInfoNew.sGuid);
            jSONObject.put("IMEI", thirdAppInfoNew.sImei);
            jSONObject.put("IMSI", thirdAppInfoNew.sImsi);
            jSONObject.put("MAC", thirdAppInfoNew.sMac);
            jSONObject.put("PV", thirdAppInfoNew.iPv);
            jSONObject.put("CORETYPE", thirdAppInfoNew.iCoreType);
            jSONObject.put("APPVN", thirdAppInfoNew.sAppVersionName);
            jSONObject.put("APPMETADATA", thirdAppInfoNew.sMetaData);
            jSONObject.put("VERSION_CODE", thirdAppInfoNew.sVersionCode);
            jSONObject.put("CPU", thirdAppInfoNew.sCpu);
            jSONObject.put("SIGNATURE", thirdAppInfoNew.sAppSignature == null ? "0" : thirdAppInfoNew.sAppSignature);
            String a2 = a(context);
            TbsLog.i("sdkreport", "addInfo is " + a2);
            if (!TextUtils.isEmpty(a2)) {
                jSONObject.put("EXT_INFO", a2);
            }
            jSONObject.put("PROTOCOL_VERSION", 3);
            jSONObject.put("ANDROID_ID", thirdAppInfoNew.sAndroidID);
            if (!TbsShareManager.isThirdPartyApp(context)) {
                jSONObject.put("HOST_COREVERSION", TbsDownloader.getCoreShareDecoupleCoreVersionByContext(context));
                jSONObject.put("DECOUPLE_COREVERSION", TbsDownloader.getCoreShareDecoupleCoreVersionByContext(context));
            } else if (!"com.xunmeng.pinduoduo".equals(context.getApplicationContext().getApplicationInfo().packageName)) {
                jSONObject.put("HOST_COREVERSION", TbsShareManager.getHostCoreVersions(context));
            }
            jSONObject.put("WIFICONNECTEDTIME", thirdAppInfoNew.sWifiConnectedTime);
            jSONObject.put("CORE_EXIST", thirdAppInfoNew.localCoreVersion);
            int i = TbsCoreLoadStat.mLoadErrorCode;
            if (thirdAppInfoNew.localCoreVersion <= 0) {
                jSONObject.put("TBS_ERROR_CODE", TbsDownloadConfig.getInstance(context).getDownloadInterruptCode());
            } else {
                jSONObject.put("TBS_ERROR_CODE", i);
            }
            if (i == -1) {
                TbsLog.e("sdkreport", "ATTENTION: Load errorCode missed!");
            }
            try {
                if (QbSdk.getTID() != null) {
                    if (thirdAppInfoNew.sAppName.equals(TbsConfig.APP_QQ)) {
                        tid = QbSdk.getTID();
                    } else if (thirdAppInfoNew.sAppName.equals(TbsConfig.APP_WX)) {
                        tid = QbSdk.getTID();
                    }
                    jSONObject.put("TID", tid);
                    jSONObject.put("TIDTYPE", 0);
                }
            } catch (Exception unused) {
            }
            return jSONObject;
        } catch (Exception unused2) {
            TbsLog.e("sdkreport", "getPostData exception!");
            return null;
        }
    }

    private static void c(Context context) {
        SharedPreferences.Editor edit = TbsDownloadConfig.getInstance(context).mPreferences.edit();
        edit.putLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_CHECK, 0);
        edit.apply();
    }
}