Merge "Exclude packages that's not installed from the hash for role." into qt-dev
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
@@ -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());
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user