mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-01-31 10:35:43 +08:00
CB-11300: (android) Recognize "2G", "3G" and "4G" network connection subtype names
This commit is contained in:
parent
04a1f713ca
commit
d29f28f6c4
@ -47,14 +47,16 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
public static final String WIMAX = "wimax";
|
public static final String WIMAX = "wimax";
|
||||||
// mobile
|
// mobile
|
||||||
public static final String MOBILE = "mobile";
|
public static final String MOBILE = "mobile";
|
||||||
|
|
||||||
// Android L calls this Cellular, because I have no idea!
|
// Android L calls this Cellular, because I have no idea!
|
||||||
public static final String CELLULAR = "cellular";
|
public static final String CELLULAR = "cellular";
|
||||||
// 2G network types
|
// 2G network types
|
||||||
|
public static final String TWO_G = "2g";
|
||||||
public static final String GSM = "gsm";
|
public static final String GSM = "gsm";
|
||||||
public static final String GPRS = "gprs";
|
public static final String GPRS = "gprs";
|
||||||
public static final String EDGE = "edge";
|
public static final String EDGE = "edge";
|
||||||
// 3G network types
|
// 3G network types
|
||||||
|
public static final String THREE_G = "3g";
|
||||||
public static final String CDMA = "cdma";
|
public static final String CDMA = "cdma";
|
||||||
public static final String UMTS = "umts";
|
public static final String UMTS = "umts";
|
||||||
public static final String HSPA = "hspa";
|
public static final String HSPA = "hspa";
|
||||||
@ -63,6 +65,7 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
public static final String ONEXRTT = "1xrtt";
|
public static final String ONEXRTT = "1xrtt";
|
||||||
public static final String EHRPD = "ehrpd";
|
public static final String EHRPD = "ehrpd";
|
||||||
// 4G network types
|
// 4G network types
|
||||||
|
public static final String FOUR_G = "4g";
|
||||||
public static final String LTE = "lte";
|
public static final String LTE = "lte";
|
||||||
public static final String UMB = "umb";
|
public static final String UMB = "umb";
|
||||||
public static final String HSPA_PLUS = "hspa+";
|
public static final String HSPA_PLUS = "hspa+";
|
||||||
@ -247,14 +250,15 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
if (type.equals(WIFI)) {
|
if (type.equals(WIFI)) {
|
||||||
return TYPE_WIFI;
|
return TYPE_WIFI;
|
||||||
}
|
}
|
||||||
else if (type.toLowerCase().equals(TYPE_ETHERNET) || type.toLowerCase().startsWith(TYPE_ETHERNET_SHORT)) {
|
else if (type.toLowerCase().equals(TYPE_ETHERNET) || type.toLowerCase().startsWith(TYPE_ETHERNET_SHORT)) {
|
||||||
return TYPE_ETHERNET;
|
return TYPE_ETHERNET;
|
||||||
}
|
}
|
||||||
else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
|
else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
|
||||||
type = info.getSubtypeName().toLowerCase(Locale.US);
|
type = info.getSubtypeName().toLowerCase(Locale.US);
|
||||||
if (type.equals(GSM) ||
|
if (type.equals(GSM) ||
|
||||||
type.equals(GPRS) ||
|
type.equals(GPRS) ||
|
||||||
type.equals(EDGE)) {
|
type.equals(EDGE) ||
|
||||||
|
type.equals(TWO_G)) {
|
||||||
return TYPE_2G;
|
return TYPE_2G;
|
||||||
}
|
}
|
||||||
else if (type.startsWith(CDMA) ||
|
else if (type.startsWith(CDMA) ||
|
||||||
@ -263,12 +267,14 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
type.equals(EHRPD) ||
|
type.equals(EHRPD) ||
|
||||||
type.equals(HSUPA) ||
|
type.equals(HSUPA) ||
|
||||||
type.equals(HSDPA) ||
|
type.equals(HSDPA) ||
|
||||||
type.equals(HSPA)) {
|
type.equals(HSPA) ||
|
||||||
|
type.equals(THREE_G)) {
|
||||||
return TYPE_3G;
|
return TYPE_3G;
|
||||||
}
|
}
|
||||||
else if (type.equals(LTE) ||
|
else if (type.equals(LTE) ||
|
||||||
type.equals(UMB) ||
|
type.equals(UMB) ||
|
||||||
type.equals(HSPA_PLUS)) {
|
type.equals(HSPA_PLUS) ||
|
||||||
|
type.equals(FOUR_G)) {
|
||||||
return TYPE_4G;
|
return TYPE_4G;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user