Ultra-SDP v1.0.0版本的 MD5 值为:5418115cd4b552c4cd79d6d68815af17

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


package com.zta.util;

import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Process;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.zta.android.news.util.HarMonyUtil;
import com.zta.util.ShellTool;
import com.zta.util.StartVpnHelper;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Locale;
import java.util.TimeZone;
import java.util.UUID;
import kotlin.UByte;
import org.json.JSONException;
import org.json.JSONObject;
public class DeviceTool {
    static final boolean $assertionsDisabled = false;

    public static String getMacAddress(Context context) {
        StringBuffer stringBuffer = new StringBuffer();
        try {
            NetworkInterface byName = NetworkInterface.getByName("eth1");
            if (byName == null) {
                byName = NetworkInterface.getByName("wlan0");
            }
            if (byName == null) {
                return "02:00:00:00:00:00";
            }
            byte[] hardwareAddress = byName.getHardwareAddress();
            int length = hardwareAddress.length;
            for (int i = 0; i < length; i++) {
                stringBuffer.append(String.format("%02X:", Byte.valueOf(hardwareAddress[i])));
            }
            if (stringBuffer.length() > 0) {
                stringBuffer.deleteCharAt(stringBuffer.length() - 1);
            }
            return stringBuffer.toString();
        } catch (SocketException e) {
            e.printStackTrace();
            return "02:00:00:00:00:00";
        }
    }

    public static String getDevicesName() {
        return Build.MANUFACTURER + "-" + Build.MODEL;
    }

    public static String getVersionName(Context context) {
        try {
            return context.getApplicationContext().getPackageManager().getPackageInfo(context.getApplicationContext().getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String getKernelVersion() {
        Process process;
        try {
            process = Runtime.getRuntime().exec("cat/proc/version");
        } catch (IOException e) {
            e.printStackTrace();
            process = null;
        }
        if (process != null) {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()), 8192);
            String str = "";
            while (true) {
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        str = str + readLine;
                    }
                } catch (IOException e2) {
                    e2.printStackTrace();
                }
                try {
                    break;
                } catch (IndexOutOfBoundsException e3) {
                    e3.printStackTrace();
                    return "linux 3.0";
                }
            }
            if (TextUtils.isEmpty(str)) {
                return "linux 3.0";
            }
            String substring = str.substring(str.indexOf("version ") + 8);
            return substring.substring(0, substring.indexOf(StrUtil.SPACE));
        }
        return "linux 3.0";
    }

    public static String getDevicesID(Context context) {
        String deviceId;
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        if (telephonyManager != null) {
            try {
                deviceId = telephonyManager.getDeviceId();
            } catch (Exception unused) {
            }
            if (TextUtils.isEmpty(deviceId)) {
                return deviceId;
            }
            String serialNumber = getSerialNumber();
            if (TextUtils.isEmpty(serialNumber)) {
                String androidID = getAndroidID(context);
                return !TextUtils.isEmpty(androidID) ? androidID : "";
            }
            return serialNumber;
        }
        deviceId = "";
        if (TextUtils.isEmpty(deviceId)) {
        }
    }

    public static String getUniqueID() {
        String str = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.CPU_ABI.length() % 10) + (Build.DEVICE.length() % 10) + (Build.DISPLAY.length() % 10) + (Build.HOST.length() % 10) + (Build.ID.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10) + (Build.TAGS.length() % 10) + (Build.TYPE.length() % 10) + (Build.USER.length() % 10);
        try {
            return new UUID(str.hashCode(), Build.class.getField("SERIAL").get(null).toString().hashCode()).toString();
        } catch (Exception unused) {
            return new UUID(str.hashCode(), "serial".hashCode()).toString();
        }
    }

    private static String getSerialNumber() {
        try {
            Class<?> cls = Class.forName("android.os.SystemProperties");
            return (String) cls.getMethod("get", String.class, String.class).invoke(cls, "ro.serialno", "");
        } catch (Exception unused) {
            return "";
        }
    }

    private static String getAndroidID(Context context) {
        return Settings.Secure.getString(context.getContentResolver(), "android_id");
    }

    public static boolean isDeviceRooted() {
        ShellTool.CommandResult execCmd = ShellTool.execCmd("echo root", true);
        if (execCmd.result == 0) {
            return true;
        }
        if (execCmd.errorMsg != null) {
            Log.d("isAppRoot", execCmd.errorMsg);
            return false;
        }
        return false;
    }

    public static String getSystemVersion() {
        return Build.VERSION.RELEASE;
    }

    public static String getPlatform(Context context) {
        return isPad(context) ? "tablet" : "phone";
    }

    public static boolean isPad(Context context) {
        return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
    }

    public static String getISOTimeFormat() {
        TimeZone timeZone = SimpleDateFormat.getInstance().getTimeZone();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DatePattern.UTC_MS_WITH_ZONE_OFFSET_PATTERN, Locale.getDefault());
        simpleDateFormat.setTimeZone(timeZone);
        return simpleDateFormat.format(new Date());
    }

    public static boolean isSupportFingerprintRecognize(Context context) {
        return Build.VERSION.SDK_INT >= 23 && FingerprintManagerCompat.from(context).isHardwareDetected();
    }

    public static boolean hasFingerprint(Context context) {
        KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService("keyguard");
        return keyguardManager != null && keyguardManager.isKeyguardSecure() && FingerprintManagerCompat.from(context).hasEnrolledFingerprints();
    }

    public static String getIPAddress(Context context) {
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
        if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
            return "";
        }
        if (activeNetworkInfo.getType() != 0) {
            return activeNetworkInfo.getType() == 1 ? intIP2StringIP(((WifiManager) context.getApplicationContext().getSystemService("wifi")).getConnectionInfo().getIpAddress()) : "";
        }
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
                while (inetAddresses.hasMoreElements()) {
                    InetAddress nextElement = inetAddresses.nextElement();
                    if (!nextElement.isLoopbackAddress() && (nextElement instanceof Inet4Address)) {
                        return nextElement.getHostAddress();
                    }
                }
            }
            return "";
        } catch (SocketException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static void getPublicIPAddress() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://ip.3322.net/").openConnection();
                    httpURLConnection.setConnectTimeout(StartVpnHelper.VpnFragment.RETRYSTARTVPNDELAY);
                    httpURLConnection.setReadTimeout(StartVpnHelper.VpnFragment.RETRYSTARTVPNDELAY);
                    httpURLConnection.setRequestMethod(ServletUtil.METHOD_GET);
                    BufferedInputStream bufferedInputStream = new BufferedInputStream(httpURLConnection.getInputStream());
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
                    SharePrefrenceManager.get().putValue(Keys.PUBLIC_IP, bufferedReader.readLine());
                    bufferedReader.close();
                    bufferedInputStream.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    private static String intIP2StringIP(int i) {
        return (i & 255) + "." + ((i >> 8) & 255) + "." + ((i >> 16) & 255) + "." + ((i >> 24) & 255);
    }

    public static String getDeviceName(Context context) {
        String string;
        try {
            String lowerCase = Build.MANUFACTURER.toLowerCase();
            if (!lowerCase.contains("smartisan") && !lowerCase.contains("samsung")) {
                string = Settings.Secure.getString(context.getContentResolver(), "bluetooth_name");
                return string;
            }
            string = Settings.Global.getString(context.getContentResolver(), "device_name");
            return string;
        } catch (Exception e) {
            e.printStackTrace();
            return "未知";
        }
    }

    public static String getAppName(Context context) {
        int myPid = Process.myPid();
        Iterator<ActivityManager.RunningAppProcessInfo> it = ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses().iterator();
        while (it.hasNext()) {
            ActivityManager.RunningAppProcessInfo next = it.next();
            try {
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (next.pid == myPid) {
                return next.processName;
            }
            continue;
        }
        return null;
    }

    public static String generaSysInfo(Context context) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("hostname", getDevicesName());
            if (HarMonyUtil.isHarmonyOs()) {
                jSONObject.put("osname", "HarmonyOS " + HarMonyUtil.getHarmonyVersion());
            } else {
                jSONObject.put("osname", "Android " + getSystemVersion());
            }
            jSONObject.put("osversion", System.getProperty("os.version"));
            jSONObject.put("osvendor", "Android Corporation");
            jSONObject.put("hwvendor", Build.MANUFACTURER);
            jSONObject.put("hwserial", getAndroidID(context));
            jSONObject.put("hwtype", "MOBILE");
            jSONObject.put("ostype", "Android");
            jSONObject.put(Keys.PUBLIC_IP, SharePrefrenceManager.get().getString(Keys.PUBLIC_IP, ""));
            jSONObject.put("macaddress", getMacAddress(context));
            jSONObject.put("deviceid", md5(getDevicesID(context)) + md5(getDevicesID(context)));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jSONObject.toString();
    }

    public static String md5(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        try {
            String str2 = "";
            for (byte b : MessageDigest.getInstance("MD5").digest(str.getBytes())) {
                String hexString = Integer.toHexString(b & UByte.MAX_VALUE);
                if (hexString.length() == 1) {
                    hexString = "0" + hexString;
                }
                str2 = str2 + hexString;
            }
            return str2;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return "";
        }
    }
}