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


package com.umeng.commonsdk.stateless;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.text.TextUtils;
import com.baidu.mobads.sdk.internal.ae;
import com.kuaishou.weapon.p0.h;
import com.kwai.video.player.PlayerProps;
import com.umeng.analytics.pro.am;
import com.umeng.commonsdk.debug.UMRTLog;
import com.umeng.commonsdk.framework.UMEnvelopeBuild;
import com.umeng.commonsdk.internal.crash.UMCrashManager;
import com.umeng.commonsdk.statistics.SdkVersion;
import com.umeng.commonsdk.statistics.b;
import com.umeng.commonsdk.statistics.common.DataHelper;
import com.umeng.commonsdk.statistics.common.DeviceConfig;
import com.umeng.commonsdk.statistics.common.MLog;
import com.umeng.commonsdk.statistics.common.ULog;
import com.umeng.commonsdk.vchannel.a;
import java.io.File;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.security.SecureRandom;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import org.apache.http.conn.ssl.SSLSocketFactory;

/* compiled from: UMSLNetWorkSenderHelper */
public class c {
    private String a = "10.0.0.172";
    private int b = 80;
    private Context c;

    public c(Context context) {
        this.c = context;
    }

    private void a() {
        String imprintProperty = UMEnvelopeBuild.imprintProperty(this.c, "sl_domain_p", "");
        if (!TextUtils.isEmpty(imprintProperty)) {
            a.i = DataHelper.assembleStatelessURL(imprintProperty);
        }
    }

    private void b() {
        String imprintProperty = UMEnvelopeBuild.imprintProperty(this.c, "sl_domain_p", "");
        String imprintProperty2 = UMEnvelopeBuild.imprintProperty(this.c, "oversea_sl_domain_p", "");
        if (!TextUtils.isEmpty(imprintProperty)) {
            a.h = DataHelper.assembleStatelessURL(imprintProperty);
        }
        if (!TextUtils.isEmpty(imprintProperty2)) {
            a.k = DataHelper.assembleStatelessURL(imprintProperty2);
        }
        a.i = a.k;
        if (TextUtils.isEmpty(b.b)) {
            return;
        }
        if (b.b.startsWith("460") || b.b.startsWith("461")) {
            a.i = a.h;
        }
    }

    private boolean c() {
        NetworkInfo activeNetworkInfo;
        String extraInfo;
        Context context = this.c;
        if (context == null || context.getPackageManager().checkPermission(h.b, this.c.getPackageName()) != 0) {
            return false;
        }
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) this.c.getSystemService("connectivity");
            if (!DeviceConfig.checkPermission(this.c, h.b) || connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || activeNetworkInfo.getType() == 1 || (extraInfo = activeNetworkInfo.getExtraInfo()) == null || (!extraInfo.equals("cmwap") && !extraInfo.equals("3gwap") && !extraInfo.equals("uniwap"))) {
                return false;
            }
            return true;
        } catch (Throwable th) {
            UMCrashManager.reportCrash(this.c, th);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:25:0x012d, code lost:
        if (r13 == null) goto L_0x015c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:?, code lost:
        com.umeng.commonsdk.debug.UMRTLog.e(com.umeng.commonsdk.debug.UMRTLog.RTLOG_TAG, "--->>> stateless: disconnect connection.");
        r13.disconnect();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:39:0x0148, code lost:
        if (r13 != null) goto L_0x012f;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x0159, code lost:
        if (r13 != null) goto L_0x012f;
     */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x0143 A[SYNTHETIC, Splitter:B:36:0x0143] */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x0154 A[SYNTHETIC, Splitter:B:44:0x0154] */
    public boolean a(byte[] bArr, String str, String str2, String str3) {
        HttpsURLConnection httpsURLConnection;
        SSLHandshakeException e;
        Throwable th;
        boolean z = false;
        if (bArr == null || str == null) {
            ULog.i("walle", "[stateless] sendMessage, envelopeByte == null || path == null ");
            return false;
        }
        if (SdkVersion.SDK_TYPE == 0) {
            a();
        } else {
            a.h = a.k;
            b();
        }
        String str4 = a.i;
        if (!a.c.equalsIgnoreCase(str)) {
            str2 = str4;
        }
        UMRTLog.e(UMRTLog.RTLOG_TAG, "--->>> 无状态收数域名:" + str2);
        OutputStream outputStream = null;
        try {
            if (c()) {
                httpsURLConnection = (HttpsURLConnection) new URL(str2 + File.separator + str).openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(this.a, this.b)));
            } else {
                httpsURLConnection = (HttpsURLConnection) new URL(str2 + File.separator + str).openConnection();
            }
            try {
                httpsURLConnection.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
                SSLContext instance = SSLContext.getInstance("TLS");
                instance.init(null, null, new SecureRandom());
                httpsURLConnection.setSSLSocketFactory(instance.getSocketFactory());
                httpsURLConnection.setRequestProperty("X-Umeng-UTC", String.valueOf(System.currentTimeMillis()));
                httpsURLConnection.setRequestProperty("Msg-Type", "envelope/json");
                httpsURLConnection.setRequestProperty("Content-Type", am.aQ + str3);
                httpsURLConnection.setRequestProperty("SM-IMP", "1");
                httpsURLConnection.setConnectTimeout(PlayerProps.FFP_PROP_FLOAT_MAX_AVDIFF_REALTIME);
                httpsURLConnection.setReadTimeout(PlayerProps.FFP_PROP_FLOAT_MAX_AVDIFF_REALTIME);
                httpsURLConnection.setRequestMethod(ae.b);
                httpsURLConnection.setDoOutput(true);
                httpsURLConnection.setDoInput(true);
                httpsURLConnection.setUseCaches(false);
                OutputStream outputStream2 = httpsURLConnection.getOutputStream();
                outputStream2.write(bArr);
                outputStream2.flush();
                httpsURLConnection.connect();
                if (httpsURLConnection.getResponseCode() == 200) {
                    UMRTLog.i(UMRTLog.RTLOG_TAG, "--->>> send stateless message success : " + a.i + "/" + str);
                    z = true;
                }
                if (outputStream2 != null) {
                    try {
                        outputStream2.close();
                    } catch (Exception unused) {
                    }
                }
            } catch (SSLHandshakeException e2) {
                e = e2;
                MLog.e("SSLHandshakeException, Failed to send message.", e);
                if (0 != 0) {
                }
            } catch (Throwable th2) {
                th = th2;
                try {
                    MLog.e("Exception,Failed to send message.", th);
                    if (0 != 0) {
                    }
                } catch (Throwable unused2) {
                }
            }
        } catch (SSLHandshakeException e3) {
            e = e3;
            httpsURLConnection = null;
            MLog.e("SSLHandshakeException, Failed to send message.", e);
            if (0 != 0) {
                try {
                    outputStream.close();
                } catch (Exception unused3) {
                }
            }
        } catch (Throwable th3) {
            th = th3;
            httpsURLConnection = null;
            MLog.e("Exception,Failed to send message.", th);
            if (0 != 0) {
                try {
                    outputStream.close();
                } catch (Exception unused4) {
                }
            }
        }
        return z;
        throw th;
    }
}