Merge tag 'android-11.0.0_r32' into r

Android 11.0.0 Release 32 (RQ2A.210305.006)

Change-Id: Id4ebb87f6f134ab08b8316e0270d1232de48ba2b
diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml
index 5f621cd..82b1e11 100644
--- a/res/layout/search_panel.xml
+++ b/res/layout/search_panel.xml
@@ -25,16 +25,15 @@
         android:id="@+id/search_bar_container"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/search_panel_background"
+        android:background="?android:attr/colorPrimary"
         android:elevation="4dp">
         <androidx.cardview.widget.CardView
             android:id="@+id/search_bar"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_margin="@dimen/search_bar_margin"
-            app:cardCornerRadius="2dp"
-            app:cardBackgroundColor="?android:attr/colorBackground"
-            app:cardElevation="2dp">
+            app:cardCornerRadius="@*android:dimen/config_dialogCornerRadius"
+            app:cardElevation="3dp">
             <Toolbar
                 android:id="@+id/search_toolbar"
                 android:layout_width="match_parent"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
new file mode 100644
index 0000000..399913a
--- /dev/null
+++ b/res/values-night/colors.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+    <color name="search_panel_background">@*android:color/material_grey_800</color>
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index a2105f0..632c72d 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -18,5 +18,5 @@
 <resources>
     <color name="launcher_background_color">#ff008577</color>
 
-    <color name="search_panel_background">#f2f2f2</color>
+    <color name="search_panel_background">@android:color/white</color>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 8a40eb6..9491650 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -26,8 +26,8 @@
     <!-- The following two margins need to match, with the caveat that
      the second should be negative. The second one ensures that the icons and text
      align despite the additional padding caused by the search bar's card background. -->
-    <dimen name="search_bar_margin">8dp</dimen>
-    <dimen name="search_bar_negative_margin">-8dp</dimen>
+    <dimen name="search_bar_margin">16dp</dimen>
+    <dimen name="search_bar_negative_margin">-16dp</dimen>
 
     <dimen name="search_bar_height">48dp</dimen>
     <dimen name="search_bar_text_size">16dp</dimen>
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/indexing/IndexDatabaseHelper.java b/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java
index cc90d21..b665fc3 100644
--- a/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java
+++ b/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java
@@ -288,7 +288,7 @@
      */
     static void setIndexed(Context context, List<ResolveInfo> providers) {
         final String localeStr = Locale.getDefault().toString();
-        final String fingerprint = Build.FINGERPRINT;
+        final String fingerprint = Build.VERSION.INCREMENTAL;
         final String providerVersionedNames =
                 IndexDatabaseHelper.buildProviderVersionedNames(context, providers);
         context.getSharedPreferences(SHARED_PREFS_TAG, Context.MODE_PRIVATE)
@@ -309,7 +309,7 @@
      */
     static boolean isFullIndex(Context context, List<ResolveInfo> providers) {
         final String localeStr = Locale.getDefault().toString();
-        final String fingerprint = Build.FINGERPRINT;
+        final String fingerprint = Build.VERSION.INCREMENTAL;
         final String providerVersionedNames =
                 IndexDatabaseHelper.buildProviderVersionedNames(context, providers);
         final SharedPreferences prefs = 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;