android.content.pm.PackageParser Java Examples
The following examples show how to use
android.content.pm.PackageParser.
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: DefaultPermissionGrantPolicy.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private boolean isSysComponentOrPersistentPlatformSignedPrivApp(PackageParser.Package pkg) { if (UserHandle.getAppId(pkg.applicationInfo.uid) < FIRST_APPLICATION_UID) { return true; } if (!pkg.isPrivileged()) { return false; } final PackageParser.Package disabledPkg = mServiceInternal.getDisabledPackage(pkg.packageName); if (disabledPkg != null) { if ((disabledPkg.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) == 0) { return false; } } else if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) == 0) { return false; } final String systemPackageName = mServiceInternal.getKnownPackageName( PackageManagerInternal.PACKAGE_SYSTEM, UserHandle.USER_SYSTEM); final PackageParser.Package systemPackage = getPackage(systemPackageName); return pkg.mSigningDetails.hasAncestorOrSelf(systemPackage.mSigningDetails) || systemPackage.mSigningDetails.checkCapability(pkg.mSigningDetails, PackageParser.SigningDetails.CertCapabilities.PERMISSION); }
Example #2
Source File: InstantAppRegistry.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public byte[] getInstantAppCookieLPw(@NonNull String packageName, @UserIdInt int userId) { // Only installed packages can get their own cookie PackageParser.Package pkg = mService.mPackages.get(packageName); if (pkg == null) { return null; } byte[] pendingCookie = mCookiePersistence.getPendingPersistCookieLPr(pkg, userId); if (pendingCookie != null) { return pendingCookie; } File cookieFile = peekInstantCookieFile(packageName, userId); if (cookieFile != null && cookieFile.exists()) { try { return IoUtils.readFileAsByteArray(cookieFile.toString()); } catch (IOException e) { Slog.w(LOG_TAG, "Error reading cookie file: " + cookieFile); } } return null; }
Example #3
Source File: PackageDexOptimizer.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Creates oat dir for the specified package if needed and supported. * In certain cases oat directory * <strong>cannot</strong> be created: * <ul> * <li>{@code pkg} is a system app, which is not updated.</li> * <li>Package location is not a directory, i.e. monolithic install.</li> * </ul> * * @return Absolute path to the oat directory or null, if oat directory * cannot be created. */ @Nullable private String createOatDirIfSupported(PackageParser.Package pkg, String dexInstructionSet) { if (!pkg.canHaveOatDir()) { return null; } File codePath = new File(pkg.codePath); if (codePath.isDirectory()) { // TODO(calin): why do we create this only if the codePath is a directory? (i.e for // cluster packages). It seems that the logic for the folder creation is // split between installd and here. File oatDir = getOatDir(codePath); try { mInstaller.createOatDir(oatDir.getAbsolutePath(), dexInstructionSet); } catch (InstallerException e) { Slog.w(TAG, "Failed to create oat dir", e); return null; } return oatDir.getAbsolutePath(); } return null; }
Example #4
Source File: InstantAppRegistry.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void addUninstalledInstantAppLPw(@NonNull PackageParser.Package pkg, @UserIdInt int userId) { InstantAppInfo uninstalledApp = createInstantAppInfoForPackage( pkg, userId, false); if (uninstalledApp == null) { return; } if (mUninstalledInstantApps == null) { mUninstalledInstantApps = new SparseArray<>(); } List<UninstalledInstantAppState> uninstalledAppStates = mUninstalledInstantApps.get(userId); if (uninstalledAppStates == null) { uninstalledAppStates = new ArrayList<>(); mUninstalledInstantApps.put(userId, uninstalledAppStates); } UninstalledInstantAppState uninstalledAppState = new UninstalledInstantAppState( uninstalledApp, System.currentTimeMillis()); uninstalledAppStates.add(uninstalledAppState); writeUninstalledInstantAppMetadata(uninstalledApp, userId); writeInstantApplicationIconLPw(pkg, userId); }
Example #5
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** Add all components defined in the given package to the internal structures. */ void addAllComponents(PackageParser.Package pkg, boolean chatty) { final ArrayList<PackageParser.ActivityIntentInfo> newIntents = new ArrayList<>(); synchronized (mLock) { addActivitiesLocked(pkg, newIntents, chatty); addReceiversLocked(pkg, chatty); addProvidersLocked(pkg, chatty); addServicesLocked(pkg, chatty); } final String setupWizardPackage = sPackageManagerInternal.getKnownPackageName( PACKAGE_SETUP_WIZARD, UserHandle.USER_SYSTEM); for (int i = newIntents.size() - 1; i >= 0; --i) { final PackageParser.ActivityIntentInfo intentInfo = newIntents.get(i); final PackageParser.Package disabledPkg = sPackageManagerInternal .getDisabledSystemPackage(intentInfo.activity.info.packageName); final List<PackageParser.Activity> systemActivities = disabledPkg != null ? disabledPkg.activities : null; adjustPriority(systemActivities, intentInfo, setupWizardPackage); } }
Example #6
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override protected boolean isFilterStopped(PackageParser.ServiceIntentInfo filter, int userId) { if (!sUserManager.exists(userId)) return true; PackageParser.Package p = filter.service.owner; if (p != null) { PackageSetting ps = (PackageSetting) p.mExtras; if (ps != null) { // System apps are never considered stopped for purposes of // filtering, because there may be no way for the user to // actually re-launch them. return (ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) == 0 && ps.getStopped(userId); } } return false; }
Example #7
Source File: DefaultPermissionGrantPolicy.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private List<PackageParser.Package> getHeadlessSyncAdapterPackages( String[] syncAdapterPackageNames, int userId) { List<PackageParser.Package> syncAdapterPackages = new ArrayList<>(); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_LAUNCHER); for (String syncAdapterPackageName : syncAdapterPackageNames) { homeIntent.setPackage(syncAdapterPackageName); ResolveInfo homeActivity = mServiceInternal.resolveIntent(homeIntent, homeIntent.resolveType(mContext.getContentResolver()), DEFAULT_FLAGS, userId, false, Binder.getCallingUid()); if (homeActivity != null) { continue; } PackageParser.Package syncAdapterPackage = getSystemPackage(syncAdapterPackageName); if (syncAdapterPackage != null) { syncAdapterPackages.add(syncAdapterPackage); } } return syncAdapterPackages; }
Example #8
Source File: VPackageManagerService.java From container with GNU General Public License v3.0 | 6 votes |
public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType, int flags, ArrayList<PackageParser.Service> packageServices) { if (packageServices == null) { return null; } mFlags = flags; final boolean defaultOnly = (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0; final int N = packageServices.size(); ArrayList<PackageParser.ServiceIntentInfo[]> listCut = new ArrayList<PackageParser.ServiceIntentInfo[]>(N); ArrayList<PackageParser.ServiceIntentInfo> intentFilters; for (int i = 0; i < N; ++i) { intentFilters = packageServices.get(i).intents; if (intentFilters != null && intentFilters.size() > 0) { PackageParser.ServiceIntentInfo[] array = new PackageParser.ServiceIntentInfo[intentFilters.size()]; intentFilters.toArray(array); listCut.add(array); } } return super.queryIntentFromList(intent, resolvedType, defaultOnly, listCut); }
Example #9
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@GuardedBy("mLock") private void addReceiversLocked(PackageParser.Package pkg, boolean chatty) { final int receiversSize = pkg.receivers.size(); StringBuilder r = null; for (int i = 0; i < receiversSize; i++) { PackageParser.Activity a = pkg.receivers.get(i); a.info.processName = fixProcessName(pkg.applicationInfo.processName, a.info.processName); mReceivers.addActivity(a, "receiver", null); if (DEBUG_PACKAGE_SCANNING && chatty) { if (r == null) { r = new StringBuilder(256); } else { r.append(' '); } r.append(a.info.name); } } if (DEBUG_PACKAGE_SCANNING && chatty) { Log.d(TAG, " Receivers: " + (r == null ? "<NONE>" : r)); } }
Example #10
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
void removeService(PackageParser.Service s) { mServices.remove(s.getComponentName()); if (DEBUG_SHOW_INFO) { Log.v(TAG, " " + (s.info.nonLocalizedLabel != null ? s.info.nonLocalizedLabel : s.info.name) + ":"); Log.v(TAG, " Class=" + s.info.name); } final int intentsSize = s.intents.size(); int j; for (j = 0; j < intentsSize; j++) { PackageParser.ServiceIntentInfo intent = s.intents.get(j); if (DEBUG_SHOW_INFO) { Log.v(TAG, " IntentFilter:"); intent.dump(new LogPrinter(Log.VERBOSE, TAG), " "); } removeFilter(intent); } }
Example #11
Source File: PackageDexOptimizer.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Performs dexopt on all code paths and libraries of the specified package for specified * instruction sets. * * <p>Calls to {@link com.android.server.pm.Installer#dexopt} on {@link #mInstaller} are * synchronized on {@link #mInstallLock}. */ int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries, String[] instructionSets, CompilerStats.PackageStats packageStats, PackageDexUsage.PackageUseInfo packageUseInfo, DexoptOptions options) { if (pkg.applicationInfo.uid == -1) { throw new IllegalArgumentException("Dexopt for " + pkg.packageName + " has invalid uid."); } if (!canOptimizePackage(pkg)) { return DEX_OPT_SKIPPED; } synchronized (mInstallLock) { final long acquireTime = acquireWakeLockLI(pkg.applicationInfo.uid); try { return performDexOptLI(pkg, sharedLibraries, instructionSets, packageStats, packageUseInfo, options); } finally { releaseWakeLockLI(acquireTime); } } }
Example #12
Source File: PackageManagerServiceUtils.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static boolean matchSignaturesRecover( String packageName, PackageParser.SigningDetails existingSignatures, PackageParser.SigningDetails parsedSignatures, @PackageParser.SigningDetails.CertCapabilities int flags) { String msg = null; try { if (parsedSignatures.checkCapabilityRecover(existingSignatures, flags)) { logCriticalInfo(Log.INFO, "Recovered effectively matching certificates for " + packageName); return true; } } catch (CertificateException e) { msg = e.getMessage(); } logCriticalInfo(Log.INFO, "Failed to recover certificates for " + packageName + ": " + msg); return false; }
Example #13
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private void removeActivity(PackageParser.Activity a, String type) { mActivities.remove(a.getComponentName()); if (DEBUG_SHOW_INFO) { Log.v(TAG, " " + type + " " + (a.info.nonLocalizedLabel != null ? a.info.nonLocalizedLabel : a.info.name) + ":"); Log.v(TAG, " Class=" + a.info.name); } final int intentsSize = a.intents.size(); for (int j = 0; j < intentsSize; j++) { PackageParser.ActivityIntentInfo intent = a.intents.get(j); if (DEBUG_SHOW_INFO) { Log.v(TAG, " IntentFilter:"); intent.dump(new LogPrinter(Log.VERBOSE, TAG), " "); } removeFilter(intent); } }
Example #14
Source File: PermissionManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private boolean isPermissionsReviewRequired(PackageParser.Package pkg, int userId) { if (!mSettings.mPermissionReviewRequired) { return false; } // Permission review applies only to apps not supporting the new permission model. if (pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.M) { return false; } // Legacy apps have the permission and get user consent on launch. if (pkg == null || pkg.mExtras == null) { return false; } final PackageSetting ps = (PackageSetting) pkg.mExtras; final PermissionsState permissionsState = ps.getPermissionsState(); return permissionsState.isPermissionReviewRequired(userId); }
Example #15
Source File: VPackageManagerService.java From container with GNU General Public License v3.0 | 6 votes |
@Override public List<String> querySharedPackages(String packageName) { synchronized (mPackages) { PackageParser.Package p = mPackages.get(packageName); if (p == null || p.mSharedUserId == null) { // noinspection unchecked return Collections.EMPTY_LIST; } ArrayList<String> list = new ArrayList<>(); for (PackageParser.Package one : mPackages.values()) { if (TextUtils.equals(one.mSharedUserId, p.mSharedUserId)) { list.add(one.packageName); } } return list; } }
Example #16
Source File: LoadedPlugin.java From VirtualAPK with Apache License 2.0 | 6 votes |
public Intent getLeanbackLaunchIntent() { ContentResolver resolver = this.mPluginContext.getContentResolver(); Intent launcher = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER); for (PackageParser.Activity activity : this.mPackage.activities) { for (PackageParser.ActivityIntentInfo intentInfo : activity.intents) { if (intentInfo.match(resolver, launcher, false, TAG) > 0) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(activity.getComponentName()); intent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER); return intent; } } } return null; }
Example #17
Source File: PackageParserCompat.java From container with GNU General Public License v3.0 | 5 votes |
public static PackageInfo generatePackageInfo(Package p, int flags, long firstInstallTime, long lastUpdateTime) { if (SDK >= M) { return PackageParserMarshmallow.generatePackageInfo.call(p, gids, flags, firstInstallTime, lastUpdateTime, null, sUserState); } else if (SDK >= LOLLIPOP) { if (PackageParserLollipop22.generatePackageInfo != null) { return PackageParserLollipop22.generatePackageInfo.call(p, gids, flags, firstInstallTime, lastUpdateTime, null, sUserState); } else { return PackageParserLollipop.generatePackageInfo.call(p, gids, flags, firstInstallTime, lastUpdateTime, null, sUserState); } } else if (SDK >= JELLY_BEAN_MR1) { return PackageParserJellyBean17.generatePackageInfo.call(p, gids, flags, firstInstallTime, lastUpdateTime, null, sUserState); } else if (SDK >= JELLY_BEAN) { return PackageParserJellyBean.generatePackageInfo.call(p, gids, flags, firstInstallTime, lastUpdateTime, null); } else { return mirror.android.content.pm.PackageParser.generatePackageInfo.call(p, gids, flags, firstInstallTime, lastUpdateTime); } }
Example #18
Source File: VPackageManagerService.java From container with GNU General Public License v3.0 | 5 votes |
@Override public ActivityInfo getActivityInfo(ComponentName component, int flags, int userId) { checkUserId(userId); synchronized (mPackages) { PackageParser.Activity a = mActivities.mActivities.get(component); if (a != null) { ActivityInfo activityInfo = PackageParserCompat.generateActivityInfo(a, flags); PackageParser.Package p = mPackages.get(activityInfo.packageName); AppSetting settings = (AppSetting) p.mExtras; ComponentFixer.fixComponentInfo(settings, activityInfo, userId); return activityInfo; } } return null; }
Example #19
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override protected void dumpFilter(PrintWriter out, String prefix, PackageParser.ServiceIntentInfo filter) { out.print(prefix); out.print(Integer.toHexString(System.identityHashCode(filter.service))); out.print(' '); filter.service.printComponentShortName(out); out.print(" filter "); out.print(Integer.toHexString(System.identityHashCode(filter))); if (filter.service.info.permission != null) { out.print(" permission "); out.println(filter.service.info.permission); } else { out.println(); } }
Example #20
Source File: PackageManagerService.java From haystack with GNU General Public License v3.0 | 5 votes |
@DexWrap //<4.1// PackageInfo generatePackageInfo(PackageParser.Package p, int flags) { /*>4.1*/ //<7.0// PackageInfo generatePackageInfo(PackageParser.Package p, int flags, int userId) { /*>7.0*/ private PackageInfo generatePackageInfo(PackageSetting p, int flags, int userId) { //<4.1// PackageInfo pi = generatePackageInfo(p, flags); /*>4.1*/ PackageInfo pi = generatePackageInfo(p, flags, userId); if (p != null && pi != null) { //<4.0// pi = GeneratePackageInfoHookAccessor.hook(pi, mContext, p, flags, -1); /*>4.0*/ //<4.1// pi = GeneratePackageInfoHook.hook(pi, mContext, p, flags, -1); /*>4.1*/ //<7.0// pi = GeneratePackageInfoHook.hook(pi, mContext, p, flags, userId); /*>7.0*/ PackageParser.Package pp = p.pkg; /*>7.0*/ if (pp != null) pi = GeneratePackageInfoHook.hook(pi, mContext, pp, flags, userId); } return pi; }
Example #21
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
protected void dumpFilterLabel(PrintWriter out, String prefix, Object label, int count) { final PackageParser.Provider provider = (PackageParser.Provider) label; out.print(prefix); out.print(Integer.toHexString(System.identityHashCode(provider))); out.print(' '); provider.printComponentShortName(out); if (count > 1) { out.print(" ("); out.print(count); out.print(" filters)"); } out.println(); }
Example #22
Source File: DexManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Generates log if the APKs in the given package have uncompressed dex file and so * files that can be direclty mapped. */ private static void logIfPackageHasUncompressedCode(PackageParser.Package pkg) { logIfApkHasUncompressedCode(pkg.baseCodePath); if (!ArrayUtils.isEmpty(pkg.splitCodePaths)) { for (int i = 0; i < pkg.splitCodePaths.length; i++) { logIfApkHasUncompressedCode(pkg.splitCodePaths[i]); } } }
Example #23
Source File: PermissionManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private int getPermissionFlags( String permName, String packageName, int callingUid, int userId) { if (!mUserManagerInt.exists(userId)) { return 0; } enforceGrantRevokeRuntimePermissionPermissions("getPermissionFlags"); enforceCrossUserPermission(callingUid, userId, true, // requireFullPermission false, // checkShell false, // requirePermissionWhenSameUser "getPermissionFlags"); final PackageParser.Package pkg = mPackageManagerInt.getPackage(packageName); if (pkg == null || pkg.mExtras == null) { return 0; } synchronized (mLock) { if (mSettings.getPermissionLocked(permName) == null) { return 0; } } if (mPackageManagerInt.filterAppAccess(pkg, callingUid, userId)) { return 0; } final PackageSetting ps = (PackageSetting) pkg.mExtras; PermissionsState permissionsState = ps.getPermissionsState(); return permissionsState.getPermissionFlags(permName, userId); }
Example #24
Source File: ComponentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override protected void dumpFilter(PrintWriter out, String prefix, PackageParser.ProviderIntentInfo filter) { out.print(prefix); out.print(Integer.toHexString(System.identityHashCode(filter.provider))); out.print(' '); filter.provider.printComponentShortName(out); out.print(" filter "); out.println(Integer.toHexString(System.identityHashCode(filter))); }
Example #25
Source File: VPackageManagerService.java From container with GNU General Public License v3.0 | 5 votes |
@Override public int getPackageUid(String packageName, int userId) { checkUserId(userId); synchronized (mPackages) { PackageParser.Package p = mPackages.get(packageName); if (p != null) { AppSetting settings = (AppSetting) p.mExtras; return VUserHandle.getUid(userId, settings.appId); } return -1; } }
Example #26
Source File: BasePermission.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public @Nullable PermissionInfo generatePermissionInfo(@NonNull String groupName, int flags) { if (groupName == null) { if (perm == null || perm.info.group == null) { return generatePermissionInfo(protectionLevel, flags); } } else { if (perm != null && groupName.equals(perm.info.group)) { return PackageParser.generatePermissionInfo(perm, flags); } } return null; }
Example #27
Source File: ArtManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Clear the profiles for the given package. */ public void clearAppProfiles(PackageParser.Package pkg) { try { ArrayMap<String, String> packageProfileNames = getPackageProfileNames(pkg); for (int i = packageProfileNames.size() - 1; i >= 0; i--) { String profileName = packageProfileNames.valueAt(i); mInstaller.clearAppProfiles(pkg.packageName, profileName); } } catch (InstallerException e) { Slog.w(TAG, String.valueOf(e)); } }
Example #28
Source File: DefaultPermissionGrantPolicy.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void grantDefaultPermissionsToDefaultSystemSmsApp( PackageParser.Package smsPackage, int userId) { if (doesPackageSupportRuntimePermissions(smsPackage)) { grantRuntimePermissions(smsPackage, PHONE_PERMISSIONS, userId); grantRuntimePermissions(smsPackage, CONTACTS_PERMISSIONS, userId); grantRuntimePermissions(smsPackage, SMS_PERMISSIONS, userId); grantRuntimePermissions(smsPackage, STORAGE_PERMISSIONS, userId); grantRuntimePermissions(smsPackage, MICROPHONE_PERMISSIONS, userId); grantRuntimePermissions(smsPackage, CAMERA_PERMISSIONS, userId); } }
Example #29
Source File: VPackageManagerService.java From container with GNU General Public License v3.0 | 5 votes |
@Override public PermissionInfo getPermissionInfo(String name, int flags) { synchronized (mPackages) { PackageParser.Permission p = mPermissions.get(name); if (p != null) { return new PermissionInfo(p.info); } } return null; }
Example #30
Source File: PermissionManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void grantRequestedRuntimePermissions(PackageParser.Package pkg, int[] userIds, String[] grantedPermissions, int callingUid, PermissionCallback callback) { for (int userId : userIds) { grantRequestedRuntimePermissionsForUser(pkg, userId, grantedPermissions, callingUid, callback); } }