use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class UsbSettingsManager method getDeviceMatchesLocked.
private final ArrayList<ResolveInfo> getDeviceMatchesLocked(UsbDevice device, Intent intent) {
ArrayList<ResolveInfo> matches = new ArrayList<ResolveInfo>();
List<ResolveInfo> resolveInfos = mPackageManager.queryIntentActivities(intent, PackageManager.GET_META_DATA);
int count = resolveInfos.size();
for (int i = 0; i < count; i++) {
ResolveInfo resolveInfo = resolveInfos.get(i);
if (packageMatchesLocked(resolveInfo, intent.getAction(), device, null)) {
matches.add(resolveInfo);
}
}
return matches;
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class UsbSettingsManager method deviceAttached.
public void deviceAttached(UsbDevice device) {
Intent intent = new Intent(UsbManager.ACTION_USB_DEVICE_ATTACHED);
intent.putExtra(UsbManager.EXTRA_DEVICE, device);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ArrayList<ResolveInfo> matches;
String defaultPackage;
synchronized (mLock) {
matches = getDeviceMatchesLocked(device, intent);
// Launch our default activity directly, if we have one.
// Otherwise we will start the UsbResolverActivity to allow the user to choose.
defaultPackage = mDevicePreferenceMap.get(new DeviceFilter(device));
}
// Send broadcast to running activity with registered intent
mUserContext.sendBroadcast(intent);
// Start activity with registered intent
resolveActivity(intent, matches, defaultPackage, device, null);
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class Searchables method findWebSearchActivity.
/**
* Finds the web search activity.
*
* Only looks in the package of the global search activity.
*/
private ComponentName findWebSearchActivity(ComponentName globalSearchActivity) {
if (globalSearchActivity == null) {
return null;
}
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setPackage(globalSearchActivity.getPackageName());
List<ResolveInfo> activities = queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (activities != null && !activities.isEmpty()) {
ActivityInfo ai = activities.get(0).activityInfo;
// TODO: do some sanity checks here?
return new ComponentName(ai.packageName, ai.name);
}
Log.w(LOG_TAG, "No web search activity found");
return null;
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class Searchables method isInstalled.
/**
* Checks whether the global search provider with a given
* component name is installed on the system or not. This deals with
* cases such as the removal of an installed provider.
*/
private boolean isInstalled(ComponentName globalSearch) {
Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
intent.setComponent(globalSearch);
List<ResolveInfo> activities = queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (activities != null && !activities.isEmpty()) {
return true;
}
return false;
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class Searchables method findGlobalSearchActivities.
/**
* Returns a sorted list of installed search providers as per
* the following heuristics:
*
* (a) System apps are given priority over non system apps.
* (b) Among system apps and non system apps, the relative ordering
* is defined by their declared priority.
*/
private List<ResolveInfo> findGlobalSearchActivities() {
// Step 1 : Query the package manager for a list
// of activities that can handle the GLOBAL_SEARCH intent.
Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
List<ResolveInfo> activities = queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (activities != null && !activities.isEmpty()) {
// Step 2: Rank matching activities according to our heuristics.
Collections.sort(activities, GLOBAL_SEARCH_RANKER);
}
return activities;
}
Aggregations