mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-01-18 21:52:48 +08:00
Performance-related fix
Move all conversions to line 236, saving ~14 tests
This commit is contained in:
parent
a87effc43e
commit
6550b937d0
@ -233,32 +233,32 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
private String getType(NetworkInfo info) {
|
private String getType(NetworkInfo info) {
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
String type = info.getTypeName();
|
String type = info.getTypeName().toLowerCase(Locale.US);
|
||||||
|
|
||||||
Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase());
|
Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase());
|
||||||
Log.d("CordovaNetworkManager", "wifi : " + WIFI);
|
Log.d("CordovaNetworkManager", "wifi : " + WIFI);
|
||||||
if (type.toLowerCase(Locale.US).equals(WIFI)) {
|
if (type.equals(WIFI)) {
|
||||||
return TYPE_WIFI;
|
return TYPE_WIFI;
|
||||||
}
|
}
|
||||||
else if (type.toLowerCase(Locale.US).equals(MOBILE) || type.toLowerCase(Locale.US).equals(CELLULAR)) {
|
else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
|
||||||
type = info.getSubtypeName();
|
type = info.getSubtypeName();
|
||||||
if (type.toLowerCase(Locale.US).equals(GSM) ||
|
if (type.equals(GSM) ||
|
||||||
type.toLowerCase(Locale.US).equals(GPRS) ||
|
type.equals(GPRS) ||
|
||||||
type.toLowerCase(Locale.US).equals(EDGE)) {
|
type.equals(EDGE)) {
|
||||||
return TYPE_2G;
|
return TYPE_2G;
|
||||||
}
|
}
|
||||||
else if (type.toLowerCase(Locale.US).startsWith(CDMA) ||
|
else if (type.startsWith(CDMA) ||
|
||||||
type.toLowerCase(Locale.US).equals(UMTS) ||
|
type.equals(UMTS) ||
|
||||||
type.toLowerCase(Locale.US).equals(ONEXRTT) ||
|
type.equals(ONEXRTT) ||
|
||||||
type.toLowerCase(Locale.US).equals(EHRPD) ||
|
type.equals(EHRPD) ||
|
||||||
type.toLowerCase(Locale.US).equals(HSUPA) ||
|
type.equals(HSUPA) ||
|
||||||
type.toLowerCase(Locale.US).equals(HSDPA) ||
|
type.equals(HSDPA) ||
|
||||||
type.toLowerCase(Locale.US).equals(HSPA)) {
|
type.equals(HSPA)) {
|
||||||
return TYPE_3G;
|
return TYPE_3G;
|
||||||
}
|
}
|
||||||
else if (type.toLowerCase(Locale.US).equals(LTE) ||
|
else if (type.equals(LTE) ||
|
||||||
type.toLowerCase(Locale.US).equals(UMB) ||
|
type.equals(UMB) ||
|
||||||
type.toLowerCase(Locale.US).equals(HSPA_PLUS)) {
|
type.equals(HSPA_PLUS)) {
|
||||||
return TYPE_4G;
|
return TYPE_4G;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user