Search in sources :

Example 56 with ResolveInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ArrayList(java.util.ArrayList)

Example 57 with ResolveInfo

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);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 58 with ResolveInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 59 with ResolveInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent)

Example 60 with ResolveInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)1196 Intent (android.content.Intent)746 PackageManager (android.content.pm.PackageManager)458 ComponentName (android.content.ComponentName)375 ArrayList (java.util.ArrayList)204 ActivityInfo (android.content.pm.ActivityInfo)203 PendingIntent (android.app.PendingIntent)159 RemoteException (android.os.RemoteException)137 ServiceInfo (android.content.pm.ServiceInfo)120 ApplicationInfo (android.content.pm.ApplicationInfo)72 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)53 Bundle (android.os.Bundle)47 HashMap (java.util.HashMap)44 IOException (java.io.IOException)43 HashSet (java.util.HashSet)43 Point (android.graphics.Point)42 PackageInfo (android.content.pm.PackageInfo)37 ActivityNotFoundException (android.content.ActivityNotFoundException)33 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)33