Once an application is configured to provide search suggestions, those same suggestions can - * easily be made available to the system-wide Quick Search Box, providing faster access to its - * content from on central prominent place. See - * Exposing Search Suggestions to Quick Search - * Box for more details. - * *
The primary form of suggestions is known as queried suggestions and is based on query * text that the user has already typed. This would generally be based on partial matches in * the available data. In certain situations - for example, when no query text has been typed yet - @@ -489,26 +481,6 @@ import java.util.List; * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}, optional otherwise. * * - *
Once your application is setup to provide search suggestions, making them available to the - * globally accessable Quick Search Box is as easy as setting android:includeInGlobalSearch to - * "true" in your searchable metadata file. Beyond that, here are some more details of how - * suggestions interact with Quick Search Box, and optional ways that you may customize suggestions - * for your application. - * - *
Source Ranking: Once your application's search results are made available to Quick - * Search Box, how they surface to the user for a particular query will depend on how many - * other apps have results for that query, and how often the user has clicked on your results - * compared to the other apps'. The apps with the best track record within Quick Search - * Box will get queried earlier and have a better chance of showing their results in the top few - * slots. If there are more results than can be displayed to the user within a screen or two, the - * results may spill into a "more results" section that groups the remaining results by - * source. The newest apps with little usage information are given middle of the road positioning - * until enough usage information is available to rank it as usual. The exact formula for ranking - * the results is not set in stone, but suffice it is to say that providing quality results will - * increase the likelihood that your app's suggestions are provided in a prominent position, and - * apps that provide lower quality suggestions will be more likely to be pushed into the spillover - * area. - * - *
Search Settings: Each app that is available to Quick Search Box has an entry in the - * system settings where the user can enable or disable the inclusion of its results. Below the - * name of the application, each application may provide a brief description of what kind of - * information will be made available via a search settings description string pointed to by the - * android:searchSettingsDescription attribute in the searchable metadata. - * - *
Shortcuts: Suggestions that are clicked on by the user are automatically made into - * shortcuts, or, copied so they can quickly be displayed to the user before querying any of - * the sources. Thereafter, the shortcutted suggestion will be displayed for the query that yielded - * the suggestion and for any prefixes of that query. When multiple shortcuts are made available - * for a given query, they are ranked based on recency and the number of clicks they have received. - * You can control how your suggestions are made into shortcuts, and whether they are refreshed, - * using the {@link #SUGGEST_COLUMN_SHORTCUT_ID} column: - *
Elements of search metadata that configure search suggestions being available to Quick Search - * Box: - *
| Attribute | Description | Required? |
|---|---|---|
| android:includeInGlobalSearch | - *If true, indicates the search suggestions provided by your application should be - * included in the globally accessible Quick Search Box. The attributes below are only - * applicable if this is set to true. | - *Yes | - *
| android:searchSettingsDescription | - *If provided, provides a brief description of the search suggestions that are provided - * by your application to Quick Search Box, and will be displayed in the search settings - * entry for your application. | - *No | - *
| android:queryAfterZeroResults | - *Indicates whether a source should be invoked for supersets of queries it has - * returned zero results for in the past. For example, if a source returned zero - * results for "bo", it would be ignored for "bob". If set to false, this source - * will only be ignored for a single session; the next time the search dialog is - * invoked, all sources will be queried. The default value is false. | - *No | - *
| android:searchSuggestThreshold | - *Indicates the minimum number of characters needed to trigger a source from Quick - * Search Box. Only guarantees that a source will not be queried for anything shorter - * than the threshold. The default value is 0. | - *No | - *
Additional metadata for search action keys. For each action key that you would like to
* define, you'll need to add an additional element defining that key, and using the attributes
* discussed in Action Keys. A simple example is shown here:
@@ -1369,12 +1247,16 @@ public class SearchManager
* result indicates the shortcut refers to a no longer valid sugggestion.
*
* @see #SUGGEST_COLUMN_SHORTCUT_ID
+ *
+ * @hide pending enabling of global search for third parties
*/
public final static String SUGGEST_URI_PATH_SHORTCUT = "search_suggest_shortcut";
/**
* MIME type for shortcut validation. You'll use this in your suggestions content provider
* in the getType() function.
+ *
+ * @hide pending enabling of global search for third parties
*/
public final static String SHORTCUT_MIME_TYPE =
"vnd.android.cursor.item/vnd.android.search.suggest";
@@ -1387,7 +1269,7 @@ public class SearchManager
* In addition to the columns below, the suggestion columns are used to pass along the full
* suggestion so it can be shortcutted.
*
- * @hide
+ * @hide an implementation detail not part of the public api
*/
public final static String SEARCH_CLICK_REPORT_AUTHORITY =
"com.android.globalsearch.stats";
@@ -1395,21 +1277,21 @@ public class SearchManager
/**
* The path the write goes to.
*
- * @hide
+ * @hide an implementation detail not part of the public api
*/
public final static String SEARCH_CLICK_REPORT_URI_PATH = "click";
/**
* The column storing the query for the click.
*
- * @hide
+ * @hide an implementation detail not part of the public api
*/
public final static String SEARCH_CLICK_REPORT_COLUMN_QUERY = "query";
/**
* The column storing the component name of the application that was pivoted into.
*
- * @hide
+ * @hide an implementation detail not part of the public api
*/
public final static String SEARCH_CLICK_REPORT_COLUMN_COMPONENT = "component";
@@ -1494,7 +1376,7 @@ public class SearchManager
* {@link #COMPONENT_NAME_KEY}. For use by the global search system only - if other providers
* attempt to use this column, the value will be overwritten by global search.
*
- * @hide
+ * @hide an implementation detail not part of the public api
*/
public final static String SUGGEST_COLUMN_INTENT_COMPONENT_NAME = "suggest_intent_component";
/**
@@ -1519,6 +1401,8 @@ public class SearchManager
* {@link #SUGGEST_NEVER_MAKE_SHORTCUT}, the result will not be stored as a shortcut.
* Otherwise, the shortcut id will be used to check back for an up to date suggestion using
* {@link #SUGGEST_URI_PATH_SHORTCUT}.
+ *
+ * @hide pending reenabling of global search for third parties
*/
public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id";
@@ -1527,7 +1411,7 @@ public class SearchManager
* cursor item's background color if it needs a non-default background color. A non-zero value
* indicates a valid background color to override the default.
*
- * @hide For internal use, not part of the public API.
+ * @hide an implementation detail not part of the public api
*/
public final static String SUGGEST_COLUMN_BACKGROUND_COLOR = "suggest_background_color";
@@ -1535,6 +1419,8 @@ public class SearchManager
* Column name for suggestions cursor. Optional. This column is used to specify
* that a spinner should be shown in lieu of an icon2 while the shortcut of this suggestion
* is being refreshed.
+ *
+ * @hide pending reenabling of global search for third parties
*/
public final static String SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING =
"suggest_spinner_while_refreshing";
@@ -1542,6 +1428,8 @@ public class SearchManager
/**
* Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion
* should not be stored as a shortcut in global search.
+ *
+ * @hide pending reenabling of global search for third parties
*/
public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1";
@@ -1588,6 +1476,8 @@ public class SearchManager
* Intent action for starting a web search provider's settings activity.
* Web search providers should handle this intent if they have provider-specific
* settings to implement.
+ *
+ * @hide implementation detail only relevent to web search providers
*/
public final static String INTENT_ACTION_WEB_SEARCH_SETTINGS
= "android.search.action.WEB_SEARCH_SETTINGS";
@@ -1602,8 +1492,7 @@ public class SearchManager
/**
* Intent action broadcasted to inform that the search settings have changed in some way.
- * Either searchables have been enabled or disabled, or a different web search provider
- * has been chosen.
+ * Either searchables have been enabled or disabled.
*/
public final static String INTENT_ACTION_SEARCH_SETTINGS_CHANGED
= "android.search.action.SETTINGS_CHANGED";
@@ -1612,7 +1501,7 @@ public class SearchManager
* If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION},
* the search dialog will take no action.
*
- * @hide
+ * @hide an implentation detail not part of the public api
*/
public final static String INTENT_ACTION_NONE = "android.search.action.ZILCH";
diff --git a/core/java/android/server/search/Searchables.java b/core/java/android/server/search/Searchables.java
index c615957367231..a2add73dc3b08 100644
--- a/core/java/android/server/search/Searchables.java
+++ b/core/java/android/server/search/Searchables.java
@@ -26,6 +26,7 @@ import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import android.util.Log;
@@ -230,14 +231,16 @@ public class Searchables {
: webSearchInfoList.get(ii - search_count);
ActivityInfo ai = info.activityInfo;
// Check first to avoid duplicate entries.
- if (newSearchablesMap.get(new ComponentName(ai.packageName, ai.name)) == null) {
- SearchableInfo searchable = SearchableInfo.getActivityMetaData(mContext, ai);
- if (searchable != null) {
- newSearchablesList.add(searchable);
- newSearchablesMap.put(searchable.getSearchActivity(), searchable);
- if (searchable.shouldIncludeInGlobalSearch()) {
- newSearchablesInGlobalSearchList.add(searchable);
- }
+ if (newSearchablesMap.containsKey(new ComponentName(ai.packageName, ai.name))) {
+ continue;
+ }
+ SearchableInfo searchable = SearchableInfo.getActivityMetaData(mContext, ai);
+ if (searchable != null) {
+ newSearchablesList.add(searchable);
+ newSearchablesMap.put(searchable.getSearchActivity(), searchable);
+ if (searchable.shouldIncludeInGlobalSearch()
+ && isWhitelistedForGlobalSearch(pm, searchable.getSearchActivity())) {
+ newSearchablesInGlobalSearchList.add(searchable);
}
}
}
@@ -288,6 +291,25 @@ public class Searchables {
}
}
+ /**
+ * Determines whether an activity may be included in quick search box. For now this is
+ * restricted to system installed apps.
+ *
+ * TODO: remove when we are ready to enable global search for third party applications.
+ *
+ * @param pm The package manager.
+ * @param searchActivity The component of the search activity.
+ * @return True if the search activity may include its search suggestions in quick search box.
+ */
+ private boolean isWhitelistedForGlobalSearch(PackageManager pm, ComponentName searchActivity) {
+ try {
+ ActivityInfo ai = pm.getActivityInfo(searchActivity, 0);
+ return ((ai.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
/**
* Checks if the given activity component is present in the system and if so makes it the
* preferred activity for handling ACTION_WEB_SEARCH.
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 729b1db5c4992..403d07d12db17 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2920,16 +2920,16 @@
when the user clicks a suggestion. Optional attribute. -->
false. Optional attribute..-->