fix wrong substring

The tokenOffsets is the offset from trimed contentLine.
But it is used in substring as the offset from un-trimed contentLine.

How to reproduce bug (ICS and before):
1. Add a contact record with name and a phone number (ex. 090-1111-2222)
2. Search by "0" in Contacts app
3. Contacts shows a wrong number something like "0900111102222"

Change-Id: I1e1cb2f3bd135d98e1573a50aa6ddc021af35b9f
This commit is contained in:
Masanori Ogino
2012-08-23 14:06:45 +09:00
parent 9f7fa4c417
commit 08bab56f68

2
core/java/android/provider/ContactsContract.java Normal file → Executable file
View File

@@ -8362,7 +8362,7 @@ public final class ContactsContract {
// Line contains the query string - now search for it at the start of tokens.
List<String> lineTokens = new ArrayList<String>();
List<Integer> tokenOffsets = new ArrayList<Integer>();
split(contentLine.trim(), lineTokens, tokenOffsets);
split(contentLine, lineTokens, tokenOffsets);
// As we find matches against the query, we'll populate this list with the marked
// (or unchanged) tokens.