秦华影视 v1.0.0版本的 MD5 值为:90520322e40df4849cf4989ab6339524

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


package com.payeasenet.wepay.utlis;

import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.text.TextUtils;
import com.ehking.sdk.wepay.utlis.LogUtil;
import com.getmessage.module_base.web.FileManager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.NetworkInterface;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NetUtils {
    public static boolean checkIsCurrentWifiHasPassword(Context context) {
        try {
            WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
            WifiInfo connectionInfo = wifiManager.getConnectionInfo();
            List<WifiConfiguration> configuredNetworks = wifiManager.getConfiguredNetworks();
            String ssid = connectionInfo.getSSID();
            if (ssid != null && ssid.length() > 2) {
                if (ssid.startsWith("\"") && ssid.endsWith("\"")) {
                    ssid = ssid.substring(1, ssid.length() - 1);
                }
                if (configuredNetworks != null && configuredNetworks.size() > 0) {
                    for (WifiConfiguration wifiConfiguration : configuredNetworks) {
                        if (wifiConfiguration != null && wifiConfiguration.status == 0) {
                            String str = null;
                            if (!TextUtils.isEmpty(wifiConfiguration.SSID)) {
                                str = wifiConfiguration.SSID;
                                if (str.startsWith("\"") && wifiConfiguration.SSID.endsWith("\"")) {
                                    String str2 = wifiConfiguration.SSID;
                                    str = str2.substring(1, str2.length() - 1);
                                }
                            }
                            if (TextUtils.isEmpty(ssid) || ssid.equalsIgnoreCase(str)) {
                                return !wifiConfiguration.allowedKeyManagement.get(0);
                            }
                        }
                    }
                }
            }
        } catch (Exception unused) {
        }
        return true;
    }

    public static String getMacAddress(Context context) {
        int i = Build.VERSION.SDK_INT;
        if (i < 23) {
            return getMacDefault(context);
        }
        if (i < 23 || i >= 24) {
            return i >= 24 ? getMacFromHardware() : "02:00:00:00:00:00";
        }
        return getMacFromFile();
    }

    private static String getMacDefault(Context context) {
        WifiManager wifiManager;
        WifiInfo wifiInfo;
        if (context == null || (wifiManager = (WifiManager) context.getApplicationContext().getSystemService("wifi")) == null) {
            return "02:00:00:00:00:00";
        }
        try {
            wifiInfo = wifiManager.getConnectionInfo();
        } catch (Exception unused) {
            wifiInfo = null;
        }
        if (wifiInfo == null) {
            return null;
        }
        String macAddress = wifiInfo.getMacAddress();
        return !TextUtils.isEmpty(macAddress) ? macAddress.toUpperCase(Locale.ENGLISH) : macAddress;
    }

    private static String getMacFromFile() {
        try {
            return new BufferedReader(new FileReader(new File("/sys/class/net/wlan0/address"))).readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "02:00:00:00:00:00";
        }
    }

    private static String getMacFromHardware() {
        try {
            for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
                if (networkInterface.getName().equalsIgnoreCase("wlan0")) {
                    byte[] hardwareAddress = networkInterface.getHardwareAddress();
                    if (hardwareAddress == null) {
                        return "";
                    }
                    StringBuilder sb = new StringBuilder();
                    for (byte b : hardwareAddress) {
                        sb.append(String.format("%02X:", Byte.valueOf(b)));
                    }
                    if (sb.length() > 0) {
                        sb.deleteCharAt(sb.length() - 1);
                    }
                    return sb.toString();
                }
            }
            return "02:00:00:00:00:00";
        } catch (Exception e) {
            e.printStackTrace();
            return "02:00:00:00:00:00";
        }
    }

    public static String getNetIp() {
        HttpURLConnection httpURLConnection;
        String str = "0.0.0.0";
        ?? r1 = 0;
        InputStream inputStream = null;
        r1 = 0;
        r1 = 0;
        r1 = 0;
        try {
            try {
                try {
                    httpURLConnection = (HttpURLConnection) new URL("http://pv.sohu.com/cityjson?ie=utf-8").openConnection();
                } catch (Throwable th) {
                    th = th;
                    try {
                        r1.close();
                        r1.disconnect();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                    throw th;
                }
            } catch (MalformedURLException e3) {
                e = e3;
                httpURLConnection = null;
            } catch (IOException e4) {
                e = e4;
                httpURLConnection = null;
            } catch (Throwable th2) {
                th = th2;
                r1.close();
                r1.disconnect();
                throw th;
            }
            try {
                if (httpURLConnection.getResponseCode() == 200) {
                    r1 = httpURLConnection.getInputStream();
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader((InputStream) r1, FileManager.CODE_ENCODING));
                    StringBuilder sb = new StringBuilder();
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        sb.append(readLine + "\n");
                    }
                    Matcher matcher = Pattern.compile("((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))").matcher(sb.toString());
                    inputStream = r1;
                    if (matcher.find()) {
                        str = matcher.group();
                        inputStream = r1;
                    }
                }
                inputStream.close();
                httpURLConnection.disconnect();
            } catch (MalformedURLException e5) {
                e = e5;
                e.printStackTrace();
                r1.close();
                httpURLConnection.disconnect();
                LogUtil.e("getNetIp", str);
                return str;
            } catch (IOException e6) {
                e = e6;
                e.printStackTrace();
                r1.close();
                httpURLConnection.disconnect();
                LogUtil.e("getNetIp", str);
                return str;
            }
        } catch (IOException e7) {
            e7.printStackTrace();
        } catch (Exception e8) {
            e8.printStackTrace();
        }
        LogUtil.e("getNetIp", str);
        return str;
    }
}