android.content.pm.PackageItemInfo Java Examples
The following examples show how to use
android.content.pm.PackageItemInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationPackageManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon( mContext.getResources(), itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #2
Source File: LoadPackagesAsyncTask.java From BarcodeEye with Apache License 2.0 | 6 votes |
@Override protected List<AppInfo> doInBackground(Void... objects) { List<AppInfo> labelsPackages = new ArrayList<AppInfo>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
Example #3
Source File: LoadPackagesAsyncTask.java From zxingfragmentlib with Apache License 2.0 | 6 votes |
@Override protected List<AppInfo> doInBackground(Object... objects) { List<AppInfo> labelsPackages = new ArrayList<>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
Example #4
Source File: ScanJob.java From android-beacon-library with Apache License 2.0 | 6 votes |
private static int getJobIdFromManifest(Context context, String name) { PackageItemInfo info = null; try { info = context.getPackageManager().getServiceInfo(new ComponentName(context, ScanJob.class), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { /* do nothing here */ } if (info != null && info.metaData != null && info.metaData.get(name) != null) { int jobId = info.metaData.getInt(name); LogManager.i(TAG, "Using "+name+" from manifest: "+jobId); return jobId; } else { throw new RuntimeException("Cannot get job id from manifest. " + "Make sure that the "+name+" is configured in the manifest for the ScanJob."); } }
Example #5
Source File: BluetoothTestJob.java From android-beacon-library with Apache License 2.0 | 6 votes |
/** * Returns the job id to be used to schedule this job. This may be set in the * AndroidManifest.xml or in single process applications by using #setOverrideJobId * @param context * @return */ public static int getJobId(Context context) { if (sOverrideJobId >= 0) { LogManager.i(TAG, "Using BluetoothTestJob JobId from static override: "+ sOverrideJobId); return sOverrideJobId; } PackageItemInfo info = null; try { info = context.getPackageManager().getServiceInfo(new ComponentName(context, BluetoothTestJob.class), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { /* do nothing here */ } if (info != null && info.metaData != null && info.metaData.get("jobId") != null) { int jobId = info.metaData.getInt("jobId"); LogManager.i(TAG, "Using BluetoothTestJob JobId from manifest: "+jobId); return jobId; } else { throw new RuntimeException("Cannot get job id from manifest. " + "Make sure that the BluetoothTestJob is configured in the manifest."); } }
Example #6
Source File: LoadPackagesAsyncTask.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override protected List<AppInfo> doInBackground(Object... objects) { List<AppInfo> labelsPackages = new ArrayList<>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
Example #7
Source File: LoadPackagesAsyncTask.java From weex with Apache License 2.0 | 6 votes |
@Override protected List<AppInfo> doInBackground(Object... objects) { List<AppInfo> labelsPackages = new ArrayList<>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
Example #8
Source File: LoadPackagesAsyncTask.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
@Override protected List<AppInfo> doInBackground(Object... objects) { List<AppInfo> labelsPackages = new ArrayList<>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
Example #9
Source File: LoadPackagesAsyncTask.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
@Override protected List<AppInfo> doInBackground(Object... objects) { List<AppInfo> labelsPackages = new ArrayList<>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
Example #10
Source File: IconDrawableFactory.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public Drawable getBadgedIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo, @UserIdInt int userId) { Drawable icon = mPm.loadUnbadgedItemIcon(itemInfo, appInfo); if (!mEmbedShadow && !needsBadging(appInfo, userId)) { return icon; } icon = getShadowedIcon(icon); if (appInfo.isInstantApp()) { int badgeColor = Resources.getSystem().getColor( com.android.internal.R.color.instant_app_badge, null); icon = mLauncherIcons.getBadgedDrawable(icon, com.android.internal.R.drawable.ic_instant_icon_badge_bolt, badgeColor); } if (mUm.isManagedProfile(userId)) { icon = mLauncherIcons.getBadgedDrawable(icon, com.android.internal.R.drawable.ic_corp_icon_badge_case, getUserBadgeColor(mUm, userId)); } return icon; }
Example #11
Source File: PackageManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private String loadText(PackageItemInfo pii, int res, CharSequence nonLocalized) throws RemoteException { if (nonLocalized != null) { return nonLocalized.toString(); } if (res != 0) { Resources r = getResources(pii); if (r != null) { try { return r.getString(res); } catch (Resources.NotFoundException e) { } } } return null; }
Example #12
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #13
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(@NonNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { // Indicates itemInfo is for a different user (e.g. a profile's parent), so use a // generic user icon (users generally lack permission to view each other's actual icons) int targetUserId = itemInfo.showUserIcon; return UserIcons.getDefaultUserIcon( mContext.getResources(), targetUserId, /* light= */ false); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null && itemInfo != appInfo && appInfo != null) { dr = loadUnbadgedItemIcon(appInfo, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #14
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #15
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #16
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #17
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #18
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #19
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon(itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #20
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * @hide */ public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { if (itemInfo.showUserIcon != UserHandle.USER_NULL) { Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon); if (bitmap == null) { return UserIcons.getDefaultUserIcon( mContext.getResources(), itemInfo.showUserIcon, /* light= */ false); } return new BitmapDrawable(bitmap); } Drawable dr = null; if (itemInfo.packageName != null) { dr = getDrawable(itemInfo.packageName, itemInfo.icon, appInfo); } if (dr == null) { dr = itemInfo.loadDefaultIcon(this); } return dr; }
Example #21
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * @hide */ public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo); if (itemInfo.showUserIcon != UserHandle.USER_NULL) { return dr; } return getUserBadgedIcon(dr, new UserHandle(getUserId())); }
Example #22
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * @hide */ public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo); if (itemInfo.showUserIcon != UserHandle.USER_NULL) { return dr; } return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId())); }
Example #23
Source File: BeaconService.java From android-beacon-library with Apache License 2.0 | 5 votes |
private String getManifestMetadataValue(String key) { String value = null; try { PackageItemInfo info = this.getPackageManager().getServiceInfo(new ComponentName(this, BeaconService.class), PackageManager.GET_META_DATA); if (info != null && info.metaData != null) { return info.metaData.get(key).toString(); } } catch (PackageManager.NameNotFoundException e) { } return null; }
Example #24
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * @hide */ public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo); if (itemInfo.showUserIcon != UserHandle.USER_NULL) { return dr; } return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId())); }
Example #25
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * @hide */ public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo); if (itemInfo.showUserIcon != UserHandle.USER_NULL) { return dr; } return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId())); }
Example #26
Source File: DynamicApkParser.java From Android-plugin-support with MIT License | 5 votes |
public Component(final ParseComponentArgs args, final ComponentInfo outInfo) { this(args, (PackageItemInfo)outInfo); if (args.outError[0] != null) { return; } if (args.processRes != 0) { CharSequence pname; if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { // pname = args.sa.getNonConfigurationString(args.processRes, // Configuration.NATIVE_CONFIG_VERSION); pname = args.sa.getNonResourceString(args.processRes); } else { // Some older apps have been seen to use a resource reference // here that on older builds was ignored (with a warning). We // need to continue to do this for them so they don't break. pname = args.sa.getNonResourceString(args.processRes); } outInfo.processName = buildProcessName(owner.applicationInfo.packageName, owner.applicationInfo.processName, pname, args.sepProcesses, args.outError); } if (args.descriptionRes != 0) { outInfo.descriptionRes = args.sa.getResourceId(args.descriptionRes, 0); } outInfo.enabled = args.sa.getBoolean(args.enabledRes, true); }
Example #27
Source File: DynamicApkParser.java From Android-plugin-support with MIT License | 5 votes |
private boolean parsePackageItemInfo(DynamicApkInfo owner, PackageItemInfo outInfo, String[] outError, String tag, TypedArray sa, int nameRes, int labelRes, int iconRes, int logoRes, int bannerRes) { String name = sa.getString(nameRes); if (name == null) { outError[0] = tag + " does not specify android:name"; return false; } outInfo.name = buildClassName(owner.applicationInfo.packageName, name, outError); if (outInfo.name == null) { return false; } int iconVal = sa.getResourceId(iconRes, 0); if (iconVal != 0) { outInfo.icon = iconVal; outInfo.nonLocalizedLabel = null; } int logoVal = sa.getResourceId(logoRes, 0); if (logoVal != 0) { outInfo.logo = logoVal; } int bannerVal = sa.getResourceId(bannerRes, 0); if (bannerVal != 0) { outInfo.banner = bannerVal; } TypedValue v = sa.peekValue(labelRes); if (v != null && (outInfo.labelRes=v.resourceId) == 0) { outInfo.nonLocalizedLabel = v.coerceToString(); } outInfo.packageName = owner.packageName; return true; }
Example #28
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * @hide */ public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo); if (itemInfo.showUserIcon != UserHandle.USER_NULL) { return dr; } return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId())); }
Example #29
Source File: AppSecurityPermissions.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void addPermToList(List<MyPermissionInfo> permList, MyPermissionInfo pInfo) { if (pInfo.mLabel == null) { pInfo.mLabel = pInfo.loadSafeLabel(mPm, 20000, PackageItemInfo.SAFE_LABEL_FLAG_TRIM | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE); } int idx = Collections.binarySearch(permList, pInfo, mPermComparator); if(localLOGV) Log.i(TAG, "idx="+idx+", list.size="+permList.size()); if (idx < 0) { idx = -idx-1; permList.add(idx, pInfo); } }
Example #30
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * @hide */ public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) { Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo); if (itemInfo.showUserIcon != UserHandle.USER_NULL) { return dr; } return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId())); }