SearchManagerServicepublic class SearchManagerService extends ISearchManager.Stub This is a simplified version of the Search Manager service. It no longer handles
presentation (UI). Its function is to maintain the map & list of "searchable"
items, which provides a mapping from individual activities (where a user might have
invoked search) to specific searchable activities (where the search will be dispatched). |
Fields Summary |
---|
private static final String | TAG | private static final boolean | DEBUG | private static final boolean | localLOGV | private static final boolean | IMMEDIATE_SEARCHABLES_UPDATE | private final android.content.Context | mContext | private final android.os.Handler | mHandler | private boolean | mSearchablesDirty | private android.content.BroadcastReceiver | mIntentReceiverListens for intent broadcasts.
The primary purpose here is to refresh the "searchables" list
if packages are added/removed. | private Runnable | mRunUpdateSearchableThis runnable (for the main handler / UI thread) will update the searchables list. |
Constructors Summary |
---|
public SearchManagerService(android.content.Context context)Initialize the Search Manager service in the provided system context.
Only one instance of this object should be created!
mContext = context;
mHandler = new Handler();
// Setup the infrastructure for updating and maintaining the list
// of searchable activities.
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
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.
if (IMMEDIATE_SEARCHABLES_UPDATE) {
mHandler.post(mRunUpdateSearchable);
}
|
Methods Summary |
---|
public SearchableInfo | getSearchableInfo(android.content.ComponentName launchActivity, boolean globalSearch)Return the searchableinfo for a given activity
// final check. however we should try to avoid this, because
// it slows down the entry into the UI.
if (mSearchablesDirty) {
updateSearchables();
}
SearchableInfo si = null;
if (globalSearch) {
si = SearchableInfo.getDefaultSearchable();
} else {
si = SearchableInfo.getSearchableInfo(mContext, launchActivity);
}
return si;
| private void | updateSearchables()Update the list of searchables, either at startup or in response to
a package add/remove broadcast message.
SearchableInfo.buildSearchableList(mContext);
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);
|
|