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

Commit 1e40e7e5 authored by lpeter's avatar lpeter Committed by Android Build Coastguard Worker
Browse files

Disallow device admin package and protected packages to be reinstalled as instant.

We should prevent the following types of apps from being reinstalled with
--install-existing as an instant.
(1)device admin package
(2)protected packages

Flag: EXEMPT bugfix

Bug: 341256043
Test: Manual test
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8a009268bb1a64e420b9048096e72096a0a48b08)
Merged-In: I4e913a12477fd4a64990033eaae533e30863e2a2
Change-Id: I4e913a12477fd4a64990033eaae533e30863e2a2
parent 408720e1
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -16284,6 +16284,9 @@ public class PackageManagerService extends IPackageManager.Stub
                    (installFlags & PackageManager.INSTALL_INSTANT_APP) != 0;
                    (installFlags & PackageManager.INSTALL_INSTANT_APP) != 0;
            final boolean fullApp =
            final boolean fullApp =
                    (installFlags & PackageManager.INSTALL_FULL_APP) != 0;
                    (installFlags & PackageManager.INSTALL_FULL_APP) != 0;
            final boolean isPackageDeviceAdmin = isPackageDeviceAdmin(packageName, userId);
            final boolean isProtectedPackage = mProtectedPackages != null
                    && mProtectedPackages.isPackageStateProtected(userId, packageName);
            // writer
            // writer
            synchronized (mLock) {
            synchronized (mLock) {
@@ -16291,7 +16294,8 @@ public class PackageManagerService extends IPackageManager.Stub
                if (pkgSetting == null) {
                if (pkgSetting == null) {
                    return PackageManager.INSTALL_FAILED_INVALID_URI;
                    return PackageManager.INSTALL_FAILED_INVALID_URI;
                }
                }
                if (instantApp && (pkgSetting.isSystem() || isUpdatedSystemApp(pkgSetting))) {
                if (instantApp && (pkgSetting.isSystem() || isUpdatedSystemApp(pkgSetting)
                        || isPackageDeviceAdmin || isProtectedPackage)) {
                    return PackageManager.INSTALL_FAILED_INVALID_URI;
                    return PackageManager.INSTALL_FAILED_INVALID_URI;
                }
                }
                if (!canViewInstantApps(callingUid, UserHandle.getUserId(callingUid))) {
                if (!canViewInstantApps(callingUid, UserHandle.getUserId(callingUid))) {