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

Commit 01e46b2d authored by Nikita Ioffe's avatar Nikita Ioffe
Browse files

PM: Reject installation of an APK with same name as an APEX

Test: atest CtsStagedInstallHostTestCases
Bug: 130788498
Change-Id: Ic7e5e14ed2d02d3685fd39bb70bc9423ae78f18e
(cherry picked from commit 95f648ac)
parent 6ca8b625
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -2470,6 +2470,7 @@ public class PackageManagerService extends IPackageManager.Stub
        mProtectedPackages = new ProtectedPackages(mContext);
        mProtectedPackages = new ProtectedPackages(mContext);
        mApexManager = new ApexManager(context);
        synchronized (mInstallLock) {
        synchronized (mInstallLock) {
        // writer
        // writer
        synchronized (mPackages) {
        synchronized (mPackages) {
@@ -3295,7 +3296,6 @@ public class PackageManagerService extends IPackageManager.Stub
                }
                }
            }
            }
            mApexManager = new ApexManager(context);
            mInstallerService = new PackageInstallerService(context, this, mApexManager);
            mInstallerService = new PackageInstallerService(context, this, mApexManager);
            final Pair<ComponentName, String> instantAppResolverComponent =
            final Pair<ComponentName, String> instantAppResolverComponent =
                    getInstantAppResolverLPr();
                    getInstantAppResolverLPr();
@@ -11707,6 +11707,11 @@ public class PackageManagerService extends IPackageManager.Stub
                    "Code and resource paths haven't been set correctly");
                    "Code and resource paths haven't been set correctly");
        }
        }
        if (mApexManager.isApexPackage(pkg.packageName)) {
            throw new PackageManagerException(INSTALL_FAILED_DUPLICATE_PACKAGE,
                    pkg.packageName + " is an APEX package and can't be installed as an APK.");
        }
        // Make sure we're not adding any bogus keyset info
        // Make sure we're not adding any bogus keyset info
        final KeySetManagerService ksms = mSettings.mKeySetManagerService;
        final KeySetManagerService ksms = mSettings.mKeySetManagerService;
        ksms.assertScannedPackageValid(pkg);
        ksms.assertScannedPackageValid(pkg);