From c40e579c5aa4e77a4695040b44ce3aa427429a1e Mon Sep 17 00:00:00 2001 From: Can Tecim Date: Sun, 26 Jul 2015 21:11:52 +0300 Subject: [PATCH] Solved toLowerCase issue with Locale.US --- src/android/NetworkManager.java | 34 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/android/NetworkManager.java b/src/android/NetworkManager.java index 4c85dda..d4cde23 100755 --- a/src/android/NetworkManager.java +++ b/src/android/NetworkManager.java @@ -35,6 +35,8 @@ Licensed to the Apache Software Foundation (ASF) under one import android.net.NetworkInfo; import android.util.Log; +import java.util.Locale; + public class NetworkManager extends CordovaPlugin { public static int NOT_REACHABLE = 0; @@ -233,28 +235,30 @@ private String getType(NetworkInfo info) { if (info != null) { String type = info.getTypeName(); - if (type.toLowerCase().equals(WIFI)) { + Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase()); + Log.d("CordovaNetworkManager", "wifi : " + WIFI); + if (type.toLowerCase(Locale.US).equals(WIFI)) { return TYPE_WIFI; } - else if (type.toLowerCase().equals(MOBILE) || type.toLowerCase().equals(CELLULAR)) { + else if (type.toLowerCase(Locale.US).equals(MOBILE) || type.toLowerCase(Locale.US).equals(CELLULAR)) { type = info.getSubtypeName(); - if (type.toLowerCase().equals(GSM) || - type.toLowerCase().equals(GPRS) || - type.toLowerCase().equals(EDGE)) { + if (type.toLowerCase(Locale.US).equals(GSM) || + type.toLowerCase(Locale.US).equals(GPRS) || + type.toLowerCase(Locale.US).equals(EDGE)) { return TYPE_2G; } - else if (type.toLowerCase().startsWith(CDMA) || - type.toLowerCase().equals(UMTS) || - type.toLowerCase().equals(ONEXRTT) || - type.toLowerCase().equals(EHRPD) || - type.toLowerCase().equals(HSUPA) || - type.toLowerCase().equals(HSDPA) || - type.toLowerCase().equals(HSPA)) { + else if (type.toLowerCase(Locale.US).startsWith(CDMA) || + type.toLowerCase(Locale.US).equals(UMTS) || + type.toLowerCase(Locale.US).equals(ONEXRTT) || + type.toLowerCase(Locale.US).equals(EHRPD) || + type.toLowerCase(Locale.US).equals(HSUPA) || + type.toLowerCase(Locale.US).equals(HSDPA) || + type.toLowerCase(Locale.US).equals(HSPA)) { return TYPE_3G; } - else if (type.toLowerCase().equals(LTE) || - type.toLowerCase().equals(UMB) || - type.toLowerCase().equals(HSPA_PLUS)) { + else if (type.toLowerCase(Locale.US).equals(LTE) || + type.toLowerCase(Locale.US).equals(UMB) || + type.toLowerCase(Locale.US).equals(HSPA_PLUS)) { return TYPE_4G; } }