From b9de4c475cb50034c4df587be83840b6b839ba3a Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Mon, 6 Dec 2021 15:53:01 -0800 Subject: [PATCH] If specified INSTALL_ALL_USERS then install for all users. Previously, it would treat this as an update, and only do it for the users who already have the app installed. Bug: 203371588 Fixes: 203371588 Test: presubmit Change-Id: I57723f3f4e22725e5bff04f3b581b62172f23811 --- .../com/android/server/pm/InstallPackageHelper.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 80c2a7e97719c..fce37a9f23458 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -2322,12 +2322,19 @@ final class InstallPackageHelper { } } - // It's implied that when a user requests installation, they want the app to be - // installed and enabled. (This does not apply to USER_ALL, which here means only - // install on users for which the app is already installed). if (userId != UserHandle.USER_ALL) { + // It's implied that when a user requests installation, they want the app to + // be installed and enabled. ps.setInstalled(true, userId); ps.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT, userId, installerPackageName); + } else if (allUsers != null) { + // The caller explicitly specified INSTALL_ALL_USERS flag. + // Thus, updating the settings to install the app for all users. + for (int currentUserId : allUsers) { + ps.setInstalled(true, currentUserId); + ps.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT, userId, + installerPackageName); + } } mPm.mSettings.addInstallerPackageNames(ps.getInstallSource());