/** Returns a high res icon for the given intent and user */ public synchronized Bitmap getIcon(Intent intent, UserHandleCompat user) { ComponentName component = intent.getComponent(); // null info means not installed, but if we have a component from the intent then // we should still look in the cache for restored app icons. if (component == null) { return getDefaultIcon(user); } LauncherActivityInfoCompat launcherActInfo = mLauncherApps.resolveActivity(intent, user); CacheEntry entry = cacheLocked(component, launcherActInfo, user, true, false /* useLowRes */); return entry.icon; }
/** Updates the entries related to the given package in memory and persistent DB. */ public synchronized void updateIconsForPkg(String packageName, UserHandleCompat user) { removeIconsForPkg(packageName, user); try { PackageInfo info = mPackageManager.getPackageInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); long userSerial = mUserManager.getSerialNumberForUser(user); for (LauncherActivityInfoCompat app : mLauncherApps.getActivityList(packageName, user)) { addIconToDBAndMemCache(app, info, userSerial); } } catch (NameNotFoundException e) { Log.d(TAG, "Package not found", e); return; } }
/** * Fill in {@param shortcutInfo} with the icon and label for {@param intent}. If the corresponding * activity is not found, it reverts to the package icon. */ public synchronized void getTitleAndIcon( ShortcutInfo shortcutInfo, Intent intent, UserHandleCompat user, boolean useLowResIcon) { ComponentName component = intent.getComponent(); // null info means not installed, but if we have a component from the intent then // we should still look in the cache for restored app icons. if (component == null) { shortcutInfo.setIcon(getDefaultIcon(user)); shortcutInfo.title = ""; shortcutInfo.usingFallbackIcon = true; shortcutInfo.usingLowResIcon = false; } else { LauncherActivityInfoCompat info = mLauncherApps.resolveActivity(intent, user); getTitleAndIcon(shortcutInfo, component, info, user, true, useLowResIcon); } }
public IconCache(Context context, InvariantDeviceProfile inv) { mContext = context; mPackageManager = context.getPackageManager(); mUserManager = UserManagerCompat.getInstance(mContext); mLauncherApps = LauncherAppsCompat.getInstance(mContext); mIconDpi = inv.fillResIconDpi; mIconDb = new IconDB(context); mWorkerHandler = new Handler(LauncherModel.getWorkerLooper()); mActivityBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color); mPackageBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color_dark); mLowResOptions = new BitmapFactory.Options(); // Always prefer RGB_565 config for low res. If the bitmap has transparency, it will // automatically be loaded as ALPHA_8888. mLowResOptions.inPreferredConfig = Bitmap.Config.RGB_565; updateSystemStateString(); }
public void updateDbIcons(Set<String> ignorePackagesForMainUser) { // Remove all active icon update tasks. mWorkerHandler.removeCallbacksAndMessages(ICON_UPDATE_TOKEN); updateSystemStateString(); for (UserHandleCompat user : mUserManager.getUserProfiles()) { // Query for the set of apps final List<LauncherActivityInfoCompat> apps = mLauncherApps.getActivityList(null, user); // Fail if we don't have any apps // TODO: Fix this. Only fail for the current user. if (apps == null || apps.isEmpty()) { return; } // Update icon cache. This happens in segments and {@link #onPackageIconsUpdated} // is called by the icon cache when the job is complete. updateDBIcons( user, apps, UserHandleCompat.myUserHandle().equals(user) ? ignorePackagesForMainUser : Collections.<String>emptySet()); } }