From 14be7d23a2ee023796126453bba55f4bc84ba065 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Tue, 2 Sep 2014 18:22:09 -0700 Subject: [PATCH] Fix bug #17208479 Have Cellular Networks Show up in Data Usage - prevent collisions in the DocId (which is the primary key of the FTS4 table) - instead of just using "updatedTitle" hash, use instead "updatedTitle + screenTitle" Change-Id: If38f7bcc7fb857d59242d08c16c39adb80590254 --- src/com/android/settings/search/Index.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/search/Index.java b/src/com/android/settings/search/Index.java index f5a2fa9464a..db60dfe8f26 100644 --- a/src/com/android/settings/search/Index.java +++ b/src/com/android/settings/search/Index.java @@ -1025,8 +1025,14 @@ public class Index { return; } + // The DocID should contains more than the title string itself (you may have two settings + // with the same title). So we need to use a combination of the title and the screenTitle. + StringBuilder sb = new StringBuilder(updatedTitle); + sb.append(screenTitle); + int docId = sb.toString().hashCode(); + ContentValues values = new ContentValues(); - values.put(IndexColumns.DOCID, updatedTitle.hashCode()); + values.put(IndexColumns.DOCID, docId); values.put(IndexColumns.LOCALE, locale); values.put(IndexColumns.DATA_RANK, rank); values.put(IndexColumns.DATA_TITLE, updatedTitle);