Revert "增加最右推广接口调用"

This reverts commit e6854121
This commit is contained in:
huangjian
2020-12-17 18:53:44 +08:00
parent 69da0e46bb
commit 634bffccce
5 changed files with 15 additions and 75 deletions

View File

@@ -39,30 +39,6 @@ public class NetworkUtils {
return sWifiLocker;
}
public String getLocalHostIp() {
String ipaddress = "";
try {
Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces();
// 遍历所用的网络接口
while (en.hasMoreElements()) {
NetworkInterface nif = en.nextElement();// 得到每一个网络接口绑定的所有ip
Enumeration<InetAddress> inet = nif.getInetAddresses();
// 遍历每一个接口绑定的所有ip
while (inet.hasMoreElements()) {
InetAddress ip = inet.nextElement();
if (!ip.isLoopbackAddress()) {
return ip.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return ipaddress;
}
public static void lockWifi(Context c) {
Log.d(TAG, "lock wifi");
if (!wifiLocker(c).isHeld())
@@ -76,7 +52,7 @@ public class NetworkUtils {
}
public static boolean isWifiActive(Context c) {
if (c == null) {
if(c == null){
Log.e("xuwakao", "isWifiActive is NULL");
return false;
}
@@ -87,7 +63,7 @@ public class NetworkUtils {
}
public static boolean isMobileActive(Context c) {
if (c == null) {
if(c == null){
Log.e("xuwakao", "isWifiActive is NULL");
return false;
}
@@ -98,7 +74,7 @@ public class NetworkUtils {
}
public static boolean isNetworkStrictlyAvailable(Context c) {
if (c == null) {
if(c == null){
Log.e("xuwakao", "isNetworkStrictlyAvailable context is NULL");
return false;
}
@@ -333,7 +309,7 @@ public class NetworkUtils {
return "Unknown";
}
public static final int NET_INVALID = 0; // 无网络
public static final int NET_INVALID = 0 ; // 无网络
public static final int NET_WIFI = 1;
public static final int NET_2G = 2;
public static final int NET_3G = 3;
@@ -447,16 +423,17 @@ public class NetworkUtils {
public static String getOperator(Context c) {
String sim = getSimOperator(c);
if (FP.empty(sim))
if(FP.empty(sim))
return ChinaOperator.UNKNOWN;
if (sim.startsWith("46003") || sim.startsWith("46005")) {
return ChinaOperator.CTL;
} else if (sim.startsWith("46001") || sim.startsWith("46006")) {
return ChinaOperator.UNICOM;
} else if (sim.startsWith("46000") || sim.startsWith("46002")
|| sim.startsWith("46007") || sim.startsWith("46020")) {
|| sim.startsWith("46007") || sim.startsWith("46020")){
return ChinaOperator.CMCC;
} else {
}
else {
return ChinaOperator.UNKNOWN;
}
}
@@ -470,16 +447,17 @@ public class NetworkUtils {
public static String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e("NetworkUtils getLocalIpAddress:", ex.toString());
}
return null;
}