If frameworks wants ASCII casing, it should explicity ask for it.
http://elliotth.blogspot.com/2012/01/beware-convenience-methods.html
Bug: https://code.google.com/p/android/issues/detail?id=58359
Change-Id: Iaab02e718a7be7bda22e626dca05d79bfd2a8fc4
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index fc95728..330b7e5 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -6979,7 +6979,7 @@
return null;
}
- type = type.trim().toLowerCase(Locale.US);
+ type = type.trim().toLowerCase(Locale.ROOT);
final int semicolonIndex = type.indexOf(';');
if (semicolonIndex != -1) {
diff --git a/core/java/android/database/DatabaseUtils.java b/core/java/android/database/DatabaseUtils.java
index e2d9724..c125544 100644
--- a/core/java/android/database/DatabaseUtils.java
+++ b/core/java/android/database/DatabaseUtils.java
@@ -1376,7 +1376,7 @@
if (sql.length() < 3) {
return STATEMENT_OTHER;
}
- String prefixSql = sql.substring(0, 3).toUpperCase(Locale.US);
+ String prefixSql = sql.substring(0, 3).toUpperCase(Locale.ROOT);
if (prefixSql.equals("SEL")) {
return STATEMENT_SELECT;
} else if (prefixSql.equals("INS") ||
diff --git a/core/java/android/net/MailTo.java b/core/java/android/net/MailTo.java
index ca28f86..b90dcb1 100644
--- a/core/java/android/net/MailTo.java
+++ b/core/java/android/net/MailTo.java
@@ -17,6 +17,7 @@
package android.net;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -84,7 +85,7 @@
}
// insert the headers with the name in lowercase so that
// we can easily find common headers
- m.mHeaders.put(Uri.decode(nameval[0]).toLowerCase(),
+ m.mHeaders.put(Uri.decode(nameval[0]).toLowerCase(Locale.ROOT),
nameval.length > 1 ? Uri.decode(nameval[1]) : null);
}
}
diff --git a/core/java/android/net/NetworkConfig.java b/core/java/android/net/NetworkConfig.java
index 3cc0bc5..5d95f41 100644
--- a/core/java/android/net/NetworkConfig.java
+++ b/core/java/android/net/NetworkConfig.java
@@ -17,6 +17,7 @@
package android.net;
import android.util.Log;
+import java.util.Locale;
/**
* Describes the buildtime configuration of a network.
@@ -63,7 +64,7 @@
*/
public NetworkConfig(String init) {
String fragments[] = init.split(",");
- name = fragments[0].trim().toLowerCase();
+ name = fragments[0].trim().toLowerCase(Locale.ROOT);
type = Integer.parseInt(fragments[1]);
radio = Integer.parseInt(fragments[2]);
priority = Integer.parseInt(fragments[3]);
diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java
index cd799da..9c4772b 100644
--- a/core/java/android/net/ProxyProperties.java
+++ b/core/java/android/net/ProxyProperties.java
@@ -25,6 +25,7 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
+import java.util.Locale;
/**
* A container class for the http proxy info
@@ -87,7 +88,7 @@
if (mExclusionList == null) {
mParsedExclusionList = new String[0];
} else {
- String splitExclusionList[] = exclusionList.toLowerCase().split(",");
+ String splitExclusionList[] = exclusionList.toLowerCase(Locale.ROOT).split(",");
mParsedExclusionList = new String[splitExclusionList.length * 2];
for (int i = 0; i < splitExclusionList.length; i++) {
String s = splitExclusionList[i].trim();
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index 1d1e149..132173d 100644
--- a/core/java/android/net/Uri.java
+++ b/core/java/android/net/Uri.java
@@ -1717,7 +1717,7 @@
if (flag == null) {
return defaultValue;
}
- flag = flag.toLowerCase();
+ flag = flag.toLowerCase(Locale.ROOT);
return (!"false".equals(flag) && !"0".equals(flag));
}
@@ -1745,7 +1745,7 @@
public Uri normalizeScheme() {
String scheme = getScheme();
if (scheme == null) return this; // give up
- String lowerScheme = scheme.toLowerCase(Locale.US);
+ String lowerScheme = scheme.toLowerCase(Locale.ROOT);
if (scheme.equals(lowerScheme)) return this; // no change
return buildUpon().scheme(lowerScheme).build();
diff --git a/core/java/android/net/UrlQuerySanitizer.java b/core/java/android/net/UrlQuerySanitizer.java
index a6efcdd..d2073b4 100644
--- a/core/java/android/net/UrlQuerySanitizer.java
+++ b/core/java/android/net/UrlQuerySanitizer.java
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
@@ -305,7 +306,7 @@
int length = value.length();
if ((mFlags & SCRIPT_URL_OK) != 0) {
if (length >= MIN_SCRIPT_PREFIX_LENGTH) {
- String asLower = value.toLowerCase();
+ String asLower = value.toLowerCase(Locale.ROOT);
if (asLower.startsWith(JAVASCRIPT_PREFIX) ||
asLower.startsWith(VBSCRIPT_PREFIX)) {
return "";
diff --git a/core/java/android/net/WebAddress.java b/core/java/android/net/WebAddress.java
index 052f921..8126b75 100644
--- a/core/java/android/net/WebAddress.java
+++ b/core/java/android/net/WebAddress.java
@@ -18,6 +18,7 @@
import static android.util.Patterns.GOOD_IRI_CHAR;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -77,7 +78,7 @@
String t;
if (m.matches()) {
t = m.group(MATCH_GROUP_SCHEME);
- if (t != null) mScheme = t.toLowerCase();
+ if (t != null) mScheme = t.toLowerCase(Locale.ROOT);
t = m.group(MATCH_GROUP_AUTHORITY);
if (t != null) mAuthInfo = t;
t = m.group(MATCH_GROUP_HOST);
diff --git a/core/java/android/net/http/HttpAuthHeader.java b/core/java/android/net/http/HttpAuthHeader.java
index d41284c..3abac23 100644
--- a/core/java/android/net/http/HttpAuthHeader.java
+++ b/core/java/android/net/http/HttpAuthHeader.java
@@ -16,6 +16,8 @@
package android.net.http;
+import java.util.Locale;
+
/**
* HttpAuthHeader: a class to store HTTP authentication-header parameters.
* For more information, see: RFC 2617: HTTP Authentication.
@@ -380,12 +382,12 @@
}
if (token.equalsIgnoreCase(QOP_TOKEN)) {
- mQop = value.toLowerCase();
+ mQop = value.toLowerCase(Locale.ROOT);
return;
}
if (token.equalsIgnoreCase(ALGORITHM_TOKEN)) {
- mAlgorithm = value.toLowerCase();
+ mAlgorithm = value.toLowerCase(Locale.ROOT);
return;
}
}
diff --git a/core/java/android/net/http/HttpsConnection.java b/core/java/android/net/http/HttpsConnection.java
index f421d29..7a12e53 100644
--- a/core/java/android/net/http/HttpsConnection.java
+++ b/core/java/android/net/http/HttpsConnection.java
@@ -44,6 +44,7 @@
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.cert.X509Certificate;
+import java.util.Locale;
/**
* A Connection connecting to a secure http server or tunneling through
@@ -209,7 +210,7 @@
// to add 'host' header unless we want proxy to answer us with a
// 400 Bad Request
for (Header h : req.mHttpRequest.getAllHeaders()) {
- String headerName = h.getName().toLowerCase();
+ String headerName = h.getName().toLowerCase(Locale.ROOT);
if (headerName.startsWith("proxy") || headerName.equals("keep-alive")
|| headerName.equals("host")) {
proxyReq.addHeader(h);
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index 9b71f62..2b58818 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -456,8 +456,8 @@
if (domain == null) throw new NullPointerException("domain is null");
if (type == null) throw new NullPointerException("type is null");
- domain = domain.trim().toLowerCase(Locale.US);
- type = type.trim().toLowerCase(Locale.US);
+ domain = domain.trim().toLowerCase(Locale.ROOT);
+ type = type.trim().toLowerCase(Locale.ROOT);
if (domain.length() == 0) throw new IllegalArgumentException("domain is empty");
if (type.length() == 0) throw new IllegalArgumentException("type is empty");
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3c8187e..3f8b680 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -56,6 +56,7 @@
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Locale;
/**
* The Settings provider contains global system-level device preferences.
@@ -5248,7 +5249,7 @@
* @hide
*/
public static final String getBluetoothHeadsetPriorityKey(String address) {
- return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase();
+ return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
}
/**
@@ -5256,7 +5257,7 @@
* @hide
*/
public static final String getBluetoothA2dpSinkPriorityKey(String address) {
- return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase();
+ return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
}
/**
@@ -5264,7 +5265,7 @@
* @hide
*/
public static final String getBluetoothInputDevicePriorityKey(String address) {
- return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase();
+ return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
}
/**
diff --git a/core/java/android/speech/srec/Recognizer.java b/core/java/android/speech/srec/Recognizer.java
index 8a2bc7d..db5d8fd 100644
--- a/core/java/android/speech/srec/Recognizer.java
+++ b/core/java/android/speech/srec/Recognizer.java
@@ -145,7 +145,7 @@
public static String getConfigDir(Locale locale) {
if (locale == null) locale = Locale.US;
String dir = "/system/usr/srec/config/" +
- locale.toString().replace('_', '.').toLowerCase();
+ locale.toString().replace('_', '.').toLowerCase(Locale.ROOT);
if ((new File(dir)).isDirectory()) return dir;
return null;
}
diff --git a/core/java/android/text/util/Linkify.java b/core/java/android/text/util/Linkify.java
index 2bc1c6a..deb138d 100644
--- a/core/java/android/text/util/Linkify.java
+++ b/core/java/android/text/util/Linkify.java
@@ -365,7 +365,7 @@
String scheme, MatchFilter matchFilter,
TransformFilter transformFilter) {
boolean hasMatches = false;
- String prefix = (scheme == null) ? "" : scheme.toLowerCase();
+ String prefix = (scheme == null) ? "" : scheme.toLowerCase(Locale.ROOT);
Matcher m = p.matcher(s);
while (m.find()) {
diff --git a/core/java/android/util/DebugUtils.java b/core/java/android/util/DebugUtils.java
index 7e3c855..f607207 100644
--- a/core/java/android/util/DebugUtils.java
+++ b/core/java/android/util/DebugUtils.java
@@ -18,6 +18,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.util.Locale;
/**
* <p>Various utilities for debugging and logging.</p>
@@ -78,7 +79,7 @@
Class<?> parent = klass;
do {
declaredMethod = parent.getDeclaredMethod("get" +
- pair[0].substring(0, 1).toUpperCase() +
+ pair[0].substring(0, 1).toUpperCase(Locale.ROOT) +
pair[0].substring(1),
(Class[]) null);
} while ((parent = klass.getSuperclass()) != null &&
diff --git a/core/java/android/webkit/URLUtil.java b/core/java/android/webkit/URLUtil.java
index b47f04f..d115984 100644
--- a/core/java/android/webkit/URLUtil.java
+++ b/core/java/android/webkit/URLUtil.java
@@ -17,6 +17,7 @@
package android.webkit;
import java.io.UnsupportedEncodingException;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -348,7 +349,7 @@
}
}
if (extension == null) {
- if (mimeType != null && mimeType.toLowerCase().startsWith("text/")) {
+ if (mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("text/")) {
if (mimeType.equalsIgnoreCase("text/html")) {
extension = ".html";
} else {