summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Muramatsu <btmura@google.com>2011-01-27 18:13:39 -0800
committerBrian Muramatsu <btmura@google.com>2011-01-27 18:13:39 -0800
commit4c8ad6eb6241a0f689e49237ecadb65e8ffa4b6c (patch)
tree354d2f761b1d1337e3c52cc8d94a86a1cb903055
parent7b4ba9d80d2cdde310c29d01d0e22c7815d84261 (diff)
downloadframeworks_base-4c8ad6eb6241a0f689e49237ecadb65e8ffa4b6c.zip
frameworks_base-4c8ad6eb6241a0f689e49237ecadb65e8ffa4b6c.tar.gz
frameworks_base-4c8ad6eb6241a0f689e49237ecadb65e8ffa4b6c.tar.bz2
Fix TextUtils#commaEllipsize
Bug 3400770 TextUtils#commaEllipsize creates a MeasuredText "mt" object with the text to be ellipsized. It calls setPara which initializes mt's mPos member to be 0. It then calls addStyleRun which moves mPos to the end of the string. The loop back in commaEllipsize then calls mt addStyleRun again and this causes IndexOutOfBoundsException, because the paint object is trying to measure text past the text's length. It seems this was a typo and that the tempMt variable should be used, because the code is trying to measure the format string...not the the string to be ellipsized. This makes the saner parts of CTS test for this method pass now. Change-Id: Ib6aa6e4bbd6afff4c95ad4c4d51a384cc1389875
-rw-r--r--core/java/android/text/TextUtils.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index 7748265..d5010c6 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -1142,7 +1142,7 @@ public class TextUtils {
// XXX this is probably ok, but need to look at it more
tempMt.setPara(format, 0, format.length(), request);
- float moreWid = mt.addStyleRun(p, mt.mLen, null);
+ float moreWid = tempMt.addStyleRun(p, tempMt.mLen, null);
if (w + moreWid <= avail) {
ok = i + 1;