Loading core/java/com/android/internal/content/om/OverlayConfig.java +0 −8 Original line number Diff line number Diff line Loading @@ -140,7 +140,6 @@ public class OverlayConfig { ArrayMap<Integer, List<String>> activeApexesPerPartition = getActiveApexes(partitions); boolean foundConfigFile = false; final Map<String, ParsedOverlayInfo> packageManagerOverlayInfos = packageProvider == null ? null : getOverlayPackageInfos(packageProvider); Loading @@ -154,7 +153,6 @@ public class OverlayConfig { activeApexesPerPartition.getOrDefault(partition.type, Collections.emptyList())); if (partitionOverlays != null) { foundConfigFile = true; overlays.addAll(partitionOverlays); continue; } Loading Loading @@ -191,12 +189,6 @@ public class OverlayConfig { overlays.addAll(partitionConfigs); } if (!foundConfigFile) { // If no overlay configuration files exist, disregard partition precedence and allow // android:priority to reorder overlays across partition boundaries. overlays.sort(sStaticOverlayComparator); } for (int i = 0, n = overlays.size(); i < n; i++) { // Add the configurations to a map so definitions of an overlay in an earlier // partition can be replaced by an overlay with the same package name in a later Loading core/tests/coretests/src/com/android/internal/content/res/OverlayConfigTest.java +55 −35 Original line number Diff line number Diff line Loading @@ -285,6 +285,39 @@ public class OverlayConfigTest { assertConfig(overlayConfig, "five", true, true, 4); } @Test public void testPartialConfigPartitionPrecedence() throws IOException { createFile("/odm/overlay/config/config.xml", "<config>" + " <overlay package=\"two\" enabled=\"true\" />" + "</config>"); mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/odm/overlay/two.apk"), "two"); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", false, true, 2); } @Test public void testNoConfigPartitionPrecedence() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/odm/overlay/two.apk"), "two", "android", 0, true, 2); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); assertConfig(overlayConfig, "three", false, true, 2); } @Test public void testImmutable() throws IOException { createFile("/product/overlay/config/config.xml", Loading Loading @@ -506,37 +539,6 @@ public class OverlayConfigTest { assertConfig(overlayConfig, "two", false, true, 1); } @Test public void testNoConfigsAllowPartitionReordering() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/product/overlay/two.apk"), "two", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 1); assertConfig(overlayConfig, "two", false, true, 0); } @Test public void testConfigDisablesPartitionReordering() throws IOException { createFile("/odm/overlay/config/config.xml", "<config>" + " <overlay package=\"two\" enabled=\"true\" />" + "</config>"); mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/odm/overlay/two.apk"), "two"); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", false, true, 2); } @Test public void testStaticOverlayOutsideOverlayDir() throws IOException { mScannerRule.addOverlay(createFile("/product/app/one.apk"), "one", "android", 0, true, 0); Loading @@ -550,7 +552,7 @@ public class OverlayConfigTest { @Test public void testSortStaticOverlaysDifferentTargets() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "other", 0, true, 0); mScannerRule.addOverlay(createFile("/product/overlay/two.apk"), "two", "android", 0, true, mScannerRule.addOverlay(createFile("/vendor/overlay/two.apk"), "two", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); Loading @@ -558,16 +560,34 @@ public class OverlayConfigTest { assertConfig(overlayConfig, "two", false, true, 0); } @Test public void testSortStaticOverlaysDifferentPartitions() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 2); mScannerRule.addOverlay(createFile("/vendor/overlay/two.apk"), "two", "android", 0, true, 3); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); mScannerRule.addOverlay(createFile("/product/overlay/four.apk"), "four", "android", 0, true, 1); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); assertConfig(overlayConfig, "three", false, true, 2); assertConfig(overlayConfig, "four", false, true, 3); } @Test public void testSortStaticOverlaysSamePriority() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 0); mScannerRule.addOverlay(createFile("/product/overlay/two.apk"), "two", "android", 0, true, mScannerRule.addOverlay(createFile("/vendor/overlay/two.apk"), "two", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 1); assertConfig(overlayConfig, "two", false, true, 0); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); } @Test Loading Loading
core/java/com/android/internal/content/om/OverlayConfig.java +0 −8 Original line number Diff line number Diff line Loading @@ -140,7 +140,6 @@ public class OverlayConfig { ArrayMap<Integer, List<String>> activeApexesPerPartition = getActiveApexes(partitions); boolean foundConfigFile = false; final Map<String, ParsedOverlayInfo> packageManagerOverlayInfos = packageProvider == null ? null : getOverlayPackageInfos(packageProvider); Loading @@ -154,7 +153,6 @@ public class OverlayConfig { activeApexesPerPartition.getOrDefault(partition.type, Collections.emptyList())); if (partitionOverlays != null) { foundConfigFile = true; overlays.addAll(partitionOverlays); continue; } Loading Loading @@ -191,12 +189,6 @@ public class OverlayConfig { overlays.addAll(partitionConfigs); } if (!foundConfigFile) { // If no overlay configuration files exist, disregard partition precedence and allow // android:priority to reorder overlays across partition boundaries. overlays.sort(sStaticOverlayComparator); } for (int i = 0, n = overlays.size(); i < n; i++) { // Add the configurations to a map so definitions of an overlay in an earlier // partition can be replaced by an overlay with the same package name in a later Loading
core/tests/coretests/src/com/android/internal/content/res/OverlayConfigTest.java +55 −35 Original line number Diff line number Diff line Loading @@ -285,6 +285,39 @@ public class OverlayConfigTest { assertConfig(overlayConfig, "five", true, true, 4); } @Test public void testPartialConfigPartitionPrecedence() throws IOException { createFile("/odm/overlay/config/config.xml", "<config>" + " <overlay package=\"two\" enabled=\"true\" />" + "</config>"); mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/odm/overlay/two.apk"), "two"); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", false, true, 2); } @Test public void testNoConfigPartitionPrecedence() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/odm/overlay/two.apk"), "two", "android", 0, true, 2); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); assertConfig(overlayConfig, "three", false, true, 2); } @Test public void testImmutable() throws IOException { createFile("/product/overlay/config/config.xml", Loading Loading @@ -506,37 +539,6 @@ public class OverlayConfigTest { assertConfig(overlayConfig, "two", false, true, 1); } @Test public void testNoConfigsAllowPartitionReordering() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/product/overlay/two.apk"), "two", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 1); assertConfig(overlayConfig, "two", false, true, 0); } @Test public void testConfigDisablesPartitionReordering() throws IOException { createFile("/odm/overlay/config/config.xml", "<config>" + " <overlay package=\"two\" enabled=\"true\" />" + "</config>"); mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 1); mScannerRule.addOverlay(createFile("/odm/overlay/two.apk"), "two"); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", false, true, 2); } @Test public void testStaticOverlayOutsideOverlayDir() throws IOException { mScannerRule.addOverlay(createFile("/product/app/one.apk"), "one", "android", 0, true, 0); Loading @@ -550,7 +552,7 @@ public class OverlayConfigTest { @Test public void testSortStaticOverlaysDifferentTargets() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "other", 0, true, 0); mScannerRule.addOverlay(createFile("/product/overlay/two.apk"), "two", "android", 0, true, mScannerRule.addOverlay(createFile("/vendor/overlay/two.apk"), "two", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); Loading @@ -558,16 +560,34 @@ public class OverlayConfigTest { assertConfig(overlayConfig, "two", false, true, 0); } @Test public void testSortStaticOverlaysDifferentPartitions() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 2); mScannerRule.addOverlay(createFile("/vendor/overlay/two.apk"), "two", "android", 0, true, 3); mScannerRule.addOverlay(createFile("/product/overlay/three.apk"), "three", "android", 0, true, 0); mScannerRule.addOverlay(createFile("/product/overlay/four.apk"), "four", "android", 0, true, 1); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); assertConfig(overlayConfig, "three", false, true, 2); assertConfig(overlayConfig, "four", false, true, 3); } @Test public void testSortStaticOverlaysSamePriority() throws IOException { mScannerRule.addOverlay(createFile("/vendor/overlay/one.apk"), "one", "android", 0, true, 0); mScannerRule.addOverlay(createFile("/product/overlay/two.apk"), "two", "android", 0, true, mScannerRule.addOverlay(createFile("/vendor/overlay/two.apk"), "two", "android", 0, true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 1); assertConfig(overlayConfig, "two", false, true, 0); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); } @Test Loading