Normalize dynamic search result in Japanese
Hiragana and Katakana are normalized in Japanese query string but
the dynamic search result is not. This leads to wrong results.
This is related to b/28410478
Bug: 112248621
Test: Manual - Set language to Japanese and search
Change-Id: I82ae5d44714b8152551d10c9868cb513bc075f7c
diff --git a/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java b/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java
index d7011ee..b7ad1bd 100644
--- a/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java
+++ b/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java
@@ -18,6 +18,10 @@
import android.text.TextUtils;
+import com.android.settings.intelligence.search.indexing.IndexData;
+
+import java.util.Locale;
+
/**
* Utils for Query-time operations.
*/
@@ -40,12 +44,18 @@
* resultName: Abcde, query: bc, Returns NAME_NO_MATCH
* resultName: Abcde, query: xyz, Returns NAME_NO_MATCH
* resultName: Abc de, query: de, Returns 4
+ *
+ * In Japanese, normalize resultName to match normalized query.
*/
public static int getWordDifference(String resultName, String query) {
if (TextUtils.isEmpty(resultName) || TextUtils.isEmpty(query)) {
return NAME_NO_MATCH;
}
+ if (Locale.getDefault().equals(Locale.JAPAN)) {
+ resultName = IndexData.normalizeJapaneseString(resultName);
+ }
+
final char[] queryTokens = query.toLowerCase().toCharArray();
final char[] resultTokens = resultName.toLowerCase().toCharArray();
final int resultLength = resultTokens.length;