导航菜单

页面标题

页面副标题

万能钥匙 v1.1.23 - NetworkModule.java 源代码

正在查看: 万能钥匙 v1.1.23 应用的 NetworkModule.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.finogeeks.lib.applet.api.network;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import com.finogeeks.lib.applet.api.BaseApi;
import com.finogeeks.lib.applet.api.CallbackHandlerKt;
import com.finogeeks.lib.applet.config.AppConfig;
import com.finogeeks.lib.applet.interfaces.ICallback;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.k0;
import kotlin.jvm.internal.n;
import lg0.t;
import org.json.JSONObject;

@Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\b\n\u0002\b\u0005\u0018\u00002\u00020\u0001:\u0001\u0019B\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0015\u0010\b\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006H\u0016¢\u0006\u0004\b\b\u0010\tJ(\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\n\u001a\u00020\u00072\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\rH\u0096\u0002¢\u0006\u0004\b\u0010\u0010\u0011J\u001f\u0010\u0012\u001a\u00020\u000f2\u0006\u0010\n\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\rH\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u001f\u0010\u0014\u001a\u00020\u000f2\u0006\u0010\n\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\rH\u0002¢\u0006\u0004\b\u0014\u0010\u0013J\u0017\u0010\u0017\u001a\u00020\u00072\u0006\u0010\u0016\u001a\u00020\u0015H\u0002¢\u0006\u0004\b\u0017\u0010\u0018¨\u0006\u001a"}, d2 = {"Lcom/finogeeks/lib/applet/api/network/NetworkModule;", "Lcom/finogeeks/lib/applet/api/BaseApi;", "Landroid/content/Context;", "context", "<init>", "(Landroid/content/Context;)V", "", "", "apis", "()[Ljava/lang/String;", FinFileResourceUtil.KEY_EVENT, "Lorg/json/JSONObject;", "param", "Lcom/finogeeks/lib/applet/interfaces/ICallback;", "callback", "Llg0/e0;", "invoke", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "getLocalIPAddress", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "getLocalIPAddressV2", "", "prefixLength", "prefixLengthToSubnetMask", "(I)Ljava/lang/String;", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class NetworkModule extends BaseApi {

    public static final class a {
        private a() {
        }

        public a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }
    }

    static {
        new a(null);
    }

    public NetworkModule(Context context) {
        super(context);
        n.j(context, "context");
    }

    private final String a(int i) {
        int i2 = (-1) << (32 - i);
        int[] iArr = new int[4];
        for (int i3 = 0; i3 <= 3; i3++) {
            iArr[i3] = i2 & 255;
            i2 >>= 8;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(iArr[3]);
        sb.append('.');
        sb.append(iArr[2]);
        sb.append('.');
        sb.append(iArr[1]);
        sb.append('.');
        sb.append(iArr[0]);
        return sb.toString();
    }

    private final void a(String str, ICallback iCallback) {
        String str2;
        Object systemService;
        List<LinkAddress> linkAddresses;
        String str3 = "255.255.255.255";
        System.currentTimeMillis();
        try {
            Context context = getContext();
            n.e(context, "context");
            systemService = context.getApplicationContext().getSystemService(AppConfig.PRELOAD_RULE_NETWORK_WIFI);
        } catch (Exception e) {
            FLog.e("NetworkModule", "get local ip address failure", e);
            str2 = "0.0.0.0";
        }
        if (systemService == null) {
            throw new t("null cannot be cast to non-null type android.net.wifi.WifiManager");
        }
        WifiManager wifiManager = (WifiManager) systemService;
        WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        n.e(connectionInfo, "wifiInfo");
        int ipAddress = connectionInfo.getIpAddress();
        k0 k0Var = k0.a;
        str2 = String.format("%d.%d.%d.%d", Arrays.copyOf(new Object[]{Integer.valueOf(ipAddress & 255), Integer.valueOf((ipAddress >> 8) & 255), Integer.valueOf((ipAddress >> 16) & 255), Integer.valueOf((ipAddress >> 24) & 255)}, 4));
        n.e(str2, "java.lang.String.format(format, *args)");
        if (Build.VERSION.SDK_INT < 31) {
            int i = wifiManager.getDhcpInfo().netmask;
            String format = String.format("%d.%d.%d.%d", Arrays.copyOf(new Object[]{Integer.valueOf(i & 255), Integer.valueOf((i >> 8) & 255), Integer.valueOf((i >> 16) & 255), Integer.valueOf((i >> 24) & 255)}, 4));
            n.e(format, "java.lang.String.format(format, *args)");
            str3 = format;
        } else {
            Object systemService2 = getContext().getSystemService("connectivity");
            if (systemService2 == null) {
                throw new t("null cannot be cast to non-null type android.net.ConnectivityManager");
            }
            ConnectivityManager connectivityManager = (ConnectivityManager) systemService2;
            LinkProperties linkProperties = connectivityManager.getLinkProperties(connectivityManager.getActiveNetwork());
            if (linkProperties != null && (linkAddresses = linkProperties.getLinkAddresses()) != null) {
                String str4 = "255.255.255.255";
                for (LinkAddress linkAddress : linkAddresses) {
                    n.e(linkAddress, "linkAddress");
                    InetAddress address = linkAddress.getAddress();
                    n.e(address, "linkAddress.address");
                    if (n.d(address.getHostAddress(), str2)) {
                        str4 = a(linkAddress.getPrefixLength());
                    }
                }
                str3 = str4;
            }
        }
        System.currentTimeMillis();
        JSONObject apiOk = CallbackHandlerKt.apiOk(str);
        apiOk.put("localip", str2);
        apiOk.put("netmask", str3);
        iCallback.onSuccess(apiOk);
    }

    @Override
    public String[] apis() {
        return new String[]{"getLocalIPAddress"};
    }

    @Override
    public void invoke(String event, JSONObject param, ICallback callback) {
        n.j(event, FinFileResourceUtil.KEY_EVENT);
        n.j(param, "param");
        n.j(callback, "callback");
        if (event.hashCode() == -218040648 && event.equals("getLocalIPAddress")) {
            a(event, callback);
        }
    }
}