aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-01-06 09:29:25 -0800
committerTor Norbye <tnorbye@google.com>2012-01-06 09:29:25 -0800
commit18bce12c5916331971b2e8108f8485cc56b696d3 (patch)
tree2c634dc2e09bf68bfe21faa0674c208e62017c71 /ddms/libs
parent9f338c0725644f84597366c1e4acb680a72b3f00 (diff)
downloadsdk-18bce12c5916331971b2e8108f8485cc56b696d3.zip
sdk-18bce12c5916331971b2e8108f8485cc56b696d3.tar.gz
sdk-18bce12c5916331971b2e8108f8485cc56b696d3.tar.bz2
Fix locale handling of uppercase/lowercase
This changeset fixes issue 23747: i and İ character problem in turkish operating Systems... and probably many other bugs in the Turkish locale. Basically, we had a lot of String.toLowerCase() and String.toUpperCase() calls. This performs locale sensitive conversions, which in many cases is NOT what we want; for "machine readable" conversions we should be using Locale.US which performs no special cases. For more, see http://developer.android.com/reference/java/util/Locale.html#default_locale Change-Id: I996b0e70fb377e8dae484c5811deb8bc9afb684c
Diffstat (limited to 'ddms/libs')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/AllocationInfo.java13
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/EmulatorConsole.java4
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/log/EventContainer.java65
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/log/EventValueDescription.java32
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java8
5 files changed, 66 insertions, 56 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/AllocationInfo.java b/ddms/libs/ddmlib/src/com/android/ddmlib/AllocationInfo.java
index a68962f..157b044 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/AllocationInfo.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/AllocationInfo.java
@@ -17,6 +17,7 @@
package com.android.ddmlib;
import java.util.Comparator;
+import java.util.Locale;
/**
* Holds an Allocation information.
@@ -185,8 +186,12 @@ public class AllocationInfo implements IStackTraceInfo {
return null;
}
- public boolean filter(String filter, boolean fullTrace) {
- if (mAllocatedClass.toLowerCase().contains(filter)) {
+ /**
+ * Returns true if the given filter matches case insensitively (according to
+ * the given locale) this allocation info.
+ */
+ public boolean filter(String filter, boolean fullTrace, Locale locale) {
+ if (mAllocatedClass.toLowerCase(locale).contains(filter)) {
return true;
}
@@ -195,11 +200,11 @@ public class AllocationInfo implements IStackTraceInfo {
final int length = fullTrace ? mStackTrace.length : 1;
for (int i = 0 ; i < length ; i++) {
- if (mStackTrace[i].getClassName().toLowerCase().contains(filter)) {
+ if (mStackTrace[i].getClassName().toLowerCase(locale).contains(filter)) {
return true;
}
- if (mStackTrace[i].getMethodName().toLowerCase().contains(filter)) {
+ if (mStackTrace[i].getMethodName().toLowerCase(locale).contains(filter)) {
return true;
}
}
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/EmulatorConsole.java b/ddms/libs/ddmlib/src/com/android/ddmlib/EmulatorConsole.java
index d34f203..f3ab28c 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/EmulatorConsole.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/EmulatorConsole.java
@@ -419,7 +419,7 @@ public final class EmulatorConsole {
String value = m.group(1);
// get the index from the list
- status.voice = GsmMode.getEnum(value.toLowerCase());
+ status.voice = GsmMode.getEnum(value.toLowerCase(Locale.US));
// move on to next line.
continue;
@@ -431,7 +431,7 @@ public final class EmulatorConsole {
String value = m.group(1);
// get the index from the list
- status.data = GsmMode.getEnum(value.toLowerCase());
+ status.data = GsmMode.getEnum(value.toLowerCase(Locale.US));
// move on to next line.
continue;
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventContainer.java b/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventContainer.java
index ec9186c..0afdf5d 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventContainer.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventContainer.java
@@ -18,6 +18,7 @@ package com.android.ddmlib.log;
import com.android.ddmlib.log.LogReceiver.LogEntry;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -25,7 +26,7 @@ import java.util.regex.Pattern;
* Represents an event and its data.
*/
public class EventContainer {
-
+
/**
* Comparison method for {@link EventContainer#testValue(int, Object, com.android.ddmlib.log.EventContainer.CompareMethod)}
*
@@ -37,7 +38,7 @@ public class EventContainer {
GREATER_THAN("greater than or equals to", ">="),
GREATER_THAN_STRICT("greater than", ">"),
BIT_CHECK("bit check", "&");
-
+
private final String mName;
private final String mTestString;
@@ -62,7 +63,7 @@ public class EventContainer {
}
}
-
+
/**
* Type for event data.
*/
@@ -73,11 +74,11 @@ public class EventContainer {
STRING(3),
LIST(4),
TREE(5);
-
+
private final static Pattern STORAGE_PATTERN = Pattern.compile("^(\\d+)@(.*)$"); //$NON-NLS-1$
-
+
private int mValue;
-
+
/**
* Returns a {@link EventValueType} from an integer value, or <code>null</code> if no match
* was found.
@@ -89,7 +90,7 @@ public class EventContainer {
return type;
}
}
-
+
return null;
}
@@ -106,16 +107,16 @@ public class EventContainer {
*/
public static String getStorageString(Object object) {
if (object instanceof String) {
- return STRING.mValue + "@" + (String)object; //$NON-NLS-1$
+ return STRING.mValue + "@" + (String)object; //$NON-NLS-1$
} else if (object instanceof Integer) {
- return INT.mValue + "@" + object.toString(); //$NON-NLS-1$
+ return INT.mValue + "@" + object.toString(); //$NON-NLS-1$
} else if (object instanceof Long) {
- return LONG.mValue + "@" + object.toString(); //$NON-NLS-1$
+ return LONG.mValue + "@" + object.toString(); //$NON-NLS-1$
}
-
+
return null;
}
-
+
/**
* Creates an {@link Object} from a storage string created with
* {@link #getStorageString(Object)}.
@@ -131,7 +132,7 @@ public class EventContainer {
if (type == null) {
return null;
}
-
+
switch (type) {
case STRING:
return m.group(2);
@@ -144,11 +145,11 @@ public class EventContainer {
return null;
}
}
-
+
return null;
}
-
-
+
+
/**
* Returns the integer value of the enum.
*/
@@ -158,7 +159,7 @@ public class EventContainer {
@Override
public String toString() {
- return super.toString().toLowerCase();
+ return super.toString().toLowerCase(Locale.US);
}
private EventValueType(int value) {
@@ -172,7 +173,7 @@ public class EventContainer {
public int sec; /* seconds since Epoch */
public int nsec; /* nanoseconds */
- private Object mData;
+ private Object mData;
/**
* Creates an {@link EventContainer} from a {@link LogEntry}.
@@ -190,7 +191,7 @@ public class EventContainer {
sec = entry.sec;
nsec = entry.nsec;
}
-
+
/**
* Creates an {@link EventContainer} with raw data
*/
@@ -198,7 +199,7 @@ public class EventContainer {
getType(data);
mTag = tag;
mData = data;
-
+
this.pid = pid;
this.tid = tid;
this.sec = sec;
@@ -217,10 +218,10 @@ public class EventContainer {
throw new InvalidTypeException();
}
-
+
/**
* Returns the data as a long.
- * @throws InvalidTypeException if the data type is not {@link EventValueType#LONG}.
+ * @throws InvalidTypeException if the data type is not {@link EventValueType#LONG}.
* @see #getType()
*/
public final Long getLong() throws InvalidTypeException {
@@ -243,7 +244,7 @@ public class EventContainer {
throw new InvalidTypeException();
}
-
+
/**
* Returns a value by index. The return type is defined by its type.
* @param valueIndex the index of the value. If the data is not a list, this is ignored.
@@ -277,7 +278,7 @@ public class EventContainer {
public String getValueAsString(int valueIndex) throws InvalidTypeException {
return getValueAsString(mData, valueIndex, true);
}
-
+
/**
* Returns the type of the data.
*/
@@ -309,7 +310,7 @@ public class EventContainer {
return EventValueType.UNKNOWN;
}
-
+
/**
* Checks that the <code>index</code>-th value of this event against a provided value.
* @param index the index of the value to test
@@ -326,7 +327,7 @@ public class EventContainer {
if (index > 0 && type != EventValueType.LIST) {
throw new InvalidTypeException();
}
-
+
Object data = mData;
if (type == EventValueType.LIST) {
data = ((Object[])mData)[index];
@@ -388,10 +389,10 @@ public class EventContainer {
throw new InvalidTypeException();
}
}
-
+
private final Object getValue(Object data, int valueIndex, boolean recursive) {
EventValueType type = getType(data);
-
+
switch (type) {
case INT:
case LONG:
@@ -405,14 +406,14 @@ public class EventContainer {
}
}
}
-
+
return null;
}
private final double getValueAsDouble(Object data, int valueIndex, boolean recursive)
throws InvalidTypeException {
EventValueType type = getType(data);
-
+
switch (type) {
case INT:
return ((Integer)data).doubleValue();
@@ -428,14 +429,14 @@ public class EventContainer {
}
}
}
-
+
throw new InvalidTypeException();
}
private final String getValueAsString(Object data, int valueIndex, boolean recursive)
throws InvalidTypeException {
EventValueType type = getType(data);
-
+
switch (type) {
case INT:
return ((Integer)data).toString();
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventValueDescription.java b/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventValueDescription.java
index b68b4e8..58d147c 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventValueDescription.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/log/EventValueDescription.java
@@ -18,6 +18,8 @@ package com.android.ddmlib.log;
import com.android.ddmlib.log.EventContainer.EventValueType;
+import java.util.Locale;
+
/**
* Describes an {@link EventContainer} value.
@@ -28,13 +30,13 @@ import com.android.ddmlib.log.EventContainer.EventValueType;
* The index of the value is not contained within this class, and is instead dependent on the
* index of this particular object in the array of {@link EventValueDescription} returned by
* {@link EventLogParser#getEventInfoMap()} when queried for a particular event tag.
- *
+ *
*/
public final class EventValueDescription {
-
+
/**
* Represents the type of a numerical value. This is used to display values of vastly different
- * type/range in graphs.
+ * type/range in graphs.
*/
public static enum ValueType {
NOT_APPLICABLE(0),
@@ -80,21 +82,21 @@ public final class EventValueDescription {
public int getValue() {
return mValue;
}
-
+
@Override
public String toString() {
- return super.toString().toLowerCase();
+ return super.toString().toLowerCase(Locale.US);
}
-
+
private ValueType(int value) {
mValue = value;
}
}
-
+
private String mName;
private EventValueType mEventValueType;
private ValueType mValueType;
-
+
/**
* Builds a {@link EventValueDescription} with a name and a type.
* <p/>
@@ -121,7 +123,7 @@ public final class EventValueDescription {
* @param type
* @param valueType
* @throws InvalidValueTypeException if type and valuetype are not compatible.
- *
+ *
*/
EventValueDescription(String name, EventValueType type, ValueType valueType)
throws InvalidValueTypeException {
@@ -130,7 +132,7 @@ public final class EventValueDescription {
mValueType = valueType;
mValueType.checkType(mEventValueType);
}
-
+
/**
* @return the Name.
*/
@@ -151,14 +153,14 @@ public final class EventValueDescription {
public ValueType getValueType() {
return mValueType;
}
-
+
@Override
public String toString() {
if (mValueType != ValueType.NOT_APPLICABLE) {
return String.format("%1$s (%2$s, %3$s)", mName, mEventValueType.toString(),
mValueType.toString());
}
-
+
return String.format("%1$s (%2$s)", mName, mEventValueType.toString());
}
@@ -178,10 +180,10 @@ public final class EventValueDescription {
case LIST:
return value instanceof Object[];
}
-
+
return false;
}
-
+
/**
* Returns an object of a valid type (based on the value returned by
* {@link #getEventValueType()}) from a String value.
@@ -208,7 +210,7 @@ public final class EventValueDescription {
case STRING:
return value;
}
-
+
return null;
}
}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java
index 3214da2..23775e8 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java
@@ -61,6 +61,7 @@ import org.eclipse.swt.widgets.Text;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Locale;
/**
* Base class for our information panels.
@@ -643,12 +644,13 @@ public class AllocationPanel extends TablePanel {
private AllocationInfo[] getFilteredAllocations(AllocationInfo[] allocations,
String filterText) {
ArrayList<AllocationInfo> results = new ArrayList<AllocationInfo>();
-
- filterText = filterText.toLowerCase();
+ // Using default locale here such that the locale-specific c
+ Locale locale = Locale.getDefault();
+ filterText = filterText.toLowerCase(locale);
boolean fullTrace = mTraceFilterCheck.getSelection();
for (AllocationInfo info : allocations) {
- if (info.filter(filterText, fullTrace)) {
+ if (info.filter(filterText, fullTrace, locale)) {
results.add(info);
}
}