summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/search/SearchManagerService.java
diff options
context:
space:
mode:
authorKarl Rosaen <>2009-04-23 19:00:21 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-23 19:00:21 -0700
commit875d50a4b9294b2be33cff6493cae7acd1d07ea7 (patch)
tree48cc044c4719e53d214e5fa6c273d1ecd9078356 /core/java/android/server/search/SearchManagerService.java
parentb08971b876801d9cb878f3f0ca0ebfde7c9bea8e (diff)
downloadframeworks_base-875d50a4b9294b2be33cff6493cae7acd1d07ea7.zip
frameworks_base-875d50a4b9294b2be33cff6493cae7acd1d07ea7.tar.gz
frameworks_base-875d50a4b9294b2be33cff6493cae7acd1d07ea7.tar.bz2
AI 147564: Merge back from search branch to donut. Notes:
- all public apis and framework changes have been reviewed by relevant folks in our branch (e.g romainguy) - all new public apis are @hidden; they will still get reviewed by api council once we're in git - other than that, it's mostly GlobalSearch and search dialog stuff, a new apps provider, and some tweaks to the contacts provider that was reviewed by jham Automated import of CL 147564
Diffstat (limited to 'core/java/android/server/search/SearchManagerService.java')
-rw-r--r--core/java/android/server/search/SearchManagerService.java49
1 files changed, 29 insertions, 20 deletions
diff --git a/core/java/android/server/search/SearchManagerService.java b/core/java/android/server/search/SearchManagerService.java
index fe15553..eaace6b 100644
--- a/core/java/android/server/search/SearchManagerService.java
+++ b/core/java/android/server/search/SearchManagerService.java
@@ -22,8 +22,8 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Handler;
-import android.util.Config;
/**
* This is a simplified version of the Search Manager service. It no longer handles
@@ -36,7 +36,6 @@ public class SearchManagerService extends ISearchManager.Stub
// general debugging support
private static final String TAG = "SearchManagerService";
private static final boolean DEBUG = false;
- private static final boolean localLOGV = DEBUG ? Config.LOGD : Config.LOGV;
// configuration choices
private static final boolean IMMEDIATE_SEARCHABLES_UPDATE = true;
@@ -45,9 +44,10 @@ public class SearchManagerService extends ISearchManager.Stub
private final Context mContext;
private final Handler mHandler;
private boolean mSearchablesDirty;
+ private Searchables mSearchables;
/**
- * Initialize the Search Manager service in the provided system context.
+ * Initializes the Search Manager service in the provided system context.
* Only one instance of this object should be created!
*
* @param context to use for accessing DB, window manager, etc.
@@ -55,6 +55,8 @@ public class SearchManagerService extends ISearchManager.Stub
public SearchManagerService(Context context) {
mContext = context;
mHandler = new Handler();
+ mSearchablesDirty = true;
+ mSearchables = new Searchables(context);
// Setup the infrastructure for updating and maintaining the list
// of searchable activities.
@@ -64,7 +66,6 @@ public class SearchManagerService extends ISearchManager.Stub
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
- mSearchablesDirty = true;
// After startup settles down, preload the searchables list,
// which will reduce the delay when the search UI is invoked.
@@ -109,34 +110,41 @@ public class SearchManagerService extends ISearchManager.Stub
};
/**
- * Update the list of searchables, either at startup or in response to
+ * Updates the list of searchables, either at startup or in response to
* a package add/remove broadcast message.
*/
private void updateSearchables() {
- SearchableInfo.buildSearchableList(mContext);
+ mSearchables.buildSearchableList();
mSearchablesDirty = false;
- // TODO This is a hack. This shouldn't be hardcoded here, it's probably
- // a policy.
-// ComponentName defaultSearch = new ComponentName(
-// "com.android.contacts",
-// "com.android.contacts.ContactsListActivity" );
- ComponentName defaultSearch = new ComponentName(
- "com.android.googlesearch",
- "com.android.googlesearch.GoogleSearch" );
- SearchableInfo.setDefaultSearchable(mContext, defaultSearch);
+ // TODO SearchableInfo should be the source of truth about whether a searchable exists.
+ // As it stands, if the package exists but is misconfigured in some way, then this
+ // would fail, and needs to be fixed.
+ ComponentName defaultSearch = new ComponentName(
+ "com.android.globalsearch",
+ "com.android.globalsearch.GlobalSearch");
+
+ try {
+ mContext.getPackageManager().getActivityInfo(defaultSearch, 0);
+ } catch (NameNotFoundException e) {
+ defaultSearch = new ComponentName(
+ "com.android.googlesearch",
+ "com.android.googlesearch.GoogleSearch");
+ }
+
+ mSearchables.setDefaultSearchable(defaultSearch);
}
/**
- * Return the searchableinfo for a given activity
+ * Returns the SearchableInfo for a given activity
*
* @param launchActivity The activity from which we're launching this search.
- * @return Returns a SearchableInfo record describing the parameters of the search,
- * or null if no searchable metadata was available.
* @param globalSearch If false, this will only launch the search that has been specifically
* defined by the application (which is usually defined as a local search). If no default
* search is defined in the current application or activity, no search will be launched.
* If true, this will always launch a platform-global (e.g. web-based) search instead.
+ * @return Returns a SearchableInfo record describing the parameters of the search,
+ * or null if no searchable metadata was available.
*/
public SearchableInfo getSearchableInfo(ComponentName launchActivity, boolean globalSearch) {
// final check. however we should try to avoid this, because
@@ -146,11 +154,12 @@ public class SearchManagerService extends ISearchManager.Stub
}
SearchableInfo si = null;
if (globalSearch) {
- si = SearchableInfo.getDefaultSearchable();
+ si = mSearchables.getDefaultSearchable();
} else {
- si = SearchableInfo.getSearchableInfo(mContext, launchActivity);
+ si = mSearchables.getSearchableInfo(launchActivity);
}
return si;
}
+
}