Search in sources :

Example 46 with PackageManager

use of android.content.pm.PackageManager in project platform_packages_apps_launcher by android.

the class LauncherModel method syncLocked.

private boolean syncLocked(Launcher launcher, String packageName) {
    final PackageManager packageManager = launcher.getPackageManager();
    final List<ResolveInfo> matches = findActivitiesForPackage(packageManager, packageName);
    if (matches.size() > 0) {
        final ApplicationsAdapter adapter = mApplicationsAdapter;
        // Find disabled activities and remove them from the adapter
        boolean removed = removeDisabledActivities(packageName, matches, adapter);
        // Find enable activities and add them to the adapter
        // Also updates existing activities with new labels/icons
        boolean added = addEnabledAndUpdateActivities(matches, adapter, launcher);
        return added || removed;
    }
    return false;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager)

Example 47 with PackageManager

use of android.content.pm.PackageManager in project platform_packages_apps_launcher by android.

the class Launcher method addLiveFolder.

static LiveFolderInfo addLiveFolder(Context context, Intent data, CellLayout.CellInfo cellInfo, boolean notify) {
    Intent baseIntent = data.getParcelableExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT);
    String name = data.getStringExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME);
    Drawable icon = null;
    boolean filtered = false;
    Intent.ShortcutIconResource iconResource = null;
    Parcelable extra = data.getParcelableExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON);
    if (extra != null && extra instanceof Intent.ShortcutIconResource) {
        try {
            iconResource = (Intent.ShortcutIconResource) extra;
            final PackageManager packageManager = context.getPackageManager();
            Resources resources = packageManager.getResourcesForApplication(iconResource.packageName);
            final int id = resources.getIdentifier(iconResource.resourceName, null, null);
            icon = resources.getDrawable(id);
        } catch (Exception e) {
            w(LOG_TAG, "Could not load live folder icon: " + extra);
        }
    }
    if (icon == null) {
        icon = context.getResources().getDrawable(R.drawable.ic_launcher_folder);
    }
    final LiveFolderInfo info = new LiveFolderInfo();
    info.icon = icon;
    info.filtered = filtered;
    info.title = name;
    info.iconResource = iconResource;
    info.uri = data.getData();
    info.baseIntent = baseIntent;
    info.displayMode = data.getIntExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_GRID);
    LauncherModel.addItemToDatabase(context, info, LauncherSettings.Favorites.CONTAINER_DESKTOP, cellInfo.screen, cellInfo.cellX, cellInfo.cellY, notify);
    sModel.addFolder(info);
    return info;
}
Also used : PackageManager(android.content.pm.PackageManager) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Intent(android.content.Intent) Parcelable(android.os.Parcelable) Resources(android.content.res.Resources) FileNotFoundException(java.io.FileNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException) IOException(java.io.IOException)

Example 48 with PackageManager

use of android.content.pm.PackageManager in project platform_packages_apps_launcher by android.

the class Search method configureVoiceSearchButton.

/**
     * If appropriate & available, configure voice search
     * 
     * Note:  Because the home screen search widget is always web search, we only check for
     * getVoiceSearchLaunchWebSearch() modes.  We don't support the alternate form of app-specific
     * voice search.
     */
private void configureVoiceSearchButton() {
    // Enable the voice search button if there is an activity that can handle it
    PackageManager pm = getContext().getPackageManager();
    ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent, PackageManager.MATCH_DEFAULT_ONLY);
    boolean voiceSearchVisible = ri != null;
    // finally, set visible state of voice search button, as appropriate
    mVoiceButton.setVisibility(voiceSearchVisible ? View.VISIBLE : View.GONE);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager)

Example 49 with PackageManager

use of android.content.pm.PackageManager in project platform_packages_apps_launcher by android.

the class LauncherModel method updateShortcutLabels.

private static void updateShortcutLabels(ContentResolver resolver, PackageManager manager) {
    final Cursor c = resolver.query(LauncherSettings.Favorites.CONTENT_URI, new String[] { LauncherSettings.Favorites._ID, LauncherSettings.Favorites.TITLE, LauncherSettings.Favorites.INTENT, LauncherSettings.Favorites.ITEM_TYPE }, null, null, null);
    final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
    final int intentIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT);
    final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
    final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
    try {
        while (c.moveToNext()) {
            try {
                if (c.getInt(itemTypeIndex) != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
                    continue;
                }
                final String intentUri = c.getString(intentIndex);
                if (intentUri != null) {
                    final Intent shortcut = Intent.parseUri(intentUri, 0);
                    if (Intent.ACTION_MAIN.equals(shortcut.getAction())) {
                        final ComponentName name = shortcut.getComponent();
                        if (name != null) {
                            final ActivityInfo activityInfo = manager.getActivityInfo(name, 0);
                            final String title = c.getString(titleIndex);
                            String label = getLabel(manager, activityInfo);
                            if (title == null || !title.equals(label)) {
                                final ContentValues values = new ContentValues();
                                values.put(LauncherSettings.Favorites.TITLE, label);
                                resolver.update(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values, "_id=?", new String[] { String.valueOf(c.getLong(idIndex)) });
                            // changed = true;
                            }
                        }
                    }
                }
            } catch (URISyntaxException e) {
            // Ignore
            } catch (PackageManager.NameNotFoundException e) {
            // Ignore
            }
        }
    } finally {
        c.close();
    }
// if (changed) resolver.notifyChange(Settings.Favorites.CONTENT_URI, null);
}
Also used : ContentValues(android.content.ContentValues) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName) URISyntaxException(java.net.URISyntaxException) Cursor(android.database.Cursor)

Example 50 with PackageManager

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

the class InputManagerService method visitAllKeyboardLayouts.

private void visitAllKeyboardLayouts(KeyboardLayoutVisitor visitor) {
    final PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(InputManager.ACTION_QUERY_KEYBOARD_LAYOUTS);
    for (ResolveInfo resolveInfo : pm.queryBroadcastReceivers(intent, PackageManager.GET_META_DATA | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE)) {
        final ActivityInfo activityInfo = resolveInfo.activityInfo;
        final int priority = resolveInfo.priority;
        visitKeyboardLayoutsInPackage(pm, activityInfo, null, priority, visitor);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Aggregations

PackageManager (android.content.pm.PackageManager)1482 Intent (android.content.Intent)505 ResolveInfo (android.content.pm.ResolveInfo)460 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)353 PackageInfo (android.content.pm.PackageInfo)270 ApplicationInfo (android.content.pm.ApplicationInfo)253 ComponentName (android.content.ComponentName)241 ArrayList (java.util.ArrayList)158 ActivityInfo (android.content.pm.ActivityInfo)140 IOException (java.io.IOException)127 RemoteException (android.os.RemoteException)105 Drawable (android.graphics.drawable.Drawable)94 IPackageManager (android.content.pm.IPackageManager)93 Resources (android.content.res.Resources)91 PendingIntent (android.app.PendingIntent)75 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Context (android.content.Context)68 Bundle (android.os.Bundle)60 HashMap (java.util.HashMap)55 ServiceInfo (android.content.pm.ServiceInfo)48