/** * Array of all {@link android.R.styleable#AndroidManifestService * <service>} tags included under <application>, * or null if there were none. This is only filled in if the flag * {@link PackageManager#GET_SERVICES} was set. */ public ServiceInfo[] services;
@Override public PackageInfo getPackageInfo(String packageName, int flags, int userId) { return getPackageInfoInternal(packageName, PackageManager.VERSION_CODE_HIGHEST, flags, Binder.getCallingUid(), userId); }
// 实际的内部方法,这里做了代码精简,只保留关键部分 private PackageInfo getPackageInfoInternal(String packageName, long versionCode, int flags, int filterCallingUid, int userId) { // ...
// reader synchronized (mPackages) { // Normalize package name to handle renamed packages and static libs packageName = resolveInternalPackageNameLPr(packageName, versionCode);
/** * Test if the given component is considered installed, enabled and a match * for the given flags. * * <p> * Expects at least one of {@link PackageManager#MATCH_DIRECT_BOOT_AWARE} and * {@link PackageManager#MATCH_DIRECT_BOOT_UNAWARE} are specified in {@code flags}. * </p> */ publicbooleanisMatch(ComponentInfo componentInfo, int flags) { finalbooleanisSystemApp= componentInfo.applicationInfo.isSystemApp(); finalbooleanmatchUninstalled= (flags & PackageManager.MATCH_KNOWN_PACKAGES) != 0; if (!isAvailable(flags) && !(isSystemApp && matchUninstalled)) returnfalse; if (!isEnabled(componentInfo, flags)) returnfalse; // 重点关注
if ((flags & MATCH_SYSTEM_ONLY) != 0) { if (!isSystemApp) { returnfalse; } }