Remove app pairs when their member apps are uninstalled

This patch modifies PackageUpdatedTask.execute() to also remove app pairs when their member apps are uninstalled.

Fixes: 316050282
Test: Install App A, create an app pair containing App A, uninstall App A.
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TEAMFOOD
Change-Id: I8487a2dfcfc6d29bd55e88003d1950078c6e2e31
This commit is contained in:
Jeremy Sim
2024-01-22 17:50:12 +08:00
parent 7b1858cbf2
commit 48467438da
2 changed files with 20 additions and 3 deletions
@@ -353,9 +353,17 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
}
if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
Predicate<ItemInfo> removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
.or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
.and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
// This predicate is used to mark an ItemInfo for removal if its package or component
// is marked for removal.
Predicate<ItemInfo> removeAppMatch =
ItemInfoMatcher.ofPackages(removedPackages, mUser)
.or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
.and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
// This predicate is used to mark an app pair for removal if it contains an app marked
// for removal.
Predicate<ItemInfo> removeAppPairMatch =
ItemInfoMatcher.forAppPairMatch(removeAppMatch);
Predicate<ItemInfo> removeMatch = removeAppMatch.or(removeAppPairMatch);
deleteAndBindComponentsRemoved(removeMatch,
"removed because the corresponding package or component is removed. "
+ "mOp=" + mOp + " removedPackages=" + removedPackages.stream().collect(