[pm] fix getInstalledApplications

ag/16176950 introduced a regression where duplicated results were
included in getInstalledApplications by mistake because packageState()
might include uninstalled packages. This CL reverts that.

BUG: 208768731
Test: manual and verified that wellbeing doesn't crash
Change-Id: Ica00a47b77d84d9669cc3062332b0d9948ef20e6
This commit is contained in:
Songchun Fan
2021-12-03 16:11:36 -08:00
parent edcc5a9682
commit dcb567646c

View File

@@ -4629,9 +4629,9 @@ public class ComputerEngine implements Computer {
}
} else {
list = new ArrayList<>(mPackages.size());
for (PackageStateInternal packageState : packageStates.values()) {
final AndroidPackage pkg = packageState.getPkg();
if (pkg == null) {
for (AndroidPackage p : mPackages.values()) {
final PackageStateInternal packageState = packageStates.get(p.getPackageName());
if (packageState == null) {
continue;
}
if (filterSharedLibPackage(packageState, Binder.getCallingUid(), userId, flags)) {
@@ -4640,10 +4640,10 @@ public class ComputerEngine implements Computer {
if (shouldFilterApplication(packageState, callingUid, userId)) {
continue;
}
ApplicationInfo ai = PackageInfoUtils.generateApplicationInfo(pkg, flags,
ApplicationInfo ai = PackageInfoUtils.generateApplicationInfo(p, flags,
packageState.getUserStateOrDefault(userId), userId, packageState);
if (ai != null) {
ai.packageName = resolveExternalPackageName(pkg);
ai.packageName = resolveExternalPackageName(p);
list.add(ai);
}
}