Fix a bug in UserSystemPackageInstaller#installWhitelistedSystemPackages
When userWhitelist was not null, it only mutated the packages in
userWhitelist, and other packages left untouched.
The correct behavior is to iterate all packages and install or
uninstall according to userWhitelist.
BYPASS_INCLUSIVE_LANGUAGE_REASON=existing code that cannot be changed
Fixes: 234877652
Test: atest UserSystemPackageInstallerTest
Test: Manual test with gcar_emu_x86_64 emulator
(cherry picked from commit 2fce090146)
Merged-In: I4325565d8acaeffd4aab5a4b6295d325edb738a9
Change-Id: I4325565d8acaeffd4aab5a4b6295d325edb738a9
This commit is contained in:
@@ -219,38 +219,21 @@ class UserSystemPackageInstaller {
|
|||||||
|
|
||||||
// Install/uninstall system packages per user.
|
// Install/uninstall system packages per user.
|
||||||
for (int userId : mUm.getUserIds()) {
|
for (int userId : mUm.getUserIds()) {
|
||||||
final Set<String> userWhitelist = getInstallablePackagesForUserId(userId);
|
final Set<String> userAllowlist = getInstallablePackagesForUserId(userId);
|
||||||
|
|
||||||
// If null, run for all packages
|
pmInt.forEachPackageState(packageState -> {
|
||||||
if (userWhitelist == null) {
|
if (packageState.getPkg() == null) {
|
||||||
pmInt.forEachPackageState(packageState -> {
|
return;
|
||||||
if (packageState.getPkg() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final boolean install = !packageState.getTransientState()
|
|
||||||
.isHiddenUntilInstalled();
|
|
||||||
if (packageState.getUserStateOrDefault(userId).isInstalled() != install
|
|
||||||
&& shouldChangeInstallationState(packageState, install, userId,
|
|
||||||
isFirstBoot, isConsideredUpgrade, preExistingPackages)) {
|
|
||||||
changesToCommit.add(userId, packageState.getPackageName(), install);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
for (String packageName : userWhitelist) {
|
|
||||||
PackageStateInternal packageState = pmInt.getPackageStateInternal(packageName);
|
|
||||||
if (packageState.getPkg() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean install = !packageState.getTransientState()
|
|
||||||
.isHiddenUntilInstalled();
|
|
||||||
if (packageState.getUserStateOrDefault(userId).isInstalled() != install
|
|
||||||
&& shouldChangeInstallationState(packageState, install, userId,
|
|
||||||
isFirstBoot, isConsideredUpgrade, preExistingPackages)) {
|
|
||||||
changesToCommit.add(userId, packageState.getPackageName(), install);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
boolean install = (userAllowlist == null
|
||||||
|
|| userAllowlist.contains(packageState.getPackageName()))
|
||||||
|
&& !packageState.getTransientState().isHiddenUntilInstalled();
|
||||||
|
if (packageState.getUserStateOrDefault(userId).isInstalled() != install
|
||||||
|
&& shouldChangeInstallationState(packageState, install, userId,
|
||||||
|
isFirstBoot, isConsideredUpgrade, preExistingPackages)) {
|
||||||
|
changesToCommit.add(userId, packageState.getPackageName(), install);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pmInt.commitPackageStateMutation(null, packageStateMutator -> {
|
pmInt.commitPackageStateMutation(null, packageStateMutator -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user