EpgThirdPlayer v0.1.7版本的 MD5 值为:01b85d80b3df6a89b6193076bc73485f

以下内容为反编译后的 k.java 源代码,内容仅作参考


package com.tencent.ktsdk.main.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import com.tencent.ktsdk.main.UniSDKShell;
import com.tencent.thumbplayer.tplayer.plugins.report.TPReportKeys;
import com.tencent.thumbplayer.tplayer.plugins.report.TPReportParams;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.json.JSONObject;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

public class k {

    private static final char[] f53a = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

    public static boolean f52a = false;
    public static HostnameVerifier a = null;

    public static String m41a() {
        return "5.7.0.4";
    }

    public static int b() {
        return 3704;
    }

    public static String a(byte[] bArr) {
        StringBuilder sb = new StringBuilder(bArr.length * 2);
        for (int i = 0; i < bArr.length; i++) {
            sb.append(f53a[(bArr[i] & 240) >>> 4]);
            sb.append(f53a[bArr[i] & 15]);
        }
        return sb.toString();
    }

    public static void m47a(String str, String str2) throws Exception {
        FileOutputStream fileOutputStream;
        ZipInputStream zipInputStream = null;
        FileOutputStream fileOutputStream2 = null;
        zipInputStream = null;
        try {
            ZipInputStream zipInputStream2 = new ZipInputStream(new FileInputStream(str));
            while (true) {
                try {
                    ZipEntry nextEntry = zipInputStream2.getNextEntry();
                    if (nextEntry != null) {
                        String name = nextEntry.getName();
                        if (!TextUtils.isEmpty(name) && name.contains("../")) {
                            break;
                        }
                        if (nextEntry.isDirectory()) {
                            new File(str2 + File.separator + name.substring(0, name.length() - 1)).mkdirs();
                        } else {
                            File file = new File(str2 + File.separator + name);
                            if (!file.getParentFile().exists()) {
                                file.getParentFile().mkdirs();
                            }
                            fileOutputStream = new FileOutputStream(file);
                            try {
                                byte[] bArr = new byte[1024];
                                while (true) {
                                    int read = zipInputStream2.read(bArr);
                                    if (read == -1) {
                                        break;
                                    }
                                    fileOutputStream.write(bArr, 0, read);
                                    fileOutputStream.flush();
                                }
                                fileOutputStream2 = fileOutputStream;
                            } catch (Exception e) {
                                e = e;
                                zipInputStream = zipInputStream2;
                                try {
                                    throw new Exception(e);
                                } catch (Throwable th) {
                                    th = th;
                                    if (zipInputStream != null) {
                                        zipInputStream.close();
                                    }
                                    if (fileOutputStream != null) {
                                        fileOutputStream.close();
                                    }
                                    throw th;
                                }
                            } catch (Throwable th2) {
                                th = th2;
                                zipInputStream = zipInputStream2;
                                if (zipInputStream != null) {
                                }
                                if (fileOutputStream != null) {
                                }
                                throw th;
                            }
                        }
                    } else {
                        zipInputStream2.close();
                        if (fileOutputStream2 != null) {
                            fileOutputStream2.close();
                            return;
                        }
                        return;
                    }
                } catch (Exception e2) {
                    e = e2;
                    fileOutputStream = fileOutputStream2;
                } catch (Throwable th3) {
                    th = th3;
                    fileOutputStream = fileOutputStream2;
                }
            }
        } catch (Exception e3) {
            e = e3;
            fileOutputStream = null;
        } catch (Throwable th4) {
            th = th4;
            fileOutputStream = null;
        }
    }

    public static String a(File file) {
        FileInputStream fileInputStream;
        InputStream inputStream;
        byte[] bArr = new byte[1024];
        String str = null;
        str = null;
        str = null;
        InputStream inputStream2 = null;
        try {
            try {
                try {
                    fileInputStream = new FileInputStream(file);
                    try {
                        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
                        while (true) {
                            int read = fileInputStream.read(bArr);
                            if (read <= 0) {
                                break;
                            }
                            messageDigest.update(bArr, 0, read);
                        }
                        str = a(messageDigest.digest());
                        fileInputStream.close();
                    } catch (Exception e) {
                        e = e;
                        Log.e("PluginUtils", "checkMd5 error " + e.getMessage());
                        if (fileInputStream != null) {
                            fileInputStream.close();
                        }
                        return str;
                    }
                } catch (Throwable th) {
                    th = th;
                    inputStream2 = inputStream;
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }
                    }
                    throw th;
                }
            } catch (Exception e3) {
                e = e3;
                fileInputStream = null;
            } catch (Throwable th2) {
                th = th2;
                if (inputStream2 != null) {
                }
                throw th;
            }
        } catch (Exception e4) {
            e4.printStackTrace();
        }
        return str;
    }

    public static void m46a(File file) {
        if (file.isFile()) {
            file.delete();
            return;
        }
        if (file.isDirectory()) {
            File[] listFiles = file.listFiles();
            if (listFiles == null || listFiles.length == 0) {
                file.delete();
                return;
            }
            for (File file2 : listFiles) {
                m46a(file2);
            }
            file.delete();
        }
    }

    public static void m44a(Context context) {
        File dir;
        if (context == null || (dir = context.getDir("plugindex", 0)) == null || !dir.isDirectory()) {
            return;
        }
        File file = new File(dir + File.separator + "unisdk.dex");
        if (file.exists()) {
            Log.i("PluginUtils", "### deleteOptDexInOptPath :" + file.getAbsolutePath());
            file.delete();
        }
        File file2 = new File(dir + File.separator + "unisdk_player.dex");
        if (file2.exists()) {
            Log.i("PluginUtils", "### deleteOptDexInOptPath :" + file2.getAbsolutePath());
            file2.delete();
        }
    }

    public static d a(String str, String str2) throws Exception {
        d dVar;
        InputStream inputStream = null;
        d a2 = null;
        InputStream inputStream2 = null;
        inputStream = null;
        try {
            try {
                str = new ZipFile(new File((String) str));
                try {
                    ZipEntry entry = str.getEntry(str2);
                    if (entry != null) {
                        String name = entry.getName();
                        if (!TextUtils.isEmpty(name) && name.contains("../")) {
                            throw new Exception("zipEntry name contain ../, throw err");
                        }
                        InputStream inputStream3 = str.getInputStream(entry);
                        if (inputStream3 != null) {
                            try {
                                a2 = a(inputStream3);
                            } catch (Exception e) {
                                e = e;
                                throw new Exception(e);
                            } catch (Throwable th) {
                                inputStream = inputStream3;
                                th = th;
                                if (inputStream != null) {
                                    inputStream.close();
                                }
                                if (str != 0) {
                                    str.close();
                                }
                                throw th;
                            }
                        }
                        d dVar2 = a2;
                        inputStream2 = inputStream3;
                        dVar = dVar2;
                    } else {
                        dVar = null;
                    }
                    if (inputStream2 != null) {
                        inputStream2.close();
                    }
                    if (str != 0) {
                        str.close();
                    }
                    return dVar;
                } catch (Exception e2) {
                    e = e2;
                }
            } catch (Throwable th2) {
                th = th2;
            }
        } catch (Exception e3) {
            e = e3;
        } catch (Throwable th3) {
            th = th3;
            str = 0;
        }
    }

    public static d a(InputStream inputStream) {
        d dVar = null;
        try {
            XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
            newInstance.setNamespaceAware(true);
            XmlPullParser newPullParser = newInstance.newPullParser();
            newPullParser.setInput(inputStream, "utf-8");
            d dVar2 = null;
            for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
                if (eventType == 0) {
                    dVar2 = new d();
                } else if (eventType == 2) {
                    String name = newPullParser.getName();
                    if (name.equalsIgnoreCase("patch_ver")) {
                        if (dVar2 != null) {
                            dVar2.a = newPullParser.nextText();
                            Log.i("PluginUtils", "patch_ver:" + dVar2.a);
                        }
                    } else if (name.equalsIgnoreCase("patch_ver_name")) {
                        if (dVar2 != null) {
                            dVar2.b = newPullParser.nextText();
                            Log.i("PluginUtils", "mVersionName:" + dVar2.a);
                        }
                    } else if (name.equalsIgnoreCase("patch_name")) {
                        if (dVar2 != null) {
                            dVar2.c = newPullParser.nextText();
                            Log.i("PluginUtils", "patch_name:" + dVar2.a);
                        }
                    } else if (name.equalsIgnoreCase("type")) {
                        if (dVar2 != null) {
                            dVar2.d = newPullParser.nextText();
                            Log.i("PluginUtils", "type:" + dVar2.d);
                        }
                    } else if (name.equals("host_info")) {
                        ArrayList arrayList = new ArrayList();
                        while (newPullParser.nextTag() != 3) {
                            c cVar = new c();
                            newPullParser.require(2, null, "host");
                            while (newPullParser.nextTag() != 3) {
                                String name2 = newPullParser.getName();
                                String nextText = newPullParser.nextText();
                                if ("name".equalsIgnoreCase(name2)) {
                                    cVar.a(nextText);
                                    Log.i("PluginUtils", "host name:" + nextText);
                                } else if ("min_ver".equalsIgnoreCase(name2)) {
                                    cVar.a(Integer.parseInt(nextText));
                                    Log.i("PluginUtils", "host min_ver:" + nextText);
                                } else if ("max_ver".equalsIgnoreCase(name2)) {
                                    cVar.b(Integer.parseInt(nextText));
                                    Log.i("PluginUtils", "host max_ver:" + nextText);
                                }
                                newPullParser.require(3, null, name2);
                            }
                            newPullParser.require(3, null, "host");
                            arrayList.add(cVar);
                        }
                        if (dVar2 != null) {
                            dVar2.f15a = arrayList;
                        }
                    } else if (name.equals("files")) {
                        HashMap hashMap = new HashMap();
                        String str = null;
                        String str2 = null;
                        while (newPullParser.nextTag() != 3) {
                            newPullParser.require(2, null, "file");
                            while (newPullParser.nextTag() != 3) {
                                String name3 = newPullParser.getName();
                                String nextText2 = newPullParser.nextText();
                                if ("file_name".equalsIgnoreCase(name3)) {
                                    Log.i("PluginUtils", "file file_name:" + nextText2);
                                    str = nextText2;
                                } else if ("file_md5".equalsIgnoreCase(name3)) {
                                    Log.i("PluginUtils", "file file_md5:" + nextText2);
                                    str2 = nextText2;
                                }
                                newPullParser.require(3, null, name3);
                            }
                            newPullParser.require(3, null, "file");
                            if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
                                hashMap.put(str, str2);
                            }
                        }
                        if (dVar2 != null) {
                            dVar2.f16a = hashMap;
                        }
                    }
                } else if (eventType == 3) {
                    try {
                        newPullParser.getName();
                    } catch (Exception e) {
                        e = e;
                        dVar = dVar2;
                        Log.e("PluginUtils", "error:" + e.getMessage());
                        return dVar;
                    }
                }
            }
            return dVar2;
        } catch (Exception e2) {
            e = e2;
        }
    }

    public static void m45a(Context context, String str, String str2) throws IOException {
        new File(str2 + File.separator + str).mkdirs();
        AssetManager assets = context.getAssets();
        for (String str3 : assets.list(str)) {
            String str4 = str + '/' + str3;
            String[] list = assets.list(str4);
            Log.i("PluginUtils", "copyAssetDirToFiles, child:" + str4 + ", destname: " + str2);
            if (list.length == 0) {
                c(context, str4, str2);
            } else {
                m45a(context, str4, str2);
            }
        }
    }

    public static void b(String str, String str2) throws Exception {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            return;
        }
        String str3 = str2 + File.separator + str.substring(str.lastIndexOf(File.separator) + 1, str.length());
        new File(str3).mkdirs();
        String[] list = new File(str).list();
        if (list != null) {
            for (String str4 : list) {
                String str5 = str + '/' + str4;
                String[] list2 = new File(str5).list();
                if (list2 == null || list2.length == 0) {
                    c(str5, str3);
                } else {
                    b(str5, str3);
                }
            }
        }
    }

    public static void c(String str, String str2) throws Exception {
        FileOutputStream fileOutputStream;
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream2 = null;
        fileInputStream = null;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(new File(str));
            try {
                byte[] bArr = new byte[fileInputStream2.available()];
                if (fileInputStream2.read(bArr) > 0) {
                    int lastIndexOf = str.lastIndexOf(File.separator);
                    String str3 = "";
                    if (lastIndexOf != -1) {
                        str3 = File.separator + str.substring(lastIndexOf + 1, str.length());
                    }
                    new File(str2).mkdirs();
                    File file = new File(str2 + str3);
                    file.createNewFile();
                    fileOutputStream = new FileOutputStream(file);
                    try {
                        fileOutputStream.write(bArr);
                        fileOutputStream2 = fileOutputStream;
                    } catch (Exception e) {
                        e = e;
                        fileInputStream = fileInputStream2;
                        try {
                            throw new Exception(e);
                        } catch (Throwable th) {
                            th = th;
                            if (fileInputStream != null) {
                                fileInputStream.close();
                            }
                            if (fileOutputStream != null) {
                                fileOutputStream.close();
                            }
                            throw th;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        fileInputStream = fileInputStream2;
                        if (fileInputStream != null) {
                        }
                        if (fileOutputStream != null) {
                        }
                        throw th;
                    }
                }
                fileInputStream2.close();
                if (fileOutputStream2 != null) {
                    fileOutputStream2.close();
                }
            } catch (Exception e2) {
                e = e2;
                fileOutputStream = null;
            } catch (Throwable th3) {
                th = th3;
                fileOutputStream = null;
            }
        } catch (Exception e3) {
            e = e3;
            fileOutputStream = null;
        } catch (Throwable th4) {
            th = th4;
            fileOutputStream = null;
        }
    }

    public static int a() {
        boolean z;
        boolean z2;
        String[] list;
        String[] list2;
        AssetManager assets = UniSDKShell.getContext().getAssets();
        String str = "plugin_install_base" + File.separator + "unisdk";
        String str2 = "plugin_install_base" + File.separator + "unisdk_player";
        try {
            list2 = assets.list(str);
        } catch (Exception e) {
            Log.e("PluginUtils", "getPluginModelFlag base dex exception: " + e.getMessage());
        }
        if (list2 != null) {
            if (list2.length != 0) {
                z = true;
                list = assets.list(str2);
                if (list != null) {
                    if (list.length != 0) {
                        z2 = true;
                        int i = (z || z2) ? (z || !z2) ? 0 : 3 : 1;
                        Log.i("PluginUtils", "### isPluginModel pluginModelFlag: " + i);
                        return i;
                    }
                }
                z2 = false;
                if (z) {
                }
                Log.i("PluginUtils", "### isPluginModel pluginModelFlag: " + i);
                return i;
            }
        }
        z = false;
        list = assets.list(str2);
        if (list != null) {
        }
        z2 = false;
        if (z) {
        }
        Log.i("PluginUtils", "### isPluginModel pluginModelFlag: " + i);
        return i;
    }

    public static String a(Context context, String str, String str2) {
        return context.getSharedPreferences("plugin_setting", 0).getString(str, str2);
    }

    public static void a(Context context, String str, int i) {
        context.getSharedPreferences("plugin_setting", 0).edit().putInt(str, i).commit();
    }

    public static void b(Context context, String str, String str2) {
        context.getSharedPreferences("plugin_setting", 0).edit().putString(str, str2).commit();
    }

    public static void a(Context context, String str, String str2, int i) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("plugin_setting", 0);
        String string = sharedPreferences.getString(str, null);
        if (!TextUtils.isEmpty(string)) {
            try {
                JSONObject jSONObject = new JSONObject(string);
                jSONObject.put(str2, i);
                sharedPreferences.edit().putString(str, jSONObject.toString()).commit();
                return;
            } catch (Exception e) {
                Log.e("PluginUtils", "saveIntForModule " + e.getMessage());
                try {
                    JSONObject jSONObject2 = new JSONObject(string);
                    jSONObject2.put(str2, i);
                    sharedPreferences.edit().putString(str, jSONObject2.toString()).commit();
                    return;
                } catch (Exception e2) {
                    Log.e("PluginUtils", "saveIntForModule " + e2.getMessage());
                    return;
                }
            }
        }
        try {
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put(str2, i);
            sharedPreferences.edit().putString(str, jSONObject3.toString()).commit();
        } catch (Exception e3) {
            Log.e("PluginUtils", "saveIntForModule " + e3.getMessage());
            try {
                JSONObject jSONObject4 = new JSONObject();
                jSONObject4.put(str2, i);
                sharedPreferences.edit().putString(str, jSONObject4.toString()).commit();
            } catch (Exception e4) {
                Log.e("PluginUtils", "saveIntForModule " + e4.getMessage());
            }
        }
    }

    public static Map<String, Object> a(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("plugin_setting", 0);
        String string = sharedPreferences.getString("unisdk", null);
        String string2 = sharedPreferences.getString("unisdk_player", null);
        String string3 = sharedPreferences.getString("unisdk_core", null);
        String string4 = sharedPreferences.getString("unisdk_p2p", null);
        String string5 = sharedPreferences.getString("unisdk_ckey", null);
        String string6 = sharedPreferences.getString("plugin_last_depress_shell_vnname", TPReportParams.ERROR_CODE_NO_ERROR);
        int i = sharedPreferences.getInt("plugin_last_depress_shell_vncode", 0);
        HashMap hashMap = new HashMap();
        hashMap.put("unisdk", string);
        hashMap.put("unisdk_player", string2);
        hashMap.put("unisdk_core", string3);
        hashMap.put("unisdk_p2p", string4);
        hashMap.put("unisdk_ckey", string5);
        hashMap.put("plugin_last_depress_shell_vncode", Integer.valueOf(i));
        hashMap.put("plugin_last_depress_shell_vnname", string6);
        Log.i("PluginUtils", hashMap.toString());
        return hashMap;
    }

    public static void c(Context context, String str, String str2) throws IOException {
        FileOutputStream fileOutputStream;
        InputStream inputStream = null;
        FileOutputStream fileOutputStream2 = null;
        inputStream = null;
        try {
            InputStream open = context.getAssets().open(str);
            try {
                byte[] bArr = new byte[open.available()];
                if (open.read(bArr) > 0) {
                    File file = new File(str2 + File.separator + str);
                    file.createNewFile();
                    fileOutputStream = new FileOutputStream(file);
                    try {
                        fileOutputStream.write(bArr);
                        fileOutputStream2 = fileOutputStream;
                    } catch (IOException e) {
                        e = e;
                        inputStream = open;
                        try {
                            throw new IOException(e);
                        } catch (Throwable th) {
                            th = th;
                            if (inputStream != null) {
                                inputStream.close();
                            }
                            if (fileOutputStream != null) {
                                fileOutputStream.close();
                            }
                            throw th;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        inputStream = open;
                        if (inputStream != null) {
                        }
                        if (fileOutputStream != null) {
                        }
                        throw th;
                    }
                }
                if (open != null) {
                    open.close();
                }
                if (fileOutputStream2 != null) {
                    fileOutputStream2.close();
                }
            } catch (IOException e2) {
                e = e2;
                fileOutputStream = null;
            } catch (Throwable th3) {
                th = th3;
                fileOutputStream = null;
            }
        } catch (IOException e3) {
            e = e3;
            fileOutputStream = null;
        } catch (Throwable th4) {
            th = th4;
            fileOutputStream = null;
        }
    }

    public static void a(int i, e eVar, String str) {
        int i2;
        String str2;
        if (eVar != null) {
            str2 = eVar.d();
            i2 = eVar.b();
        } else {
            i2 = 0;
            str2 = "";
        }
        Properties properties = new Properties();
        properties.put(TPReportKeys.PlayerStep.PLAYER_ERROR_CODE, Integer.valueOf(i));
        properties.put("version", Integer.valueOf(i2));
        properties.put("pluginName", str2 != null ? str2 : "");
        properties.put(NotificationCompat.CATEGORY_MESSAGE, str);
        com.tencent.ktsdk.main.shellmodule.e.a(properties);
    }

    public static String m42a(String str, String str2) {
        HttpURLConnection httpURLConnection;
        BufferedReader bufferedReader;
        HttpURLConnection httpURLConnection2;
        InputStream inputStream;
        HttpsURLConnection httpsURLConnection;
        StringBuffer stringBuffer = new StringBuffer();
        InputStream inputStream2 = null;
        try {
            URL url = new URL(str);
            Proxy a2 = a(str);
            if (url.getProtocol().toLowerCase(Locale.getDefault()).equals("https")) {
                if (!f52a) {
                    m43a();
                }
                if (a2 != null) {
                    httpsURLConnection = (HttpsURLConnection) url.openConnection(a2);
                } else {
                    httpsURLConnection = (HttpsURLConnection) url.openConnection();
                }
                httpURLConnection2 = httpsURLConnection;
                if (!f52a) {
                    httpURLConnection2 = httpsURLConnection;
                    if (a != null) {
                        httpsURLConnection.setHostnameVerifier(a);
                        httpURLConnection2 = httpsURLConnection;
                    }
                }
            } else if (a2 != null) {
                httpURLConnection2 = (HttpURLConnection) url.openConnection(a2);
            } else {
                httpURLConnection2 = (HttpURLConnection) url.openConnection();
            }
            try {
                if (!TextUtils.isEmpty(str2)) {
                    httpURLConnection2.setRequestProperty("cookie", str2);
                }
                httpURLConnection2.setDoInput(true);
                httpURLConnection2.setConnectTimeout(10000);
                httpURLConnection2.setRequestMethod("GET");
                httpURLConnection2.setRequestProperty("accept", "*/*");
                int responseCode = httpURLConnection2.getResponseCode();
                httpURLConnection2.connect();
                if (responseCode == 200) {
                    InputStream inputStream3 = httpURLConnection2.getInputStream();
                    try {
                        bufferedReader = new BufferedReader(new InputStreamReader(inputStream3, "UTF-8"));
                        while (true) {
                            try {
                                String readLine = bufferedReader.readLine();
                                if (readLine == null) {
                                    break;
                                }
                                stringBuffer.append(readLine);
                            } catch (Exception e) {
                                inputStream = inputStream3;
                                httpURLConnection = httpURLConnection2;
                                e = e;
                                inputStream2 = inputStream;
                                try {
                                    Log.e("PluginUtils", "Exception: " + e.getMessage());
                                    if (inputStream2 != null) {
                                        try {
                                            inputStream2.close();
                                        } catch (Exception unused) {
                                        }
                                    }
                                    if (bufferedReader != null) {
                                        try {
                                            bufferedReader.close();
                                        } catch (Exception unused2) {
                                        }
                                    }
                                    if (httpURLConnection != null) {
                                        httpURLConnection.disconnect();
                                    }
                                    return stringBuffer.toString();
                                } catch (Throwable th) {
                                    th = th;
                                    if (inputStream2 != null) {
                                        try {
                                            inputStream2.close();
                                        } catch (Exception unused3) {
                                        }
                                    }
                                    if (bufferedReader != null) {
                                        try {
                                            bufferedReader.close();
                                        } catch (Exception unused4) {
                                        }
                                    }
                                    if (httpURLConnection != null) {
                                        throw th;
                                    }
                                    httpURLConnection.disconnect();
                                    throw th;
                                }
                            } catch (Throwable th2) {
                                th = th2;
                                inputStream2 = inputStream3;
                                httpURLConnection = httpURLConnection2;
                                th = th;
                                if (inputStream2 != null) {
                                }
                                if (bufferedReader != null) {
                                }
                                if (httpURLConnection != null) {
                                }
                            }
                        }
                        inputStream2 = inputStream3;
                    } catch (Exception e2) {
                        inputStream = inputStream3;
                        httpURLConnection = httpURLConnection2;
                        e = e2;
                        bufferedReader = null;
                    } catch (Throwable th3) {
                        th = th3;
                        bufferedReader = null;
                    }
                } else {
                    bufferedReader = null;
                }
                if (inputStream2 != null) {
                    try {
                        inputStream2.close();
                    } catch (Exception unused5) {
                    }
                }
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                    } catch (Exception unused6) {
                    }
                }
                if (httpURLConnection2 != null) {
                    httpURLConnection2.disconnect();
                }
            } catch (Exception e3) {
                bufferedReader = null;
                httpURLConnection = httpURLConnection2;
                e = e3;
            } catch (Throwable th4) {
                bufferedReader = null;
                httpURLConnection = httpURLConnection2;
                th = th4;
            }
        } catch (Exception e4) {
            e = e4;
            httpURLConnection = null;
            bufferedReader = null;
        } catch (Throwable th5) {
            th = th5;
            httpURLConnection = null;
            bufferedReader = null;
        }
        return stringBuffer.toString();
    }

    private static void m43a() {
        TrustManager[] trustManagerArr = {new X509TrustManager() {
            @Override
            public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
            }

            @Override
            public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
            }

            @Override
            public X509Certificate[] getAcceptedIssuers() {
                return new X509Certificate[0];
            }
        }};
        try {
            SSLContext sSLContext = SSLContext.getInstance("TLS");
            sSLContext.init(null, trustManagerArr, new SecureRandom());
            HttpsURLConnection.setDefaultSSLSocketFactory(sSLContext.getSocketFactory());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static boolean m48a(String str) {
        return str != null && str.length() >= 6 && "https:".equalsIgnoreCase(str.substring(0, 6));
    }

    public static Proxy a(String str) {
        if (str == null) {
            return null;
        }
        boolean m48a = m48a(str);
        String proxyHost = UniSDKShell.getInitConfig().getProxyHost();
        int proxyPort = UniSDKShell.getInitConfig().getProxyPort();
        String proxyHostHttps = UniSDKShell.getInitConfig().getProxyHostHttps();
        int proxyPortHttps = UniSDKShell.getInitConfig().getProxyPortHttps();
        if (m48a) {
            if (TextUtils.isEmpty(proxyHostHttps) || proxyPortHttps <= 0) {
                return null;
            }
            return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHostHttps, proxyPortHttps));
        }
        if (TextUtils.isEmpty(proxyHost) || proxyPort <= 0) {
            return null;
        }
        return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
    }
}