QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 Apn.java 源代码,内容仅作参考
package com.tencent.common.http;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Handler;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.tencent.basesupport.FLogger;
import com.tencent.common.connectivity.ConnectivityAdapterHolder;
import com.tencent.common.http.ConnectionChangeHandler;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.compliance.MethodDelegate;
import java.lang.reflect.Method;
public class Apn {
public static final String APN_3GNET = "3gnet";
public static final String APN_3GWAP = "3gwap";
public static final String APN_777 = "#777";
public static final String APN_CMLTE = "cmnet";
public static final String APN_CMNET = "cmnet";
public static final String APN_CMWAP = "cmwap";
public static final String APN_CTLTE = "ctlte";
public static final String APN_CTNET = "ctnet";
public static final String APN_CTWAP = "ctwap";
public static final String APN_NET = "Net";
public static final String APN_UNINET = "uninet";
public static final String APN_UNIWAP = "uniwap";
public static final String APN_UNKNOWN = "N/A";
public static final String APN_WAP = "Wap";
public static final String APN_WIFI = "Wlan";
public static final String APN_WONET = "wonet";
public static final int NETWORK_TYPE_1xRTT = 7;
public static final int NETWORK_TYPE_CDMA = 4;
public static final int NETWORK_TYPE_EDGE = 2;
public static final int NETWORK_TYPE_EHRPD = 14;
public static final int NETWORK_TYPE_EVDO_0 = 5;
public static final int NETWORK_TYPE_EVDO_A = 6;
public static final int NETWORK_TYPE_EVDO_B = 12;
public static final int NETWORK_TYPE_GPRS = 1;
public static final int NETWORK_TYPE_HSDPA = 8;
public static final int NETWORK_TYPE_HSPA = 10;
public static final int NETWORK_TYPE_HSPAP = 15;
public static final int NETWORK_TYPE_HSUPA = 9;
public static final int NETWORK_TYPE_IDEN = 11;
public static final int NETWORK_TYPE_LTE = 13;
public static final int NETWORK_TYPE_NR = 20;
public static final int NETWORK_TYPE_UMTS = 3;
public static final int NETWORK_TYPE_UNKNOWN = 0;
public static final byte PROXY_TYPE_CM = 0;
public static final byte PROXY_TYPE_CT = 1;
public static final String TAG = "Apn";
public static final int TYPE_NET = 1;
public static final int TYPE_UNKNOWN = 0;
public static final int TYPE_WAP = 2;
public static final int TYPE_WIFI = 4;
public static final int T_APN_3GNET = 512;
public static final int T_APN_3GWAP = 16;
public static final int T_APN_CMLTE = 8192;
public static final int T_APN_CMNET = 1024;
public static final int T_APN_CMWAP = 8;
public static final int T_APN_CTLTE = 2048;
public static final int T_APN_CTNET = 128;
public static final int T_APN_CTWAP = 64;
public static final int T_APN_UNINET = 256;
public static final int T_APN_UNIWAP = 32;
public static final int T_APN_WONET = 4096;
static String f9576a = "Wlan";
private static String f9579d = "N/A";
private static Handler l = null;
private static ConnectionChangeHandler m = null;
public static int sApnType = 4;
public static int sApnTypeS = 4;
public static String sCurrentDnsServer = "get_dns_failed";
private static ApnProxyInfo e = new ApnProxyInfo();
private static ApnInfo f = new ApnInfo();
private static Context g = null;
private static volatile ConnectivityManager h = null;
private static Object i = new Object();
private static volatile boolean j = false;
static NetworkInfo f9577b = null;
static Runnable f9578c = null;
private static boolean k = false;
public static class ApnInfo {
public static final int MOBILE_NETWORK_TYPE_2G = 1;
public static final int MOBILE_NETWORK_TYPE_3G = 2;
public static final int MOBILE_NETWORK_TYPE_4G = 3;
public static final int MOBILE_NETWORK_TYPE_UNKNOW = -1;
private int f9581a = -1;
private int f9582b = -1;
private int f9583c = 4;
private int f9584d = 4;
private ApnProxyInfo e = null;
private String f = "get_dns_failed";
private boolean g = false;
private boolean h = false;
private boolean i = false;
private int j = -1;
public int getApnType() {
return this.f9583c;
}
public int getApnTypeS() {
return this.f9584d;
}
public String getCurrentDnsServer() {
return this.f;
}
public int getMobileNetworkType() {
return this.j;
}
public int getNetworkType() {
return this.f9581a;
}
public ApnProxyInfo getProxyInfo() {
return this.e;
}
public int getSubNetworkType() {
return this.f9582b;
}
public boolean isMobileNetwork() {
return this.h;
}
public boolean isWapPoint() {
return this.i;
}
public boolean isWifiNetwork() {
return this.g;
}
public void reset() {
this.f9581a = -1;
this.f9582b = -1;
this.f9583c = 4;
this.f9584d = 4;
this.e = null;
this.f = "get_dns_failed";
this.g = false;
this.h = false;
this.j = -1;
}
}
public static class ApnProxyInfo {
public String apnProxy = null;
public int apnPort = 80;
public byte apnProxyType = 0;
public boolean apnUseProxy = false;
}
private static void a(int i2, int i3) {
f.reset();
f.f9581a = i2;
f.f9582b = i3;
f.f9583c = sApnType;
f.f9584d = sApnTypeS;
f.e = e;
f.f = sCurrentDnsServer;
f.g = i2 == 1;
f.h = i2 == 0;
if (f.h) {
if (i3 == 1 || i3 == 2 || i3 == 4 || i3 == 7 || i3 == 11) {
f.j = 1;
}
if (i3 != 1 && i3 != 2 && i3 != 4 && i3 != 7 && i3 != 11 && i3 != 13) {
f.j = 2;
}
if (i3 == 13) {
f.j = 3;
}
ApnInfo apnInfo = f;
apnInfo.i = apnInfo.f9583c == 2;
}
}
private static synchronized void a(NetworkInfo networkInfo, boolean z) {
int i2;
int type;
String extraInfo;
synchronized (Apn.class) {
j = true;
g();
sApnType = 0;
sApnTypeS = 0;
f9579d = APN_UNKNOWN;
int i3 = -1;
if (networkInfo != null) {
try {
type = networkInfo.getType();
} catch (Exception unused) {
}
try {
int subtype = networkInfo.getSubtype();
try {
extraInfo = networkInfo.getExtraInfo();
if (extraInfo == null) {
sApnType = 0;
sApnTypeS = 0;
} else {
extraInfo = extraInfo.trim().toLowerCase();
}
i3 = type;
i2 = subtype;
} catch (Exception unused2) {
i3 = type;
i2 = subtype;
}
} catch (Exception unused3) {
i3 = type;
i2 = -1;
a(i3, i2);
j = false;
}
} else {
extraInfo = null;
i2 = -1;
}
try {
if (i3 == 1) {
sApnType = 4;
sApnTypeS = 4;
e.apnUseProxy = false;
if (!z) {
h();
}
} else {
if (extraInfo == null) {
sApnType = 0;
} else {
if (extraInfo.contains(APN_CTNET) && i2 == 6) {
sApnType = 1;
sApnTypeS = 128;
} else if ((extraInfo.contains(APN_CTNET) || extraInfo.contains(APN_CTLTE)) && i2 >= 13) {
sApnType = 1;
sApnTypeS = 2048;
} else if ((extraInfo.contains("cmnet") || extraInfo.contains(APN_CMWAP)) && i2 == 13) {
sApnType = 1;
sApnTypeS = 8192;
} else if ((extraInfo.contains(APN_WONET) || extraInfo.contains(APN_3GNET)) && i2 >= 13) {
sApnType = 1;
sApnTypeS = 4096;
} else if (extraInfo.contains(APN_CMWAP)) {
sApnType = 2;
sApnTypeS = 8;
} else if (extraInfo.contains(APN_UNIWAP)) {
sApnType = 2;
sApnTypeS = 32;
} else if (extraInfo.contains(APN_3GWAP)) {
sApnType = 2;
sApnTypeS = 16;
} else if (extraInfo.contains(APN_CTWAP)) {
sApnType = 2;
sApnTypeS = 64;
} else if (extraInfo.contains("cmnet")) {
sApnType = 1;
sApnTypeS = 1024;
} else if (extraInfo.contains(APN_UNINET)) {
sApnType = 1;
sApnTypeS = 256;
} else if (extraInfo.contains(APN_3GNET)) {
sApnType = 1;
sApnTypeS = 512;
} else if (extraInfo.contains(APN_777)) {
sApnType = 0;
} else {
sApnType = 0;
}
e.apnUseProxy = false;
e.apnProxy = Proxy.getDefaultHost();
e.apnPort = Proxy.getDefaultPort();
if (e.apnProxy != null) {
e.apnProxy = e.apnProxy.trim();
}
if (TextUtils.isEmpty(e.apnProxy)) {
e.apnUseProxy = true;
sApnType = 2;
if ("10.0.0.200".equals(e.apnProxy)) {
e.apnProxyType = (byte) 1;
sApnTypeS = 64;
} else {
e.apnProxyType = (byte) 0;
}
} else {
e.apnUseProxy = false;
sApnType = 1;
if (extraInfo != null && extraInfo.contains(APN_777)) {
sApnTypeS = 128;
}
}
if (sApnTypeS != 0 || sApnType == 0) {
switch (i2) {
case 13:
sApnType = 1;
sApnTypeS = 8192;
break;
case 14:
sApnType = 1;
sApnTypeS = 2048;
break;
case 15:
sApnType = 1;
sApnTypeS = 4096;
break;
default:
if (networkInfo != null) {
f9579d += "_" + networkInfo.getExtraInfo();
break;
}
break;
}
}
if (!z) {
TelephonyManager telephonyManager = (TelephonyManager) ContextHolder.getAppContext().getSystemService("phone");
k = telephonyManager == null ? false : telephonyManager.isNetworkRoaming();
}
}
sApnTypeS = 0;
e.apnUseProxy = false;
e.apnProxy = Proxy.getDefaultHost();
e.apnPort = Proxy.getDefaultPort();
if (e.apnProxy != null) {
}
if (TextUtils.isEmpty(e.apnProxy)) {
}
if (sApnTypeS != 0) {
}
switch (i2) {
}
if (!z) {
}
}
} catch (Exception unused4) {
}
a(i3, i2);
j = false;
}
}
public static int adjustNetworkType(int i2) {
if (i2 != 13) {
return i2;
}
Context appContext = ContextHolder.getAppContext();
if (Build.VERSION.SDK_INT < 29 || appContext.checkSelfPermission("android.permission.READ_PHONE_STATE") != 0) {
return i2;
}
try {
ServiceState serviceState = MethodDelegate.getServiceState((TelephonyManager) appContext.getSystemService("phone"));
if (serviceState == null) {
return i2;
}
if (isServiceStateFiveGAvailable(serviceState.toString())) {
return 20;
}
return i2;
} catch (Throwable unused) {
return i2;
}
}
static Context c() {
return d();
}
private static Context d() {
Context context = g;
if (context != null) {
return context;
}
g = ContextHolder.getAppContext();
return g;
}
public static void e() {
ConnectivityManager connectivityManager = getConnectivityManager();
NetworkInfo networkInfo = null;
if (connectivityManager != null) {
try {
networkInfo = connectivityManager.getActiveNetworkInfo();
} catch (Exception unused) {
}
}
a(networkInfo, false);
f9577b = networkInfo;
WifiManager wifiManager = (WifiManager) g.getSystemService("wifi");
if (wifiManager != null) {
try {
WifiInfo connectionInfo = MethodDelegate.getConnectionInfo(wifiManager);
if (connectionInfo != null) {
synchronized ("APN_WIFI_NAME_WITH_SSID_LOCK") {
f9576a = APN_WIFI + connectionInfo.getBSSID();
FLogger.d("ip-list", "Apn--wifiInfo.getBSSID():" + connectionInfo.getBSSID());
}
}
} catch (Throwable unused2) {
}
}
}
private static void f() {
a(getActiveNetworkInfo(false), false);
}
private static void g() {
try {
Method declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class);
declaredMethod.setAccessible(true);
sCurrentDnsServer = (String) declaredMethod.invoke(null, "net.dns1");
} catch (Exception unused) {
sCurrentDnsServer = "get_dns_failed";
}
}
public static NetworkInfo getActiveNetworkInfo(boolean z) {
NetworkInfo networkInfo;
if (z) {
networkInfo = f9577b;
if (networkInfo != null) {
return networkInfo;
}
} else {
networkInfo = null;
}
ConnectivityManager connectivityManager = getConnectivityManager();
if (connectivityManager != null) {
try {
networkInfo = connectivityManager.getActiveNetworkInfo();
} catch (Exception unused) {
return null;
}
}
f9577b = networkInfo;
return networkInfo;
}
public static ApnInfo getApnInfo() {
return getApnInfo(false);
}
public static ApnInfo getApnInfo(boolean z) {
a(getActiveNetworkInfo(z), z);
return f;
}
public static String getApnName(int i2) {
switch (i2) {
case 4:
return APN_WIFI;
case 8:
return APN_CMWAP;
case 16:
return APN_3GWAP;
case 32:
return APN_UNIWAP;
case 64:
return APN_CTWAP;
case 128:
return APN_CTNET;
case 256:
return APN_UNINET;
case 512:
return APN_3GNET;
case 1024:
return "cmnet";
case 2048:
return APN_CTLTE;
case 4096:
return APN_WONET;
case 8192:
return "cmnet";
default:
return f9579d;
}
}
public static String getApnNameWithBSSID(int i2) {
String str;
if (i2 != 4) {
return getApnName(i2);
}
synchronized ("APN_WIFI_NAME_WITH_SSID_LOCK") {
str = f9576a;
}
return str;
}
public static synchronized ApnProxyInfo getApnProxyInfo() {
ApnProxyInfo apnProxyInfo;
synchronized (Apn.class) {
f();
apnProxyInfo = e;
}
return apnProxyInfo;
}
public static synchronized int getApnType() {
int i2;
synchronized (Apn.class) {
f();
i2 = sApnType;
}
return i2;
}
public static synchronized int getApnTypeS() {
int i2;
synchronized (Apn.class) {
f();
i2 = sApnTypeS;
}
return i2;
}
public static ConnectivityManager getConnectivityManager() {
if (h != null) {
return h;
}
synchronized (i) {
if (h == null) {
try {
h = (ConnectivityManager) d().getSystemService("connectivity");
} catch (Exception unused) {
return null;
}
}
}
return h;
}
public static int getType(String str) {
if (TextUtils.isEmpty(str)) {
return 0;
}
try {
String lowerCase = str.trim().toLowerCase();
if (lowerCase.indexOf("wifi") == -1 && lowerCase.indexOf("wlan") == -1) {
if (lowerCase.indexOf("net") != -1) {
return 1;
}
return lowerCase.indexOf("wap") != -1 ? 2 : 0;
}
return 4;
} catch (Exception unused) {
return 0;
}
}
private static void h() {
if (l == null) {
l = new Handler(ConnectivityAdapterHolder.a());
}
l.post(new Runnable() {
@Override
public void run() {
try {
WifiInfo connectionInfo = MethodDelegate.getConnectionInfo((WifiManager) Apn.c().getSystemService("wifi"));
if (connectionInfo != null) {
synchronized ("APN_WIFI_NAME_WITH_SSID_LOCK") {
Apn.f9576a = Apn.APN_WIFI + connectionInfo.getBSSID();
FLogger.d("ip-list", "Apn--wifiInfo.getBSSID():" + connectionInfo.getBSSID());
}
}
} catch (Throwable unused) {
}
}
});
}
public static boolean is2GMode() {
return is2GMode(false);
}
public static boolean is2GMode(boolean z) {
int type;
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(z);
if (activeNetworkInfo == null || (type = activeNetworkInfo.getType()) == 1 || type != 0) {
return false;
}
int subtype = activeNetworkInfo.getSubtype();
return subtype == 1 || subtype == 2 || subtype == 4 || subtype == 7 || subtype == 11;
}
public static boolean is3GMode() {
return is3GMode(false);
}
public static boolean is3GMode(boolean z) {
int type;
int subtype;
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(z);
return (activeNetworkInfo == null || (type = activeNetworkInfo.getType()) == 1 || type != 0 || (subtype = activeNetworkInfo.getSubtype()) == 1 || subtype == 2 || subtype == 4 || subtype == 7 || subtype == 11 || subtype == 13) ? false : true;
}
@Deprecated
public static boolean is3GOr2GMode() {
return is3GOr2GMode(false);
}
@Deprecated
public static boolean is3GOr2GMode(boolean z) {
return isMobileNetwork(z);
}
public static boolean is4GMode() {
return is4GMode(false);
}
public static boolean is4GMode(boolean z) {
int type;
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(z);
return activeNetworkInfo != null && (type = activeNetworkInfo.getType()) != 1 && type == 0 && activeNetworkInfo.getSubtype() == 13;
}
public static boolean is5GMode() {
return is5GMode(false);
}
public static boolean is5GMode(boolean z) {
int type;
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(z);
return activeNetworkInfo != null && (type = activeNetworkInfo.getType()) != 1 && type == 0 && adjustNetworkType(activeNetworkInfo.getSubtype()) == 20;
}
public static boolean isActiveNetworkMetered() {
if (Build.VERSION.SDK_INT < 16) {
return false;
}
ConnectivityManager connectivityManager = getConnectivityManager();
if (connectivityManager == null) {
return true;
}
return connectivityManager.isActiveNetworkMetered();
}
public static boolean isCharge() {
ConnectivityManager connectivityManager = getConnectivityManager();
if (connectivityManager == null) {
return true;
}
try {
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo == null || activeNetworkInfo.getType() == 0;
} catch (Exception unused) {
return true;
}
}
public static boolean isFreeWifi() {
return isWifiMode(false) && !isCharge();
}
public static boolean isMobileNetwork() {
return isMobileNetwork(false);
}
public static boolean isMobileNetwork(boolean z) {
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(z);
return activeNetworkInfo != null && activeNetworkInfo.getType() == 0;
}
public static boolean isNetworkAvailable() {
return isNetworkConnected();
}
public static boolean isNetworkConnected() {
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(false);
if (activeNetworkInfo == null) {
return false;
}
return activeNetworkInfo.isConnected() || activeNetworkInfo.isAvailable();
}
public static boolean isNetworkRemoating() {
return k;
}
public static boolean isNetworkStateConnectingOrConnected() {
try {
ConnectivityManager connectivityManager = getConnectivityManager();
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(0);
NetworkInfo networkInfo2 = connectivityManager.getNetworkInfo(1);
if (networkInfo != null && networkInfo2 != null) {
if (!networkInfo.isConnectedOrConnecting()) {
if (!networkInfo2.isConnectedOrConnecting()) {
return false;
}
}
return true;
}
} catch (Exception unused) {
}
return false;
}
public static boolean isServiceStateFiveGAvailable(String str) {
return !TextUtils.isEmpty(str) && (str.contains("nrState=NOT_RESTRICTED") || str.contains("nrState=CONNECTED"));
}
public static boolean isWifiMode() {
return isWifiMode(false);
}
public static boolean isWifiMode(boolean z) {
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(z);
return activeNetworkInfo != null && activeNetworkInfo.getType() == 1;
}
public static synchronized void refreshApntype() {
synchronized (Apn.class) {
FLogger.d("ip-list", "Apn--refreshApntype()");
if (!j) {
f();
}
}
}
public static void registerRecevier() {
if (m != null) {
return;
}
m = new ConnectionChangeHandler(new ConnectionChangeHandler.ConnectionChangeCallback() {
@Override
public void onConnectionChanged() {
}
@Override
public void onConnectionChanging() {
Apn.e();
}
});
m.startObserve();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.USER_PRESENT");
intentFilter.addAction("android.intent.action.SCREEN_OFF");
d().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (TextUtils.equals(action, "android.intent.action.USER_PRESENT") || TextUtils.equals(action, "android.intent.action.SCREEN_OFF")) {
if (Apn.l == null) {
Handler unused = Apn.l = new Handler(ConnectivityAdapterHolder.a());
}
Apn.l.post(new Runnable() {
@Override
public void run() {
Apn.e();
}
});
}
}
}, intentFilter);
}
public static void setApplicationContext(Context context) {
g = context;
}
public static void tbsInit(Context context) {
setApplicationContext(context);
f();
}
public static String userNetworkSummary() {
Context d2;
TelephonyManager telephonyManager;
NetworkInfo activeNetworkInfo = getActiveNetworkInfo(false);
if (activeNetworkInfo == null || (d2 = d()) == null) {
return "";
}
try {
telephonyManager = (TelephonyManager) d2.getSystemService("phone");
} catch (Throwable unused) {
telephonyManager = null;
}
if (telephonyManager == null) {
return "";
}
String simOperator = telephonyManager.getSimOperator();
StringBuilder sb = new StringBuilder();
sb.append("\nNetwork Information:\n");
sb.append("ExtraInfo=" + activeNetworkInfo.getExtraInfo() + "\n");
sb.append("SubtypeName=" + activeNetworkInfo.getSubtypeName() + " SubType = " + activeNetworkInfo.getSubtype() + "\n");
sb.append("TypeName=" + activeNetworkInfo.getTypeName() + " Type = " + activeNetworkInfo.getType() + "\n");
StringBuilder sb2 = new StringBuilder();
sb2.append("SimOperator=");
sb2.append(simOperator);
sb2.append("\n");
sb.append(sb2.toString());
return sb.toString();
}
}