PackageManagerService: Check for duplicate inactive factory packages

If after a factory reset, APEX modules are updated, duplicate package
names are returned from the API - factory packages are added first and
then inactive factory packages leading to duplication.

After updating APEX modules, inactive factory packages would always be a
subset of factory packages. The fix adds inactive packages only if there
was no factory reset done.

Bug: 200519752
Bug: 200120056
Test: atest 'PackageManagerTest#testGetInstalledPackages_WithFactoryFlag_ContainsNoDuplicates'
Change-Id: I5b5469fc6879bbeee4dc2ea47b2046ab011a65ce
This commit is contained in:
Sanjana Sunil
2021-10-04 14:20:28 +00:00
parent bf23230dc0
commit 56172ee863

View File

@@ -1594,9 +1594,9 @@ public class ComputerEngine implements Computer {
list.addAll(mApexManager.getFactoryPackages()); list.addAll(mApexManager.getFactoryPackages());
} else { } else {
list.addAll(mApexManager.getActivePackages()); list.addAll(mApexManager.getActivePackages());
} if (listUninstalled) {
if (listUninstalled) { list.addAll(mApexManager.getInactivePackages());
list.addAll(mApexManager.getInactivePackages()); }
} }
} }
return new ParceledListSlice<>(list); return new ParceledListSlice<>(list);