Search in sources :

Example 41 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class PackageManagerService method matchComponentForVerifier.

private ComponentName matchComponentForVerifier(String packageName, List<ResolveInfo> receivers) {
    ActivityInfo targetReceiver = null;
    final int NR = receivers.size();
    for (int i = 0; i < NR; i++) {
        final ResolveInfo info = receivers.get(i);
        if (info.activityInfo == null) {
            continue;
        }
        if (packageName.equals(info.activityInfo.packageName)) {
            targetReceiver = info.activityInfo;
            break;
        }
    }
    if (targetReceiver == null) {
        return null;
    }
    return new ComponentName(targetReceiver.packageName, targetReceiver.name);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) ComponentName(android.content.ComponentName)

Example 42 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class PackageManagerService method queryIntentReceivers.

@Override
public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, int userId) {
    if (!sUserManager.exists(userId))
        return Collections.emptyList();
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (intent.getSelector() != null) {
            intent = intent.getSelector();
            comp = intent.getComponent();
        }
    }
    if (comp != null) {
        List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        ActivityInfo ai = getReceiverInfo(comp, flags, userId);
        if (ai != null) {
            ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mReceivers.queryIntent(intent, resolvedType, flags, userId);
        }
        final PackageParser.Package pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers, userId);
        }
        return null;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName)

Example 43 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class UsbSettingsManager method getAccessoryMatchesLocked.

private final ArrayList<ResolveInfo> getAccessoryMatchesLocked(UsbAccessory accessory, 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(), null, accessory)) {
            matches.add(resolveInfo);
        }
    }
    return matches;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ArrayList(java.util.ArrayList)

Example 44 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 45 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)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)2316 Intent (android.content.Intent)1476 PackageManager (android.content.pm.PackageManager)875 ComponentName (android.content.ComponentName)637 ArrayList (java.util.ArrayList)515 ActivityInfo (android.content.pm.ActivityInfo)360 Test (org.junit.Test)282 ServiceInfo (android.content.pm.ServiceInfo)203 PendingIntent (android.app.PendingIntent)183 ApplicationInfo (android.content.pm.ApplicationInfo)178 RemoteException (android.os.RemoteException)170 Context (android.content.Context)101 Bundle (android.os.Bundle)97 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)81 IOException (java.io.IOException)78 PackageInfo (android.content.pm.PackageInfo)68 HashSet (java.util.HashSet)65 HashMap (java.util.HashMap)63 ActivityNotFoundException (android.content.ActivityNotFoundException)59 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58