package com.google.android.gms.measurement.internal;

import android.app.ActivityManager;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import com.google.ads.interactivemedia.pal.PlatformSignalCollector;
import com.google.android.gms.internal.measurement.ga;
import com.google.android.gms.internal.measurement.i9;
import com.google.android.gms.internal.measurement.ia;
import com.google.android.gms.internal.measurement.ja;
import com.google.android.gms.internal.measurement.k9;
import com.google.android.gms.internal.measurement.l9;
import com.google.firebase.components.ComponentRegistrar;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.Key;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.Provider;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.logging.Level;
import javax.crypto.Cipher;
import javax.crypto.KeyAgreement;
import javax.crypto.spec.SecretKeySpec;
import tv.danmaku.ijk.media.player.IjkMediaMeta;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class c0 implements e0, PlatformSignalCollector, sa.k, com.google.firebase.components.f, ed.h, fe.g {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static c0 f21496b;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f21497a;

    public /* synthetic */ c0(int i10) {
        this.f21497a = i10;
    }

    public static String e() {
        InetAddress inetAddress;
        SocketException e10;
        String strF = f("eth0");
        if (TextUtils.isEmpty(strF)) {
            try {
                try {
                    Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
                    inetAddress = null;
                    do {
                        try {
                            if (!networkInterfaces.hasMoreElements()) {
                                break;
                            }
                            Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
                            while (true) {
                                if (!inetAddresses.hasMoreElements()) {
                                    break;
                                }
                                InetAddress inetAddressNextElement = inetAddresses.nextElement();
                                try {
                                    if (!inetAddressNextElement.isLoopbackAddress()) {
                                        String hostAddress = inetAddressNextElement.getHostAddress();
                                        Objects.requireNonNull(hostAddress);
                                        if (!hostAddress.contains(":")) {
                                            inetAddress = inetAddressNextElement;
                                            break;
                                        }
                                    }
                                    inetAddress = null;
                                } catch (SocketException e11) {
                                    e10 = e11;
                                    inetAddress = inetAddressNextElement;
                                    e10.printStackTrace();
                                }
                            }
                        } catch (SocketException e12) {
                            e10 = e12;
                        }
                    } while (inetAddress == null);
                } catch (Exception unused) {
                    strF = "";
                }
            } catch (SocketException e13) {
                inetAddress = null;
                e10 = e13;
            }
            byte[] hardwareAddress = NetworkInterface.getByInetAddress(inetAddress).getHardwareAddress();
            StringBuilder sb = new StringBuilder();
            for (int i10 = 0; i10 < hardwareAddress.length; i10++) {
                if (i10 != 0) {
                    sb.append(':');
                }
                String hexString = Integer.toHexString(hardwareAddress[i10] & 255);
                if (hexString.length() == 1) {
                    hexString = 0 + hexString;
                }
                sb.append(hexString);
            }
            strF = sb.toString().toUpperCase();
        }
        return !TextUtils.isEmpty(strF) ? strF.toLowerCase(Locale.US) : strF;
    }

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

    public static HashMap g() {
        byte[] bArrDoFinal;
        String string;
        int i10;
        int blockSizeLong;
        BluetoothAdapter defaultAdapter;
        HashMap map = new HashMap();
        String strN = kotlinx.coroutines.flow.h.n("persist.sys.sn");
        String str = "";
        if (TextUtils.isEmpty(strN)) {
            string = "";
        } else {
            xyz.stream.utils.a0 a0Var = new xyz.stream.utils.a0();
            try {
                StringBuilder sb = new StringBuilder((TextUtils.isEmpty(strN) || strN.length() <= 24) ? strN : strN.substring(0, 24));
                while (sb.length() < 24) {
                    sb.append(SessionDescription.SUPPORTED_SDP_VERSION);
                }
                a0Var.f36098a = new SecretKeySpec(sb.toString().getBytes(), "DESede");
            } catch (Exception e10) {
                e10.printStackTrace();
            }
            try {
                byte[] bytes = strN.getBytes();
                try {
                    Cipher cipher = Cipher.getInstance("DESede");
                    cipher.init(1, (Key) a0Var.f36098a);
                    bArrDoFinal = cipher.doFinal(bytes);
                } catch (Exception e11) {
                    e11.printStackTrace();
                    bArrDoFinal = null;
                }
                StringBuilder sb2 = new StringBuilder(bArrDoFinal.length * 2);
                for (int i11 : bArrDoFinal) {
                    while (i11 < 0) {
                        i11 += 256;
                    }
                    if (i11 < 16) {
                        sb2.append(SessionDescription.SUPPORTED_SDP_VERSION);
                    }
                    sb2.append(Integer.toString(i11, 16));
                }
                string = sb2.toString();
            } catch (Exception e12) {
                e12.printStackTrace();
                string = "";
            }
        }
        map.put("authenticator", string);
        map.put("ethMac", e().replace(":", ""));
        map.put("wifiMac", h(xyz.stream.utils.e.d().f36112a).replace(":", ""));
        Context context = xyz.stream.utils.e.d().f36112a;
        try {
            defaultAdapter = BluetoothAdapter.getDefaultAdapter();
        } catch (Exception unused) {
        }
        String address = (defaultAdapter != null && g0.d.a(context, "android.permission.BLUETOOTH") == 0) ? defaultAdapter.getAddress() : "";
        map.put("btMac", address.replace(":", ""));
        String str2 = "unknown";
        try {
            String string2 = Settings.Secure.getString(xyz.stream.utils.e.d().f36112a.getContentResolver(), "android_id");
            if (string2 != null) {
                if (!string2.isEmpty()) {
                    str2 = string2;
                }
            }
        } catch (Exception unused2) {
        }
        map.put("androidId", str2);
        String strN2 = kotlinx.coroutines.flow.h.n("ro.customize.model");
        if (TextUtils.isEmpty(strN2)) {
            strN2 = Build.MODEL;
        }
        map.put("model", strN2);
        map.put("manufacturer", Build.MANUFACTURER);
        map.put("brand", Build.BRAND);
        map.put("hardware", Build.HARDWARE);
        map.put("serialNumber", Build.SERIAL);
        try {
            ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
            ((ActivityManager) xyz.stream.utils.e.d().f36112a.getSystemService("activity")).getMemoryInfo(memoryInfo);
            i10 = (int) (memoryInfo.totalMem / 1048576);
        } catch (Exception e13) {
            e13.printStackTrace();
            i10 = 0;
        }
        map.put("memorySize", Integer.valueOf(i10));
        map.put("androidVersion", Build.VERSION.RELEASE);
        try {
            StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
            blockSizeLong = (int) ((statFs.getBlockSizeLong() * statFs.getBlockCountLong()) / 1048576);
        } catch (Exception e14) {
            e14.printStackTrace();
            blockSizeLong = 0;
        }
        map.put("storageSize", Integer.valueOf(blockSizeLong));
        map.put("imei", "");
        map.put("device", Build.DEVICE);
        map.put("board", Build.BOARD);
        map.put("appName", "Netfly");
        Context context2 = xyz.stream.utils.e.d().f36112a;
        try {
            str = context2.getPackageManager().getPackageInfo(context2.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException unused3) {
        }
        map.put("appVersion", str);
        if (xyz.stream.utils.e.d().f36118g) {
            map.put("terminalType", "AndroidTV");
        } else if (xyz.stream.utils.e.d().f36119h) {
            map.put("terminalType", "AndroidPad");
        } else {
            map.put("terminalType", "AndroidMobile");
        }
        xyz.stream.utils.e.d().getClass();
        map.put(IjkMediaMeta.IJKM_KEY_LANGUAGE, xyz.stream.utils.e.e());
        return map;
    }

    public static String h(Context context) {
        WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService("wifi");
        if (wifiManager != null) {
            wifiManager.getConnectionInfo();
        }
        String strF = f("wlan0");
        if (strF.equals("02:00:00:00:00:00")) {
            strF = "";
        }
        return !TextUtils.isEmpty(strF) ? strF.toLowerCase(Locale.US) : strF;
    }

    @Override // fe.g
    public final void a(Level level, String str) {
        System.out.println("[" + level + "] " + str);
    }

    @Override // sa.k
    public final Object b(String str, Provider provider) {
        switch (this.f21497a) {
            case 9:
                return provider == null ? KeyAgreement.getInstance(str) : KeyAgreement.getInstance(str, provider);
            case 10:
                return provider == null ? KeyPairGenerator.getInstance(str) : KeyPairGenerator.getInstance(str, provider);
            default:
                return provider == null ? MessageDigest.getInstance(str) : MessageDigest.getInstance(str, provider);
        }
    }

    @Override // com.google.firebase.components.f
    public final List c(ComponentRegistrar componentRegistrar) {
        ArrayList arrayList = new ArrayList();
        for (com.google.firebase.components.a aVarD : componentRegistrar.getComponents()) {
            String name = aVarD.getName();
            if (name != null) {
                aVarD = aVarD.d(new nb.e(name, aVarD, 1));
            }
            arrayList.add(aVarD);
        }
        return arrayList;
    }

    @Override // com.google.ads.interactivemedia.pal.PlatformSignalCollector
    public final w8.h collectSignals(Context context, ExecutorService executorService) {
        w8.i iVar = new w8.i();
        context.getClass();
        executorService.getClass();
        executorService.execute(new com.google.android.gms.common.api.internal.v0(iVar, context, 9, 0));
        return iVar.f34224a;
    }

    @Override // fe.g
    public final void d(Level level, String str, Throwable th) {
        PrintStream printStream = System.out;
        printStream.println("[" + level + "] " + str);
        th.printStackTrace(printStream);
    }

    @Override // com.google.android.gms.measurement.internal.e0
    public final Object zza() {
        switch (this.f21497a) {
            case 0:
                ((ia) ((ja) ga.f20212b.get())).getClass();
                return Boolean.valueOf(((Boolean) ia.f20242c.a()).booleanValue());
            case 1:
                ((ia) ((ja) ga.f20212b.get())).getClass();
                return Boolean.valueOf(((Boolean) ia.f20244e.a()).booleanValue());
            case 2:
                ((k9) ((l9) i9.f20238b.get())).getClass();
                return Boolean.valueOf(((Boolean) k9.f20288a.a()).booleanValue());
            default:
                ((k9) ((l9) i9.f20238b.get())).getClass();
                return Boolean.valueOf(((Boolean) k9.f20289b.a()).booleanValue());
        }
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ c0(int i10, int i11) {
        this(14);
        this.f21497a = i10;
        switch (i10) {
            case 16:
                this(16);
                break;
            case 17:
                this(17);
                break;
            case 18:
                this(18);
                break;
            case 19:
                this(19);
                break;
            case 20:
                this(20);
                break;
            case 21:
                this(21);
                break;
            case 22:
                this(22);
                break;
            case 23:
                this(23);
                break;
            case 24:
                this(24);
                break;
            case 25:
                this(25);
                break;
            case 26:
                this(26);
                break;
            case 27:
                this(27);
                break;
            default:
                break;
        }
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ c0() {
        this(15);
        this.f21497a = 15;
    }
}
