Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 811d8403 authored by Sumedh Sen's avatar Sumedh Sen Committed by Automerger Merge Worker
Browse files

Merge "Prevent installing apps in policy restricted work profile using ADB"...

Merge "Prevent installing apps in policy restricted work profile using ADB" into udc-dev am: 2297912e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22512303



Change-Id: I4dd93e6a07641dcee95f2c211ec277f561b452fb
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 24f937b5 2297912e
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -2265,11 +2265,27 @@ final class InstallPackageHelper {
                    // The caller explicitly specified INSTALL_ALL_USERS flag.
                    // Thus, updating the settings to install the app for all users.
                    for (int currentUserId : allUsers) {
                        // If the app is already installed for the currentUser,
                        // keep it as installed as we might be updating the app at this place.
                        // If not currently installed, check if the currentUser is restricted by
                        // DISALLOW_INSTALL_APPS or DISALLOW_DEBUGGING_FEATURES device policy.
                        // Install / update the app if the user isn't restricted. Skip otherwise.
                        final boolean installedForCurrentUser = ArrayUtils.contains(
                                installedForUsers, currentUserId);
                        final boolean restrictedByPolicy =
                                mPm.isUserRestricted(currentUserId,
                                        UserManager.DISALLOW_INSTALL_APPS)
                                || mPm.isUserRestricted(currentUserId,
                                        UserManager.DISALLOW_DEBUGGING_FEATURES);
                        if (installedForCurrentUser || !restrictedByPolicy) {
                            ps.setInstalled(true, currentUserId);
                            if (!installRequest.isApplicationEnabledSettingPersistent()) {
                                ps.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT, currentUserId,
                                        installerPackageName);
                            }
                        } else {
                            ps.setInstalled(false, currentUserId);
                        }
                    }
                }