Loading core/java/android/content/pm/PackageManagerInternal.java +7 −0 Original line number Diff line number Diff line Loading @@ -844,6 +844,13 @@ public abstract class PackageManagerInternal { */ public abstract void forEachPackage(Consumer<PackageParser.Package> actionLocked); /** * Perform the given action for each installed package for a user. * Note that packages lock will be held while performin the actions. */ public abstract void forEachInstalledPackage( @NonNull Consumer<PackageParser.Package> actionLocked, @UserIdInt int userId); /** Returns the list of enabled components */ public abstract ArraySet<String> getEnabledComponents(String packageName, int userId); Loading services/core/java/com/android/server/pm/PackageManagerService.java +21 −0 Original line number Diff line number Diff line Loading @@ -24783,6 +24783,12 @@ public class PackageManagerService extends IPackageManager.Stub PackageManagerService.this.forEachPackage(actionLocked); } @Override public void forEachInstalledPackage(@NonNull Consumer<PackageParser.Package> actionLocked, @UserIdInt int userId) { PackageManagerService.this.forEachInstalledPackage(actionLocked, userId); } @Override public ArraySet<String> getEnabledComponents(String packageName, int userId) { synchronized (mPackages) { Loading Loading @@ -25075,6 +25081,21 @@ public class PackageManagerService extends IPackageManager.Stub } } void forEachInstalledPackage(@NonNull Consumer<PackageParser.Package> actionLocked, @UserIdInt int userId) { synchronized (mPackages) { int numPackages = mPackages.size(); for (int i = 0; i < numPackages; i++) { PackageParser.Package pkg = mPackages.valueAt(i); PackageSetting setting = mSettings.getPackageLPr(pkg.packageName); if (setting == null || !setting.getInstalled(userId)) { continue; } actionLocked.accept(pkg); } } } private static void enforceSystemOrPhoneCaller(String tag) { int callingUid = Binder.getCallingUid(); if (callingUid != Process.PHONE_UID && callingUid != Process.SYSTEM_UID) { services/core/java/com/android/server/role/RoleManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -280,7 +280,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); pm.forEachPackage(FunctionalUtils.uncheckExceptions(pkg -> { pm.forEachInstalledPackage(FunctionalUtils.uncheckExceptions(pkg -> { out.write(pkg.packageName.getBytes()); out.write(BitUtils.toBytes(pkg.getLongVersionCode())); out.write(pm.getApplicationEnabledState(pkg.packageName, userId)); Loading @@ -288,6 +288,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C ArraySet<String> enabledComponents = pm.getEnabledComponents(pkg.packageName, userId); int numComponents = CollectionUtils.size(enabledComponents); out.write(numComponents); for (int i = 0; i < numComponents; i++) { out.write(enabledComponents.valueAt(i).getBytes()); } Loading @@ -301,7 +302,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C for (Signature signature : pkg.mSigningDetails.signatures) { out.write(signature.toByteArray()); } })); }), userId); return PackageUtils.computeSha256Digest(out.toByteArray()); } Loading Loading
core/java/android/content/pm/PackageManagerInternal.java +7 −0 Original line number Diff line number Diff line Loading @@ -844,6 +844,13 @@ public abstract class PackageManagerInternal { */ public abstract void forEachPackage(Consumer<PackageParser.Package> actionLocked); /** * Perform the given action for each installed package for a user. * Note that packages lock will be held while performin the actions. */ public abstract void forEachInstalledPackage( @NonNull Consumer<PackageParser.Package> actionLocked, @UserIdInt int userId); /** Returns the list of enabled components */ public abstract ArraySet<String> getEnabledComponents(String packageName, int userId); Loading
services/core/java/com/android/server/pm/PackageManagerService.java +21 −0 Original line number Diff line number Diff line Loading @@ -24783,6 +24783,12 @@ public class PackageManagerService extends IPackageManager.Stub PackageManagerService.this.forEachPackage(actionLocked); } @Override public void forEachInstalledPackage(@NonNull Consumer<PackageParser.Package> actionLocked, @UserIdInt int userId) { PackageManagerService.this.forEachInstalledPackage(actionLocked, userId); } @Override public ArraySet<String> getEnabledComponents(String packageName, int userId) { synchronized (mPackages) { Loading Loading @@ -25075,6 +25081,21 @@ public class PackageManagerService extends IPackageManager.Stub } } void forEachInstalledPackage(@NonNull Consumer<PackageParser.Package> actionLocked, @UserIdInt int userId) { synchronized (mPackages) { int numPackages = mPackages.size(); for (int i = 0; i < numPackages; i++) { PackageParser.Package pkg = mPackages.valueAt(i); PackageSetting setting = mSettings.getPackageLPr(pkg.packageName); if (setting == null || !setting.getInstalled(userId)) { continue; } actionLocked.accept(pkg); } } } private static void enforceSystemOrPhoneCaller(String tag) { int callingUid = Binder.getCallingUid(); if (callingUid != Process.PHONE_UID && callingUid != Process.SYSTEM_UID) {
services/core/java/com/android/server/role/RoleManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -280,7 +280,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); pm.forEachPackage(FunctionalUtils.uncheckExceptions(pkg -> { pm.forEachInstalledPackage(FunctionalUtils.uncheckExceptions(pkg -> { out.write(pkg.packageName.getBytes()); out.write(BitUtils.toBytes(pkg.getLongVersionCode())); out.write(pm.getApplicationEnabledState(pkg.packageName, userId)); Loading @@ -288,6 +288,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C ArraySet<String> enabledComponents = pm.getEnabledComponents(pkg.packageName, userId); int numComponents = CollectionUtils.size(enabledComponents); out.write(numComponents); for (int i = 0; i < numComponents; i++) { out.write(enabledComponents.valueAt(i).getBytes()); } Loading @@ -301,7 +302,7 @@ public class RoleManagerService extends SystemService implements RoleUserState.C for (Signature signature : pkg.mSigningDetails.signatures) { out.write(signature.toByteArray()); } })); }), userId); return PackageUtils.computeSha256Digest(out.toByteArray()); } Loading