Update the target sdk version of SettingsIntelligence app. am: 0bd36f4890 am: 7667949ef1

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/SettingsIntelligence/+/12201631

Change-Id: Ia231f87de61561268a03bed1baabb52e7de52000
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/res/values/strings.xml b/res/values/strings.xml
index eb768f5..3445e51 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -19,6 +19,9 @@
     <!-- Applications settings title. If clicked, the user is taken to a screen full of application settings [CHAR_LIMIT=NONE BACKUP_MESSAGE_ID=5281808652705396152] -->
     <string name="applications_settings">App info</string>
 
+    <!-- Class name for AccessibilityServiceResult Task [CHAR_LIMIT=NONE]-->
+    <string name="accessibility_settings_classname">com.android.settings.accessibility.AccessibilitySettings</string>
+
     <!-- Settings title in main settings screen for accessibility settings [CHAR_LIMIT=NONE BACKUP_MESSAGE_ID=3975902491934816215] -->
     <string name="accessibility_settings">Accessibility</string>
 
diff --git a/src/com/android/settings/intelligence/search/SearchFragment.java b/src/com/android/settings/intelligence/search/SearchFragment.java
index 4642b16..c76eda3 100644
--- a/src/com/android/settings/intelligence/search/SearchFragment.java
+++ b/src/com/android/settings/intelligence/search/SearchFragment.java
@@ -344,9 +344,11 @@
         final Activity activity = getActivity();
         if (activity != null) {
             View view = activity.getCurrentFocus();
-            InputMethodManager imm = (InputMethodManager)
-                    activity.getSystemService(Context.INPUT_METHOD_SERVICE);
-            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+            if (view != null) {
+                InputMethodManager imm = (InputMethodManager)
+                        activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+            }
         }
 
         if (mResultsRecyclerView != null) {
diff --git a/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java b/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java
index cd7b4ad..d6de496 100644
--- a/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java
+++ b/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java
@@ -42,8 +42,6 @@
     public static final int QUERY_WORKER_ID = SettingsIntelligenceLogProto.SettingsIntelligenceEvent
             .SEARCH_QUERY_ACCESSIBILITY_SERVICES;
 
-    private static final String ACCESSIBILITY_SETTINGS_CLASSNAME =
-            "com.android.settings.accessibility.AccessibilitySettings";
     private static final int NAME_NO_MATCH = -1;
 
     private final AccessibilityManager mAccessibilityManager;
@@ -88,7 +86,8 @@
             final String componentName = new ComponentName(serviceInfo.packageName,
                     serviceInfo.name).flattenToString();
             final Intent intent = DatabaseIndexingUtils.buildSearchTrampolineIntent(mContext,
-                    ACCESSIBILITY_SETTINGS_CLASSNAME, componentName, screenTitle);
+                    mContext.getString(R.string.accessibility_settings_classname),
+                    componentName, screenTitle);
 
             results.add(new SearchResult.Builder()
                     .setTitle(title)
@@ -111,7 +110,7 @@
     private List<String> getBreadCrumb() {
         if (mBreadcrumb == null || mBreadcrumb.isEmpty()) {
             mBreadcrumb = mSiteMapManager.buildBreadCrumb(
-                    mContext, ACCESSIBILITY_SETTINGS_CLASSNAME,
+                    mContext, mContext.getString(R.string.accessibility_settings_classname),
                     mContext.getString(R.string.accessibility_settings));
         }
         return mBreadcrumb;
diff --git a/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java b/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
index a57f510..d6d865a 100644
--- a/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
+++ b/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
@@ -61,7 +61,7 @@
 
     private final int LONG_TITLE_LENGTH = 20;
 
-    private static final String[] whiteList = {
+    private static final String[] allowList = {
             "main_toggle_wifi",
             "main_toggle_bluetooth",
             "main_toggle_bluetooth_obsolete",
@@ -73,7 +73,7 @@
             "data_usage_enable",
             "button_roaming_key",
     };
-    private static final Set<String> prioritySettings = new HashSet(Arrays.asList(whiteList));
+    private static final Set<String> prioritySettings = new HashSet(Arrays.asList(allowList));
 
 
     public CursorToSearchResultConverter(Context context) {
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;