mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-01-31 18:47:21 +08:00
CB-11300: (android) Recognize "2G", "3G" and "4G" network connection subtype names
This commit is contained in:
parent
04a1f713ca
commit
d29f28f6c4
@ -51,10 +51,12 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
// 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+";
|
||||||
@ -254,7 +257,8 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
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