From 92ce5734b52ef014c80cc6335112a027188b3eb6 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 2 Jun 2010 23:47:01 +0200 Subject: [PATCH 1/2] Canvas.drawVertices: correct color range-check The range-check in drawVertices previously checked that the color count was equal to the vertex count. However, the vertex count is specified in array elements, and there's two array elements per vertex for the positions, but only one array element per vertex for the colors. Correct the code so the check is consistent with the element count. Change-Id: Id043f1003f9245f18adc91bac49dc33727ca765e --- graphics/java/android/graphics/Canvas.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 345f810ecf2a9..76cde731945d6 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -1221,7 +1221,7 @@ public class Canvas { checkRange(texs.length, texOffset, vertexCount); } if (colors != null) { - checkRange(colors.length, colorOffset, vertexCount); + checkRange(colors.length, colorOffset, vertexCount / 2); } if (indices != null) { checkRange(indices.length, indexOffset, indexCount); From 47633f86279bc1854660d95a0b02bfa5ff14ad04 Mon Sep 17 00:00:00 2001 From: Lars Dunemark Date: Mon, 8 Feb 2010 14:04:38 +0100 Subject: [PATCH 2/2] Removes dashes when locale and number is not NANP or Japan Removes all dashes if locale isn't NANP or Japan and the number don't have there country code. Use case: If adding a number starting with 1nnnnnn and then trying to add a country code before (ex +46) we will first trigger NANP formatting with +1-nnn-nnn so when we get +41-nnn-nnn we will still have the old NANP formatting. This number should be shown as +461nnnnnn. Change-Id: I5cab830350d785a58367eba79e268d9e8ee16aac --- .../android/telephony/PhoneNumberUtils.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 3f086765a8b8f..454231ff6adcf 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1058,7 +1058,7 @@ public class PhoneNumberUtils && text.charAt(2) == '1') { formatType = FORMAT_JAPAN; } else { - return; + formatType = FORMAT_UNKNOWN; } } @@ -1069,6 +1069,9 @@ public class PhoneNumberUtils case FORMAT_JAPAN: formatJapaneseNumber(text); return; + case FORMAT_UNKNOWN: + removeDashes(text); + return; } } @@ -1104,14 +1107,7 @@ public class PhoneNumberUtils CharSequence saved = text.subSequence(0, length); // Strip the dashes first, as we're going to add them back - int p = 0; - while (p < text.length()) { - if (text.charAt(p) == '-') { - text.delete(p, p + 1); - } else { - p++; - } - } + removeDashes(text); length = text.length(); // When scanning the number we record where dashes need to be added, @@ -1215,6 +1211,22 @@ public class PhoneNumberUtils JapanesePhoneNumberFormatter.format(text); } + /** + * Removes all dashes from the number. + * + * @param text the number to clear from dashes + */ + private static void removeDashes(Editable text) { + int p = 0; + while (p < text.length()) { + if (text.charAt(p) == '-') { + text.delete(p, p + 1); + } else { + p++; + } + } + } + // Three and four digit phone numbers for either special services, // or 3-6 digit addresses from the network (eg carrier-originated SMS messages) should // not match.