Include user query in search intents

This change adds a new intent extra field USER_QUERY set in intents
launched by the search dialog. It contains the query as typed by
the user, unaffected by query jamming or search suggestions.

Fixes http://b/issue?id=1939592
diff --git a/api/current.xml b/api/current.xml
index f5bcb5c..658a87c 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -23852,6 +23852,17 @@
  visibility="public"
 >
 </field>
+<field name="USER_QUERY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;user_query&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <interface name="SearchManager.OnCancelListener"
  abstract="true"
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 6c7bcda..9b0cc39 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -1474,6 +1474,7 @@
         if (data != null) {
             intent.setData(data);
         }
+        intent.putExtra(SearchManager.USER_QUERY, mUserQuery);
         if (query != null) {
             intent.putExtra(SearchManager.QUERY, query);
         }
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index fd69ba4..e5ba6a4 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -1136,6 +1136,20 @@
     public final static String QUERY = "query";
 
     /**
+     * Intent extra data key: Use this key with
+     * {@link android.content.Intent#getStringExtra
+     *  content.Intent.getStringExtra()}
+     * to obtain the query string typed in by the user.
+     * This may be different from the value of {@link #QUERY}
+     * if the intent is the result of selecting a suggestion.
+     * In that case, {@link #QUERY} will contain the value of
+     * {@link #SUGGEST_COLUMN_QUERY} for the suggestion, and
+     * {@link #USER_QUERY} will contain the string typed by the
+     * user.
+     */
+    public final static String USER_QUERY = "user_query";
+
+    /**
      * Intent extra data key: Use this key with Intent.ACTION_SEARCH and
      * {@link android.content.Intent#getBundleExtra
      *  content.Intent.getBundleExtra()}