package K.K.ʬ;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.places.PlaceManager;
import com.facebook.places.model.PlaceFields;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.NetworkInterface;
import java.util.Collections;
import K.K.K.ʬ.C2369;

/* renamed from: K.K.ʬ.㴹  reason: contains not printable characters */
public class C2360 extends C2359 {
    /* JADX INFO: finally extract failed */
    /* renamed from: ῲ  reason: contains not printable characters */
    public static String m6192() {
        FileInputStream fileInputStream = new FileInputStream(new File("/sys/class/net/wlan0/address"));
        StringWriter stringWriter = new StringWriter();
        char[] cArr = new char[RecyclerView.AbstractC0269.FLAG_MOVED];
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"));
            while (true) {
                int read = bufferedReader.read(cArr);
                if (read != -1) {
                    stringWriter.write(cArr, 0, read);
                } else {
                    fileInputStream.close();
                    String obj = stringWriter.toString();
                    fileInputStream.close();
                    return obj;
                }
            }
        } catch (Throwable th) {
            fileInputStream.close();
            throw th;
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static String m6193(Context context) {
        if (C2369.m6270(context, "android.permission.ACCESS_NETWORK_STATE")) {
            try {
                NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
                if (activeNetworkInfo == null) {
                    return "no_network";
                }
                int type = activeNetworkInfo.getType();
                if (type == 1) {
                    return "WIFI";
                }
                if (type != 0) {
                    return type == -1 ? "no_network" : activeNetworkInfo.getTypeName();
                }
                TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(PlaceFields.PHONE);
                int i = 0;
                if (telephonyManager != null) {
                    i = telephonyManager.getNetworkType();
                }
                switch (i) {
                    case 1:
                    case 2:
                    case 4:
                    case 7:
                    case 11:
                        return "2G";
                    case 3:
                    case 5:
                    case 6:
                    case 8:
                    case 9:
                    case 10:
                    case 12:
                    case 14:
                    case 15:
                        return "3G";
                    case 13:
                        return "4G";
                    default:
                        return String.valueOf(i);
                }
            } catch (Exception unused) {
            }
        }
        return "unknown";
    }

    /* renamed from: K  reason: contains not printable characters */
    public static String m6194() {
        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();
                    int length = hardwareAddress.length;
                    for (int i = 0; i < length; i++) {
                        sb.append(String.format("%02X:", Byte.valueOf(hardwareAddress[i])));
                    }
                    if (sb.length() > 0) {
                        sb.deleteCharAt(sb.length() - 1);
                    }
                    return sb.toString();
                }
            }
            return null;
        } catch (Exception unused) {
            return null;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static String m6195(Context context) {
        WifiManager wifiManager;
        WifiInfo connectionInfo;
        if (!(context == null || !C2369.m6270(context, "android.permission.ACCESS_WIFI_STATE") || (wifiManager = (WifiManager) context.getApplicationContext().getSystemService(PlaceManager.PARAM_WIFI)) == null || (connectionInfo = wifiManager.getConnectionInfo()) == null)) {
            String macAddress = connectionInfo.getMacAddress();
            if (!"02:00:00:00:00:00".equals(macAddress)) {
                return macAddress;
            }
            try {
                String r2 = m6194();
                return r2 == null ? m6192() : r2;
            } catch (IOException | Exception unused) {
            }
        }
        return "02:00:00:00:00:00";
    }
}
