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

Commit 85a4d96f authored by Yo Chiang's avatar Yo Chiang Committed by Yi-yo Chiang
Browse files

ApexManager: Allow duplicating VNDK APEX package names

Don't throw when the duplicating APEX names are VNDK.

Explicitly allow duplicating builtin packages if they are VNDK APEX.
For example, aosp_bonito has its VNDK APEX installed in the vendor
partition and GSI installed its VNDK APEX in system partition.
When booting with GSI as the system image, there would be two APEXes
with the same name "com.android.vndk.v30", and only one is activated
by apexd:

- (inactive) /vendor/apex/com.android.vndk.current.on_vendor.apex
-   (active) /system/apex/com.android.vndk.current.apex

Bug: 160611268
Test: Flash aosp_bonito / vendor.img + aosp_arm64 / system.img and boot
  to home screen
Test: atest CtsStagedInstallHostTestCases
Test: atest FrameworksServicesTests:PackageParserTest
Test: atest FrameworksServicesTests:ApexManagerTest
Test: adb shell dumpsys package
Test: | com.android.vndk.current.apex is active
Test: | com.android.vndk.current.on_vendor.apex is inactive
Change-Id: I9f01ba075f26d22aa5101dc3da69d53c5a8b6202
parent 038d147e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ public abstract class ApexManager {
    public static final int MATCH_ACTIVE_PACKAGE = 1 << 0;
    static final int MATCH_FACTORY_PACKAGE = 1 << 1;

    private static final String VNDK_APEX_MODULE_NAME_PREFIX = "com.android.vndk.";

    private static final Singleton<ApexManager> sApexManagerSingleton =
            new Singleton<ApexManager>() {
                @Override
@@ -521,7 +523,9 @@ public abstract class ApexManager {
                        activePackagesSet.add(packageInfo.packageName);
                    }
                    if (ai.isFactory) {
                        if (factoryPackagesSet.contains(packageInfo.packageName)) {
                        // Don't throw when the duplicating APEX is VNDK APEX
                        if (factoryPackagesSet.contains(packageInfo.packageName)
                                && !ai.moduleName.startsWith(VNDK_APEX_MODULE_NAME_PREFIX)) {
                            throw new IllegalStateException(
                                    "Two factory packages have the same name: "
                                            + packageInfo.packageName);