惠合 v3.0.0版本的 MD5 值为:0eb47ffc7a53a6b708a3b4e3f9ed0e8c

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


package p.a.y.e.a.s.e.net;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import com.huawei.hms.framework.common.ContainerUtils;
import io.netty.handler.codec.http.HttpHeaders;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public class li2 {
    public static final Pattern lite_do = Pattern.compile("([^\\s;]+)(.*)");
    public static final Pattern lite_if = Pattern.compile("(.*?charset\\s*=[^a-zA-Z0-9]*)([-a-zA-Z0-9]+)(.*)", 2);
    public static final Pattern lite_for = Pattern.compile("(\\<\\?xml\\s+.*?encoding\\s*=[^a-zA-Z0-9]*)([-a-zA-Z0-9]+)(.*)", 2);

    public static final class a extends FilterInputStream {
        private boolean lite_static;

        public a(InputStream inputStream) {
            super(inputStream);
        }

        @Override
        public int read(byte[] bArr, int i, int i2) {
            int read;
            if (this.lite_static || (read = super.read(bArr, i, i2)) == -1) {
                this.lite_static = true;
                return -1;
            }
            return read;
        }
    }

    public static class b {
        public int lite_do;
        public Map<String, String> lite_if;

        public String toString() {
            return String.format("resCode = %1$d, headers = %2$s", Integer.valueOf(this.lite_do), this.lite_if.toString());
        }
    }

    public static boolean lite_break(Context context) {
        ConnectivityManager connectivityManager;
        if ("CN".equalsIgnoreCase(((TelephonyManager) context.getSystemService("phone")).getSimCountryIso())) {
            try {
                connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            } catch (Exception unused) {
            }
            if (connectivityManager == null) {
                return false;
            }
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null) {
                return false;
            }
            String extraInfo = activeNetworkInfo.getExtraInfo();
            return !TextUtils.isEmpty(extraInfo) && extraInfo.length() >= 3 && extraInfo.contains("ctwap");
        }
        return false;
    }

    public static String lite_byte(Context context) {
        if (lite_const(context)) {
            return "wifi";
        }
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager == null) {
                return "";
            }
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null) {
                return "";
            }
            return (activeNetworkInfo.getTypeName() + ye2.lite_final + activeNetworkInfo.getSubtypeName() + ye2.lite_final + activeNetworkInfo.getExtraInfo()).toLowerCase();
        } catch (Exception unused) {
            return "";
        }
    }

    public static String lite_case(Context context, URL url) {
        return lite_char(context, url, false, null, "UTF-8", null);
    }

    public static boolean lite_catch(Context context) {
        return lite_do(context) >= 0;
    }

    public static String lite_char(Context context, URL url, boolean z, String str, String str2, String str3) {
        InputStream inputStream;
        try {
            inputStream = lite_new(context, url, z, str, str3);
            try {
                StringBuilder sb = new StringBuilder(1024);
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, str2));
                char[] cArr = new char[4096];
                while (true) {
                    int read = bufferedReader.read(cArr);
                    if (-1 == read) {
                        bt2.lite_if(inputStream);
                        return sb.toString();
                    }
                    sb.append(cArr, 0, read);
                }
            } catch (Throwable th) {
                th = th;
                bt2.lite_if(inputStream);
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
            inputStream = null;
        }
    }

    public static boolean lite_class(Context context) {
        NetworkInfo networkInfo;
        try {
            networkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
        } catch (Exception unused) {
            networkInfo = null;
        }
        return networkInfo != null && networkInfo.isConnected();
    }

    public static boolean lite_const(Context context) {
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager == null) {
                return false;
            }
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            return activeNetworkInfo != null && 1 == activeNetworkInfo.getType();
        } catch (Exception unused) {
            return false;
        }
    }

    public static int lite_do(Context context) {
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager == null) {
                return -1;
            }
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null) {
                return -1;
            }
            return activeNetworkInfo.getType();
        } catch (Exception unused) {
            return -1;
        }
    }

    public static String lite_else(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        new String();
        return String.format("%s&key=%s", str, ri2.lite_if(String.format("%sbe988a6134bc8254465424e5a70ef037", str)));
    }

    public static boolean lite_final(Context context) {
        return lite_float(context) || lite_short(context) || lite_super(context);
    }

    public static boolean lite_float(Context context) {
        NetworkInfo lite_if2 = lite_if(context);
        return lite_if2 != null && lite_if2.getType() == 0 && 13 == lite_if2.getSubtype();
    }

    public static ji2 lite_for(Context context, String str, String str2, Map<String, String> map, String str3) {
        BufferedReader bufferedReader;
        ji2 ji2Var = new ji2();
        try {
            try {
                try {
                    HttpURLConnection lite_this = lite_this(context, lite_void(str));
                    lite_this.setConnectTimeout(10000);
                    lite_this.setReadTimeout(15000);
                    String str4 = str2;
                    if (str2 == 0) {
                        str4 = lb2.G;
                    }
                    lite_this.setRequestMethod(str4);
                    if (map != null) {
                        for (String str5 : map.keySet()) {
                            lite_this.setRequestProperty(str5, map.get(str5));
                        }
                    }
                    int i = 0;
                    if (!TextUtils.isEmpty(str3)) {
                        lite_this.setDoOutput(true);
                        byte[] bytes = str3.getBytes();
                        OutputStream outputStream = lite_this.getOutputStream();
                        try {
                            outputStream.write(bytes, 0, bytes.length);
                            outputStream.flush();
                            outputStream.close();
                        } catch (IOException e) {
                            e = e;
                            throw new IOException("err while request " + str + ye2.lite_extends + e.getClass().getSimpleName());
                        } catch (Throwable th) {
                            th = th;
                            throw new IOException(th.getMessage());
                        }
                    }
                    ji2Var.lite_do = lite_this.getResponseCode();
                    Log.d("com.xiaomi.common.Network", "Http POST Response Code: " + ji2Var.lite_do);
                    while (true) {
                        String headerFieldKey = lite_this.getHeaderFieldKey(i);
                        String headerField = lite_this.getHeaderField(i);
                        if (headerFieldKey == null && headerField == null) {
                            try {
                                break;
                            } catch (IOException unused) {
                                bufferedReader = new BufferedReader(new InputStreamReader(new a(lite_this.getErrorStream())));
                            }
                        } else {
                            ji2Var.lite_if.put(headerFieldKey, headerField);
                            i = i + 1 + 1;
                        }
                    }
                    bufferedReader = new BufferedReader(new InputStreamReader(new a(lite_this.getInputStream())));
                } catch (Throwable th2) {
                    th = th2;
                }
            } catch (IOException e2) {
                e = e2;
            }
            try {
                StringBuffer stringBuffer = new StringBuffer();
                String property = System.getProperty("line.separator");
                for (String readLine = bufferedReader.readLine(); readLine != null; readLine = bufferedReader.readLine()) {
                    stringBuffer.append(readLine);
                    stringBuffer.append(property);
                }
                ji2Var.lite_for = stringBuffer.toString();
                bufferedReader.close();
                bt2.lite_if(null);
                bt2.lite_if(null);
                return ji2Var;
            } catch (IOException e3) {
                e = e3;
                throw new IOException("err while request " + str + ye2.lite_extends + e.getClass().getSimpleName());
            } catch (Throwable th3) {
                th = th3;
                throw new IOException(th.getMessage());
            }
        } catch (Throwable th4) {
            bt2.lite_if(null);
            bt2.lite_if(str2);
            throw th4;
        }
    }

    public static String lite_goto(String str, Map<String, String> map, File file, String str2) {
        if (!file.exists()) {
            return null;
        }
        String name = file.getName();
        try {
            try {
                HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                httpURLConnection.setReadTimeout(15000);
                httpURLConnection.setConnectTimeout(10000);
                httpURLConnection.setDoInput(true);
                httpURLConnection.setDoOutput(true);
                httpURLConnection.setUseCaches(false);
                httpURLConnection.setRequestMethod(lb2.H);
                httpURLConnection.setRequestProperty("Connection", "Keep-Alive");
                httpURLConnection.setRequestProperty("Content-Type", "multipart/form-data;boundary=*****");
                if (map != null) {
                    for (Map.Entry<String, String> entry : map.entrySet()) {
                        httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
                    }
                }
                httpURLConnection.setFixedLengthStreamingMode(name.length() + 77 + ((int) file.length()) + str2.length());
                DataOutputStream dataOutputStream = new DataOutputStream(httpURLConnection.getOutputStream());
                dataOutputStream.writeBytes("--*****\r\n");
                dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"" + str2 + "\";filename=\"" + file.getName() + "\"\r\n");
                dataOutputStream.writeBytes("\r\n");
                FileInputStream fileInputStream = new FileInputStream(file);
                try {
                    byte[] bArr = new byte[1024];
                    while (true) {
                        int read = fileInputStream.read(bArr);
                        if (read == -1) {
                            break;
                        }
                        dataOutputStream.write(bArr, 0, read);
                        dataOutputStream.flush();
                    }
                    dataOutputStream.writeBytes("\r\n");
                    dataOutputStream.writeBytes("--");
                    dataOutputStream.writeBytes("*****");
                    dataOutputStream.writeBytes("--");
                    dataOutputStream.writeBytes("\r\n");
                    dataOutputStream.flush();
                    StringBuffer stringBuffer = new StringBuffer();
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new a(httpURLConnection.getInputStream())));
                    while (true) {
                        try {
                            String readLine = bufferedReader.readLine();
                            if (readLine == null) {
                                String stringBuffer2 = stringBuffer.toString();
                                bt2.lite_if(fileInputStream);
                                bt2.lite_if(bufferedReader);
                                return stringBuffer2;
                            }
                            stringBuffer.append(readLine);
                        } catch (IOException e) {
                            e = e;
                            throw new IOException("IOException:" + e.getClass().getSimpleName());
                        } catch (Throwable th) {
                            th = th;
                            throw new IOException(th.getMessage());
                        }
                    }
                } catch (IOException e2) {
                    e = e2;
                } catch (Throwable th2) {
                    th = th2;
                }
            } catch (Throwable th3) {
                bt2.lite_if(null);
                bt2.lite_if(file);
                throw th3;
            }
        } catch (IOException e3) {
            e = e3;
        } catch (Throwable th4) {
            th = th4;
        }
    }

    public static NetworkInfo lite_if(Context context) {
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager == null) {
                return null;
            }
            return connectivityManager.getActiveNetworkInfo();
        } catch (Exception unused) {
            return null;
        }
    }

    public static ji2 lite_int(Context context, String str, Map<String, String> map) {
        return lite_for(context, str, lb2.H, null, lite_long(map));
    }

    public static String lite_long(Map<String, String> map) {
        if (map == null || map.size() <= 0) {
            return null;
        }
        StringBuffer stringBuffer = new StringBuffer();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            if (entry.getKey() != null && entry.getValue() != null) {
                try {
                    stringBuffer.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
                    stringBuffer.append(ContainerUtils.KEY_VALUE_DELIMITER);
                    stringBuffer.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
                    stringBuffer.append("&");
                } catch (UnsupportedEncodingException e) {
                    StringBuilder b2 = r5.b("Failed to convert from params map to string: ");
                    b2.append(e.toString());
                    Log.d("com.xiaomi.common.Network", b2.toString());
                    Log.d("com.xiaomi.common.Network", "map: " + map.toString());
                    return null;
                }
            }
        }
        if (stringBuffer.length() > 0) {
            stringBuffer = stringBuffer.deleteCharAt(stringBuffer.length() - 1);
        }
        return stringBuffer.toString();
    }

    public static InputStream lite_new(Context context, URL url, boolean z, String str, String str2) {
        return lite_try(context, url, z, str, str2, null, null);
    }

    public static boolean lite_short(Context context) {
        NetworkInfo lite_if2 = lite_if(context);
        if (lite_if2 != null && lite_if2.getType() == 0) {
            String subtypeName = lite_if2.getSubtypeName();
            if (!"TD-SCDMA".equalsIgnoreCase(subtypeName) && !"CDMA2000".equalsIgnoreCase(subtypeName) && !"WCDMA".equalsIgnoreCase(subtypeName)) {
                switch (lite_if2.getSubtype()) {
                    case 3:
                    case 5:
                    case 6:
                    case 8:
                    case 9:
                    case 10:
                    case 12:
                    case 14:
                    case 15:
                        break;
                    case 4:
                    case 7:
                    case 11:
                    case 13:
                    default:
                        return false;
                }
            }
            return true;
        }
        return false;
    }

    public static boolean lite_super(Context context) {
        NetworkInfo lite_if2 = lite_if(context);
        if (lite_if2 != null && lite_if2.getType() == 0) {
            int subtype = lite_if2.getSubtype();
            return subtype == 1 || subtype == 2 || subtype == 4 || subtype == 7 || subtype == 11;
        }
        return false;
    }

    public static HttpURLConnection lite_this(Context context, URL url) {
        return (HttpURLConnection) ((ot.lite_do.equals(url.getProtocol()) && lite_break(context)) ? url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.200", 80))) : url.openConnection());
    }

    public static InputStream lite_try(Context context, URL url, boolean z, String str, String str2, Map<String, String> map, b bVar) {
        if (context != null) {
            if (url != null) {
                URL url2 = !z ? new URL(lite_else(url.toString())) : url;
                try {
                    HttpURLConnection.setFollowRedirects(true);
                    HttpURLConnection lite_this = lite_this(context, url2);
                    lite_this.setConnectTimeout(10000);
                    lite_this.setReadTimeout(15000);
                    if (!TextUtils.isEmpty(str)) {
                        lite_this.setRequestProperty("User-Agent", str);
                    }
                    if (str2 != null) {
                        lite_this.setRequestProperty(HttpHeaders.Names.COOKIE, str2);
                    }
                    if (map != null) {
                        for (String str3 : map.keySet()) {
                            lite_this.setRequestProperty(str3, map.get(str3));
                        }
                    }
                    if (bVar != null && (url.getProtocol().equals(ot.lite_do) || url.getProtocol().equals("https"))) {
                        bVar.lite_do = lite_this.getResponseCode();
                        if (bVar.lite_if == null) {
                            bVar.lite_if = new HashMap();
                        }
                        int i = 0;
                        while (true) {
                            String headerFieldKey = lite_this.getHeaderFieldKey(i);
                            String headerField = lite_this.getHeaderField(i);
                            if (headerFieldKey == null && headerField == null) {
                                break;
                            }
                            if (!TextUtils.isEmpty(headerFieldKey) && !TextUtils.isEmpty(headerField)) {
                                bVar.lite_if.put(headerFieldKey, headerField);
                            }
                            i++;
                        }
                    }
                    return new a(lite_this.getInputStream());
                } catch (IOException e) {
                    StringBuilder b2 = r5.b("IOException:");
                    b2.append(e.getClass().getSimpleName());
                    throw new IOException(b2.toString());
                } catch (Throwable th) {
                    throw new IOException(th.getMessage());
                }
            }
            throw new IllegalArgumentException("url");
        }
        throw new IllegalArgumentException("context");
    }

    private static URL lite_void(String str) {
        return new URL(str);
    }
}