Search in sources :

Example 16 with ActivityInfo

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

the class InputManagerService method visitKeyboardLayout.

private void visitKeyboardLayout(String keyboardLayoutDescriptor, KeyboardLayoutVisitor visitor) {
    KeyboardLayoutDescriptor d = KeyboardLayoutDescriptor.parse(keyboardLayoutDescriptor);
    if (d != null) {
        final PackageManager pm = mContext.getPackageManager();
        try {
            ActivityInfo receiver = pm.getReceiverInfo(new ComponentName(d.packageName, d.receiverName), PackageManager.GET_META_DATA);
            visitKeyboardLayoutsInPackage(pm, receiver, d.keyboardLayoutName, visitor);
        } catch (NameNotFoundException ex) {
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ComponentName(android.content.ComponentName)

Example 17 with ActivityInfo

use of android.content.pm.ActivityInfo 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 18 with ActivityInfo

use of android.content.pm.ActivityInfo 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 19 with ActivityInfo

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

the class UsbSettingsManager method handlePackageUpdate.

// Check to see if the package supports any USB devices or accessories.
// If so, clear any non-matching preferences for matching devices/accessories.
private void handlePackageUpdate(String packageName) {
    synchronized (mLock) {
        PackageInfo info;
        boolean changed = false;
        try {
            info = mPackageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);
        } catch (NameNotFoundException e) {
            Slog.e(TAG, "handlePackageUpdate could not find package " + packageName, e);
            return;
        }
        ActivityInfo[] activities = info.activities;
        if (activities == null)
            return;
        for (int i = 0; i < activities.length; i++) {
            // check for meta-data, both for devices and accessories
            if (handlePackageUpdateLocked(packageName, activities[i], UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
                changed = true;
            }
            if (handlePackageUpdateLocked(packageName, activities[i], UsbManager.ACTION_USB_ACCESSORY_ATTACHED)) {
                changed = true;
            }
        }
        if (changed) {
            writeSettingsLocked();
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo)

Example 20 with ActivityInfo

use of android.content.pm.ActivityInfo 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)

Aggregations

ActivityInfo (android.content.pm.ActivityInfo)886 ResolveInfo (android.content.pm.ResolveInfo)360 Intent (android.content.Intent)339 ComponentName (android.content.ComponentName)324 PackageManager (android.content.pm.PackageManager)215 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)141 ArrayList (java.util.ArrayList)139 ApplicationInfo (android.content.pm.ApplicationInfo)115 Test (org.junit.Test)113 RemoteException (android.os.RemoteException)82 Bundle (android.os.Bundle)68 PendingIntent (android.app.PendingIntent)62 Drawable (android.graphics.drawable.Drawable)61 IOException (java.io.IOException)60 PackageInfo (android.content.pm.PackageInfo)59 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)54 XmlResourceParser (android.content.res.XmlResourceParser)43 Point (android.graphics.Point)35 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)34 Context (android.content.Context)33