SearchManagerServicepublic class SearchManagerService extends ISearchManager.Stub The search manager service handles the search UI, and maintains a registry of searchable
activities. |
Fields Summary |
---|
private static final String | TAG | private final android.content.Context | mContext | private final android.util.SparseArray | mSearchables |
Constructors Summary |
---|
public SearchManagerService(android.content.Context context)Initializes the Search Manager service in the provided system context.
Only one instance of this object should be created!
mContext = context;
IntentFilter filter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
mContext.registerReceiver(new BootCompletedReceiver(), filter);
mContext.registerReceiver(new UserReceiver(),
new IntentFilter(Intent.ACTION_USER_REMOVED));
new MyPackageMonitor().register(context, null, UserHandle.ALL, true);
|
Methods Summary |
---|
public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
synchronized (mSearchables) {
for (int i = 0; i < mSearchables.size(); i++) {
ipw.print("\nUser: "); ipw.println(mSearchables.keyAt(i));
ipw.increaseIndent();
mSearchables.valueAt(i).dump(fd, ipw, args);
ipw.decreaseIndent();
}
}
| public android.content.ComponentName | getAssistIntent(int userHandle)
try {
userHandle = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userHandle, true, false, "getAssistIntent", null);
IPackageManager pm = AppGlobals.getPackageManager();
Intent assistIntent = new Intent(Intent.ACTION_ASSIST);
ResolveInfo info =
pm.resolveIntent(assistIntent,
assistIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DEFAULT_ONLY, userHandle);
if (info != null) {
return new ComponentName(
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name);
}
} catch (RemoteException re) {
// Local call
Log.e(TAG, "RemoteException in getAssistIntent: " + re);
} catch (Exception e) {
Log.e(TAG, "Exception in getAssistIntent: " + e);
}
return null;
| public java.util.List | getGlobalSearchActivities()
return getSearchables(UserHandle.getCallingUserId()).getGlobalSearchActivities();
| public android.content.ComponentName | getGlobalSearchActivity()Gets the name of the global search activity.
return getSearchables(UserHandle.getCallingUserId()).getGlobalSearchActivity();
| public android.app.SearchableInfo | getSearchableInfo(android.content.ComponentName launchActivity)Returns the SearchableInfo for a given activity.
if (launchActivity == null) {
Log.e(TAG, "getSearchableInfo(), activity == null");
return null;
}
return getSearchables(UserHandle.getCallingUserId()).getSearchableInfo(launchActivity);
| private Searchables | getSearchables(int userId)
long origId = Binder.clearCallingIdentity();
try {
boolean userExists = ((UserManager) mContext.getSystemService(Context.USER_SERVICE))
.getUserInfo(userId) != null;
if (!userExists) return null;
} finally {
Binder.restoreCallingIdentity(origId);
}
synchronized (mSearchables) {
Searchables searchables = mSearchables.get(userId);
if (searchables == null) {
//Log.i(TAG, "Building list of searchable activities for userId=" + userId);
searchables = new Searchables(mContext, userId);
searchables.buildSearchableList();
mSearchables.append(userId, searchables);
}
return searchables;
}
| public java.util.List | getSearchablesInGlobalSearch()Returns a list of the searchable activities that can be included in global search.
return getSearchables(UserHandle.getCallingUserId()).getSearchablesInGlobalSearchList();
| public android.content.ComponentName | getWebSearchActivity()Gets the name of the web search activity.
return getSearchables(UserHandle.getCallingUserId()).getWebSearchActivity();
| public boolean | launchAssistAction(int requestType, java.lang.String hint, int userHandle)
ComponentName comp = getAssistIntent(userHandle);
if (comp == null) {
return false;
}
long ident = Binder.clearCallingIdentity();
try {
Intent intent = new Intent(Intent.ACTION_ASSIST);
intent.setComponent(comp);
IActivityManager am = ActivityManagerNative.getDefault();
return am.launchAssistIntent(intent, requestType, hint, userHandle);
} catch (RemoteException e) {
} finally {
Binder.restoreCallingIdentity(ident);
}
return true;
| private void | onUserRemoved(int userId)
if (userId != UserHandle.USER_OWNER) {
synchronized (mSearchables) {
mSearchables.remove(userId);
}
}
|
|