Always update overlay paths of newly added apps

When a package is updated, its overlays must always be initialized.
A package may be affected by framework overlays or overlays of shared
libraries it uses. The overlay paths must always be initialized in
package manager.

To work around this issue, rebooting the device always initializes
overlay paths for all installed applications.

Bug: 180416025
Bug: 180016597
Test: OverlayManagerTests
Change-Id: I1bf0d460336ee757bb191adaaeec0089911fa182
This commit is contained in:
Ryan Mitchell
2021-02-16 21:45:16 -08:00
parent d145f376ca
commit 50a3c1b95e

View File

@@ -244,7 +244,11 @@ final class OverlayManagerServiceImpl {
@NonNull
Set<PackageAndUser> onPackageAdded(@NonNull final String pkgName,
final int userId) throws OperationFailedException {
return reconcileSettingsForPackage(pkgName, userId, 0 /* flags */);
final Set<PackageAndUser> updatedTargets = new ArraySet<>();
// Always update the overlays of newly added packages.
updatedTargets.add(new PackageAndUser(pkgName, userId));
updatedTargets.addAll(reconcileSettingsForPackage(pkgName, userId, 0 /* flags */));
return updatedTargets;
}
@NonNull
@@ -282,7 +286,7 @@ final class OverlayManagerServiceImpl {
private Set<PackageAndUser> removeOverlaysForUser(
@NonNull final Predicate<OverlayInfo> condition, final int userId) {
final List<OverlayInfo> overlays = mSettings.removeIf(
io -> userId == io.userId && condition.test(io) );
io -> userId == io.userId && condition.test(io));
Set<PackageAndUser> targets = Collections.emptySet();
for (int i = 0, n = overlays.size(); i < n; i++) {
final OverlayInfo info = overlays.get(i);