正在查看: Dostt v1.0.89 应用的 RNNetworkInfo.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Dostt v1.0.89 应用的 RNNetworkInfo.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.pusherman.networkinfo;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
public class RNNetworkInfo extends ReactContextBaseJavaModule {
public static List<String> DSLITE_LIST = Arrays.asList("192.0.0.0", "192.0.0.1", "192.0.0.2", "192.0.0.3", "192.0.0.4", "192.0.0.5", "192.0.0.6", "192.0.0.7");
public static final String TAG = "RNNetworkInfo";
WifiManager wifi;
class a implements Runnable {
final Promise a;
a(Promise promise) {
this.a = promise;
}
@Override
public void run() {
String str;
try {
WifiInfo connectionInfo = RNNetworkInfo.this.wifi.getConnectionInfo();
if (connectionInfo.getSupplicantState() == SupplicantState.COMPLETED) {
str = connectionInfo.getSSID();
if (str.startsWith("\"") && str.endsWith("\"")) {
str = str.substring(1, str.length() - 1);
}
} else {
str = null;
}
this.a.resolve(str);
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class b implements Runnable {
final Promise a;
b(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
this.a.resolve(RNNetworkInfo.this.wifi.getConnectionInfo().getSupplicantState() == SupplicantState.COMPLETED ? RNNetworkInfo.this.wifi.getConnectionInfo().getBSSID() : null);
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class c implements Runnable {
final Promise a;
c(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
String str = null;
for (InterfaceAddress interfaceAddress : RNNetworkInfo.this.getInetAddresses()) {
if (!interfaceAddress.getAddress().isLoopbackAddress()) {
str = interfaceAddress.getBroadcast().toString();
}
}
this.a.resolve(str);
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class d implements Runnable {
final Promise a;
d(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
String str = null;
for (InterfaceAddress interfaceAddress : RNNetworkInfo.this.getInetAddresses()) {
if (!interfaceAddress.getAddress().isLoopbackAddress()) {
String str2 = interfaceAddress.getAddress().getHostAddress().toString();
if (!RNNetworkInfo.this.inDSLITERange(str2).booleanValue()) {
str = str2;
}
}
}
this.a.resolve(str);
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class e implements Runnable {
final Promise a;
e(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
String str = null;
for (InterfaceAddress interfaceAddress : RNNetworkInfo.this.getInetAddresses()) {
if (!interfaceAddress.getAddress().isLoopbackAddress() && (interfaceAddress.getAddress() instanceof Inet4Address)) {
String str2 = interfaceAddress.getAddress().getHostAddress().toString();
if (!RNNetworkInfo.this.inDSLITERange(str2).booleanValue()) {
str = str2;
}
}
}
this.a.resolve(str);
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class f implements Runnable {
final Promise a;
f(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
int ipAddress = RNNetworkInfo.this.wifi.getConnectionInfo().getIpAddress();
this.a.resolve(String.format("%d.%d.%d.%d", Integer.valueOf(ipAddress & 255), Integer.valueOf((ipAddress >> 8) & 255), Integer.valueOf((ipAddress >> 16) & 255), Integer.valueOf((ipAddress >> 24) & 255)));
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class g implements Runnable {
final Promise a;
g(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface nextElement = networkInterfaces.nextElement();
if (!nextElement.isLoopback() && nextElement.isUp()) {
Enumeration<InetAddress> inetAddresses = nextElement.getInetAddresses();
for (InterfaceAddress interfaceAddress : nextElement.getInterfaceAddresses()) {
if (!(inetAddresses.nextElement() instanceof Inet6Address)) {
this.a.resolve(RNNetworkInfo.this.intToIP(interfaceAddress.getNetworkPrefixLength()));
return;
}
}
}
}
} catch (Exception unused) {
this.a.resolve("0.0.0.0");
}
}
}
class h implements Runnable {
final Promise a;
h(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
int i = RNNetworkInfo.this.wifi.getDhcpInfo().gateway;
this.a.resolve(String.format("%d.%d.%d.%d", Integer.valueOf(i & 255), Integer.valueOf((i >> 8) & 255), Integer.valueOf((i >> 16) & 255), Integer.valueOf((i >> 24) & 255)));
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
class i implements Runnable {
final Promise a;
i(Promise promise) {
this.a = promise;
}
@Override
public void run() {
try {
this.a.resolve(Float.valueOf(RNNetworkInfo.this.wifi.getConnectionInfo().getFrequency()));
} catch (Exception unused) {
this.a.resolve((Object) null);
}
}
}
public RNNetworkInfo(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
this.wifi = (WifiManager) reactApplicationContext.getApplicationContext().getSystemService("wifi");
}
public List<InterfaceAddress> getInetAddresses() {
ArrayList arrayList = new ArrayList();
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
Iterator<InterfaceAddress> it = networkInterfaces.nextElement().getInterfaceAddresses().iterator();
while (it.hasNext()) {
arrayList.add(it.next());
}
}
} catch (Exception e2) {
Log.e(TAG, e2.toString());
}
return arrayList;
}
public Boolean inDSLITERange(String str) {
return Boolean.valueOf(DSLITE_LIST.contains(str));
}
public String intToIP(int i2) {
String[] strArr = new String[4];
strArr[0] = "";
strArr[1] = "";
strArr[2] = "";
strArr[3] = "";
int i3 = 1;
for (int i4 = 0; i4 < 4; i4++) {
for (int i5 = 0; i5 < 8; i5++) {
if (i3 <= i2) {
strArr[i4] = strArr[i4] + "1";
} else {
strArr[i4] = strArr[i4] + "0";
}
i3++;
}
}
return Integer.parseInt(strArr[0], 2) + "." + Integer.parseInt(strArr[1], 2) + "." + Integer.parseInt(strArr[2], 2) + "." + Integer.parseInt(strArr[3], 2);
}
@ReactMethod
public void getBSSID(Promise promise) throws Exception {
new Thread(new b(promise)).start();
}
@ReactMethod
public void getBroadcast(Promise promise) throws Exception {
new Thread(new c(promise)).start();
}
@ReactMethod
public void getFrequency(Promise promise) throws Exception {
new Thread(new i(promise)).start();
}
@ReactMethod
public void getGatewayIPAddress(Promise promise) throws Exception {
new Thread(new h(promise)).start();
}
@ReactMethod
public void getIPAddress(Promise promise) throws Exception {
new Thread(new d(promise)).start();
}
@ReactMethod
public void getIPV4Address(Promise promise) throws Exception {
new Thread(new e(promise)).start();
}
public String getName() {
return TAG;
}
@ReactMethod
public void getSSID(Promise promise) throws Exception {
new Thread(new a(promise)).start();
}
@ReactMethod
public void getSubnet(Promise promise) throws Exception {
new Thread(new g(promise)).start();
}
@ReactMethod
public void getWIFIIPV4Address(Promise promise) throws Exception {
new Thread(new f(promise)).start();
}
}