summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/search
diff options
context:
space:
mode:
authorAnonymous Coward <nobody@android.com>2009-08-20 17:53:27 -0700
committerAnonymous Coward <nobody@android.com>2009-08-21 12:47:14 -0700
commit081a136d259c02b2ab8ba773c38e404f7b3c3de4 (patch)
treedd6766ddccbd1c1d3c80d1ba87d5899290d71347 /core/java/android/server/search
parente97c2006bf7c391c933307e520a392e532aa5d6a (diff)
downloadframeworks_base-081a136d259c02b2ab8ba773c38e404f7b3c3de4.zip
frameworks_base-081a136d259c02b2ab8ba773c38e404f7b3c3de4.tar.gz
frameworks_base-081a136d259c02b2ab8ba773c38e404f7b3c3de4.tar.bz2
Remove third party support for Quick Search Box (aka global search).
- @hides relevant APIs - removes relevant javadoc - enforces that only system apps can participate note: general support is still there, will be easy to reenable when we are ready.
Diffstat (limited to 'core/java/android/server/search')
-rw-r--r--core/java/android/server/search/Searchables.java38
1 files changed, 30 insertions, 8 deletions
diff --git a/core/java/android/server/search/Searchables.java b/core/java/android/server/search/Searchables.java
index c615957..a2add73 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);
}
}
}
@@ -289,6 +292,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.
* @param component Name of the component to check and set as preferred.