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

Commit 2296700c authored by Sanjana Sunil's avatar Sanjana Sunil Committed by Nishith Khanna
Browse files

Explicitly unset INSTALL_FROM_MANAGED_USER_OR_PROFILE flag

If the flag is not explicitly unset, an app could set this flag, leading
to unexpected behaviour if the install is not actually from a managed
user or profile.

DISABLE_TOPIC_PROTECTOR
Bug: 459461121
Test: atest PackageManagerShellCommandInstallTest#testSessionCreationWithManagedUserOrProfileFlag_notFromManagedProfile
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:472e8c78dfdf282ba1efd1f3d99e430b7df112c0
Merged-In: I21bbbf628e97244d469eb23ce0558dbf560b7618
Change-Id: I21bbbf628e97244d469eb23ce0558dbf560b7618
parent 51f4f16b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1015,6 +1015,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }

        final var dpmi = LocalServices.getService(DevicePolicyManagerInternal.class);
        // Only the system should be able to set this flag - so ensure it is unset when not needed.
        params.installFlags &= ~PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE;
        if (dpmi != null && dpmi.isUserOrganizationManaged(userId)) {
            params.installFlags |= PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE;
        }