Search in sources :

Example 86 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class DefaultPermissionGrantPolicy method getDefaultSystemHandlerServicePackageLPr.

private PackageParser.Package getDefaultSystemHandlerServicePackageLPr(Intent intent, int userId) {
    List<ResolveInfo> handlers = mService.queryIntentServices(intent, intent.resolveType(mService.mContext.getContentResolver()), DEFAULT_FLAGS, userId).getList();
    if (handlers == null) {
        return null;
    }
    final int handlerCount = handlers.size();
    for (int i = 0; i < handlerCount; i++) {
        ResolveInfo handler = handlers.get(i);
        PackageParser.Package handlerPackage = getSystemPackageLPr(handler.serviceInfo.packageName);
        if (handlerPackage != null) {
            return handlerPackage;
        }
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageParser(android.content.pm.PackageParser)

Example 87 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class ZenModeHelper method getServiceInfo.

private ServiceInfo getServiceInfo(ComponentName owner) {
    Intent queryIntent = new Intent();
    queryIntent.setComponent(owner);
    List<ResolveInfo> installedServices = mPm.queryIntentServicesAsUser(queryIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, UserHandle.getCallingUserId());
    if (installedServices != null) {
        for (int i = 0, count = installedServices.size(); i < count; i++) {
            ResolveInfo resolveInfo = installedServices.get(i);
            ServiceInfo info = resolveInfo.serviceInfo;
            if (mServiceConfig.bindPermission.equals(info.permission)) {
                return info;
            }
        }
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) Intent(android.content.Intent)

Example 88 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class TrustManagerService method maybeEnableFactoryTrustAgents.

private void maybeEnableFactoryTrustAgents(LockPatternUtils utils, int userId) {
    if (0 != Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.TRUST_AGENTS_INITIALIZED, 0, userId)) {
        return;
    }
    PackageManager pm = mContext.getPackageManager();
    List<ResolveInfo> resolveInfos = resolveAllowedTrustAgents(pm, userId);
    ArraySet<ComponentName> discoveredAgents = new ArraySet<>();
    for (ResolveInfo resolveInfo : resolveInfos) {
        ComponentName componentName = getComponentName(resolveInfo);
        int applicationInfoFlags = resolveInfo.serviceInfo.applicationInfo.flags;
        if ((applicationInfoFlags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            Log.i(TAG, "Leaving agent " + componentName + " disabled because package " + "is not a system package.");
            continue;
        }
        discoveredAgents.add(componentName);
    }
    List<ComponentName> previouslyEnabledAgents = utils.getEnabledTrustAgents(userId);
    if (previouslyEnabledAgents != null) {
        discoveredAgents.addAll(previouslyEnabledAgents);
    }
    utils.setEnabledTrustAgents(discoveredAgents, userId);
    Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.TRUST_AGENTS_INITIALIZED, 1, userId);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ArraySet(android.util.ArraySet) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Example 89 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

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 90 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class Searchables method updateSearchableList.

/**
     * Builds an entire list (suitable for display) of
     * activities that are searchable, by iterating the entire set of
     * ACTION_SEARCH & ACTION_WEB_SEARCH intents.
     *
     * Also clears the hash of all activities -> searches which will
     * refill as the user clicks "search".
     *
     * This should only be done at startup and again if we know that the
     * list has changed.
     *
     * TODO: every activity that provides a ACTION_SEARCH intent should
     * also provide searchability meta-data.  There are a bunch of checks here
     * that, if data is not found, silently skip to the next activity.  This
     * won't help a developer trying to figure out why their activity isn't
     * showing up in the list, but an exception here is too rough.  I would
     * like to find a better notification mechanism.
     *
     * TODO: sort the list somehow?  UI choice.
     */
public void updateSearchableList() {
    // These will become the new values at the end of the method
    HashMap<ComponentName, SearchableInfo> newSearchablesMap = new HashMap<ComponentName, SearchableInfo>();
    ArrayList<SearchableInfo> newSearchablesList = new ArrayList<SearchableInfo>();
    ArrayList<SearchableInfo> newSearchablesInGlobalSearchList = new ArrayList<SearchableInfo>();
    // Use intent resolver to generate list of ACTION_SEARCH & ACTION_WEB_SEARCH receivers.
    List<ResolveInfo> searchList;
    final Intent intent = new Intent(Intent.ACTION_SEARCH);
    long ident = Binder.clearCallingIdentity();
    try {
        searchList = queryIntentActivities(intent, PackageManager.GET_META_DATA | PackageManager.MATCH_DEBUG_TRIAGED_MISSING);
        List<ResolveInfo> webSearchInfoList;
        final Intent webSearchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
        webSearchInfoList = queryIntentActivities(webSearchIntent, PackageManager.GET_META_DATA | PackageManager.MATCH_DEBUG_TRIAGED_MISSING);
        // analyze each one, generate a Searchables record, and record
        if (searchList != null || webSearchInfoList != null) {
            int search_count = (searchList == null ? 0 : searchList.size());
            int web_search_count = (webSearchInfoList == null ? 0 : webSearchInfoList.size());
            int count = search_count + web_search_count;
            for (int ii = 0; ii < count; ii++) {
                // for each component, try to find metadata
                ResolveInfo info = (ii < search_count) ? searchList.get(ii) : webSearchInfoList.get(ii - search_count);
                ActivityInfo ai = info.activityInfo;
                // Check first to avoid duplicate entries.
                if (newSearchablesMap.get(new ComponentName(ai.packageName, ai.name)) == null) {
                    SearchableInfo searchable = SearchableInfo.getActivityMetaData(mContext, ai, mUserId);
                    if (searchable != null) {
                        newSearchablesList.add(searchable);
                        newSearchablesMap.put(searchable.getSearchActivity(), searchable);
                        if (searchable.shouldIncludeInGlobalSearch()) {
                            newSearchablesInGlobalSearchList.add(searchable);
                        }
                    }
                }
            }
        }
        List<ResolveInfo> newGlobalSearchActivities = findGlobalSearchActivities();
        // Find the global search activity
        ComponentName newGlobalSearchActivity = findGlobalSearchActivity(newGlobalSearchActivities);
        // Find the web search activity
        ComponentName newWebSearchActivity = findWebSearchActivity(newGlobalSearchActivity);
        // Store a consistent set of new values
        synchronized (this) {
            mSearchablesMap = newSearchablesMap;
            mSearchablesList = newSearchablesList;
            mSearchablesInGlobalSearchList = newSearchablesInGlobalSearchList;
            mGlobalSearchActivities = newGlobalSearchActivities;
            mCurrentGlobalSearchActivity = newGlobalSearchActivity;
            mWebSearchActivity = newWebSearchActivity;
        }
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) HashMap(java.util.HashMap) SearchableInfo(android.app.SearchableInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)1211 Intent (android.content.Intent)760 PackageManager (android.content.pm.PackageManager)470 ComponentName (android.content.ComponentName)375 ActivityInfo (android.content.pm.ActivityInfo)209 ArrayList (java.util.ArrayList)205 PendingIntent (android.app.PendingIntent)159 RemoteException (android.os.RemoteException)137 ServiceInfo (android.content.pm.ServiceInfo)120 ApplicationInfo (android.content.pm.ApplicationInfo)73 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)53 Bundle (android.os.Bundle)47 HashMap (java.util.HashMap)46 IOException (java.io.IOException)43 HashSet (java.util.HashSet)43 Point (android.graphics.Point)42 ActivityNotFoundException (android.content.ActivityNotFoundException)38 PackageInfo (android.content.pm.PackageInfo)37 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)33