Loading android/apex.go +8 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ type ApexInfo struct { ApexName string MinSdkVersion int Updatable bool } // Extracted from ApexModule to make it easier to define custom subsets of the Loading Loading @@ -116,6 +117,9 @@ type ApexModule interface { // it returns 9 as string ChooseSdkVersion(versionList []string, maxSdkVersion int) (string, error) // Tests if the module comes from an updatable APEX. Updatable() bool // List of APEXes that this module tests. The module has access to // the private part of the listed APEXes even when it is not included in the // APEXes. Loading Loading @@ -260,6 +264,10 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) { } } func (m *ApexModuleBase) Updatable() bool { return m.ApexProperties.Info.Updatable } type byApexName []ApexInfo func (a byApexName) Len() int { return len(a) } Loading apex/apex.go +1 −0 Original line number Diff line number Diff line Loading @@ -785,6 +785,7 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { apexBundles = []android.ApexInfo{{ ApexName: mctx.ModuleName(), MinSdkVersion: a.minSdkVersion(mctx), Updatable: proptools.Bool(a.properties.Updatable), }} directDep = true } else if am, ok := mctx.Module().(android.ApexModule); ok { Loading apex/apex_test.go +44 −1 Original line number Diff line number Diff line Loading @@ -4437,6 +4437,13 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg, bp string, transformDe "system/sepolicy/apex/some-updatable-apex-file_contexts", ], } filegroup { name: "some-non-updatable-apex-file_contexts", srcs: [ "system/sepolicy/apex/some-non-updatable-apex-file_contexts", ], } ` bp += cc.GatherRequiredDepsForTest(android.Android) bp += java.GatherRequiredDepsForTest() Loading @@ -4449,6 +4456,7 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg, bp string, transformDe "apex_manifest.json": nil, "AndroidManifest.xml": nil, "system/sepolicy/apex/some-updatable-apex-file_contexts": nil, "system/sepolicy/apex/some-non-updatable-apex-file_contexts": nil, "system/sepolicy/apex/com.android.art.something-file_contexts": nil, "framework/aidl/a.aidl": nil, } Loading Loading @@ -4519,6 +4527,14 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { ], } java_library { name: "some-non-updatable-apex-lib", srcs: ["a.java"], apex_available: [ "some-non-updatable-apex", ], } java_library { name: "some-platform-lib", srcs: ["a.java"], Loading @@ -4540,16 +4556,30 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { name: "some-updatable-apex", key: "some-updatable-apex.key", java_libs: ["some-updatable-apex-lib"], updatable: true, min_sdk_version: "current", } apex { name: "some-non-updatable-apex", key: "some-non-updatable-apex.key", java_libs: ["some-non-updatable-apex-lib"], } apex_key { name: "some-updatable-apex.key", } apex_key { name: "some-non-updatable-apex.key", } apex { name: "com.android.art.something", key: "com.android.art.something.key", java_libs: ["some-art-lib"], updatable: true, min_sdk_version: "current", } apex_key { Loading Loading @@ -4580,6 +4610,13 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { } testNoUpdatableJarsInBootImage(t, error, bp, transform) // non-updatable jar from some other apex in the ART boot image => error error = "module 'some-non-updatable-apex-lib' is not allowed in the ART boot image" transform = func(config *dexpreopt.GlobalConfig) { config.ArtApexJars = []string{"some-non-updatable-apex-lib"} } testNoUpdatableJarsInBootImage(t, error, bp, transform) // updatable jar from some other apex in the framework boot image => error error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the framework boot image" transform = func(config *dexpreopt.GlobalConfig) { Loading @@ -4587,6 +4624,12 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { } testNoUpdatableJarsInBootImage(t, error, bp, transform) // non-updatable jar from some other apex in the framework boot image => ok transform = func(config *dexpreopt.GlobalConfig) { config.BootJars = []string{"some-non-updatable-apex-lib"} } testNoUpdatableJarsInBootImage(t, "", bp, transform) // nonexistent jar in the ART boot image => error error = "failed to find a dex jar path for module 'nonexistent'" transform = func(config *dexpreopt.GlobalConfig) { Loading @@ -4602,7 +4645,7 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { testNoUpdatableJarsInBootImage(t, error, bp, transform) // platform jar in the ART boot image => error error = "module 'some-platform-lib' is part of the platform and not allowed in the ART boot image" error = "module 'some-platform-lib' is not allowed in the ART boot image" transform = func(config *dexpreopt.GlobalConfig) { config.ArtApexJars = []string{"some-platform-lib"} } Loading java/dexpreopt_bootjars.go +12 −11 Original line number Diff line number Diff line Loading @@ -264,27 +264,28 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul // Check that this module satisfies constraints for a particular boot image. apex, isApexModule := module.(android.ApexModule) fromUpdatableApex := isApexModule && apex.Updatable() if image.name == artBootImageName { if isApexModule && strings.HasPrefix(apex.ApexName(), "com.android.art.") { // ok, found the jar in the ART apex } else if isApexModule && !apex.IsForPlatform() { // this jar is part of an updatable apex other than ART, fail immediately ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexName()) // ok: found the jar in the ART apex } else if isApexModule && apex.IsForPlatform() && Bool(module.(*Library).deviceProperties.Hostdex) { // this is a special "hostdex" variant, skip it and resume search // exception (skip and continue): special "hostdex" platform variant return -1, nil } else if name == "jacocoagent" && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { // this is Jacoco platform variant for a coverage build, skip it and resume search // exception (skip and continue): Jacoco platform variant for a coverage build return -1, nil } else if fromUpdatableApex { // error: this jar is part of an updatable apex other than ART ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexName()) } else { // this (installable) jar is part of the platform, fail immediately ctx.Errorf("module '%s' is part of the platform and not allowed in the ART boot image", name) // error: this jar is part of the platform or a non-updatable apex ctx.Errorf("module '%s' is not allowed in the ART boot image", name) } } else if image.name == frameworkBootImageName { if !isApexModule || apex.IsForPlatform() { // ok, this jar is part of the platform if !fromUpdatableApex { // ok: this jar is part of the platform or a non-updatable apex } else { // this jar is part of an updatable apex, fail immediately // error: this jar is part of an updatable apex ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the framework boot image", name, apex.ApexName()) } } else { Loading Loading
android/apex.go +8 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ type ApexInfo struct { ApexName string MinSdkVersion int Updatable bool } // Extracted from ApexModule to make it easier to define custom subsets of the Loading Loading @@ -116,6 +117,9 @@ type ApexModule interface { // it returns 9 as string ChooseSdkVersion(versionList []string, maxSdkVersion int) (string, error) // Tests if the module comes from an updatable APEX. Updatable() bool // List of APEXes that this module tests. The module has access to // the private part of the listed APEXes even when it is not included in the // APEXes. Loading Loading @@ -260,6 +264,10 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) { } } func (m *ApexModuleBase) Updatable() bool { return m.ApexProperties.Info.Updatable } type byApexName []ApexInfo func (a byApexName) Len() int { return len(a) } Loading
apex/apex.go +1 −0 Original line number Diff line number Diff line Loading @@ -785,6 +785,7 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { apexBundles = []android.ApexInfo{{ ApexName: mctx.ModuleName(), MinSdkVersion: a.minSdkVersion(mctx), Updatable: proptools.Bool(a.properties.Updatable), }} directDep = true } else if am, ok := mctx.Module().(android.ApexModule); ok { Loading
apex/apex_test.go +44 −1 Original line number Diff line number Diff line Loading @@ -4437,6 +4437,13 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg, bp string, transformDe "system/sepolicy/apex/some-updatable-apex-file_contexts", ], } filegroup { name: "some-non-updatable-apex-file_contexts", srcs: [ "system/sepolicy/apex/some-non-updatable-apex-file_contexts", ], } ` bp += cc.GatherRequiredDepsForTest(android.Android) bp += java.GatherRequiredDepsForTest() Loading @@ -4449,6 +4456,7 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg, bp string, transformDe "apex_manifest.json": nil, "AndroidManifest.xml": nil, "system/sepolicy/apex/some-updatable-apex-file_contexts": nil, "system/sepolicy/apex/some-non-updatable-apex-file_contexts": nil, "system/sepolicy/apex/com.android.art.something-file_contexts": nil, "framework/aidl/a.aidl": nil, } Loading Loading @@ -4519,6 +4527,14 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { ], } java_library { name: "some-non-updatable-apex-lib", srcs: ["a.java"], apex_available: [ "some-non-updatable-apex", ], } java_library { name: "some-platform-lib", srcs: ["a.java"], Loading @@ -4540,16 +4556,30 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { name: "some-updatable-apex", key: "some-updatable-apex.key", java_libs: ["some-updatable-apex-lib"], updatable: true, min_sdk_version: "current", } apex { name: "some-non-updatable-apex", key: "some-non-updatable-apex.key", java_libs: ["some-non-updatable-apex-lib"], } apex_key { name: "some-updatable-apex.key", } apex_key { name: "some-non-updatable-apex.key", } apex { name: "com.android.art.something", key: "com.android.art.something.key", java_libs: ["some-art-lib"], updatable: true, min_sdk_version: "current", } apex_key { Loading Loading @@ -4580,6 +4610,13 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { } testNoUpdatableJarsInBootImage(t, error, bp, transform) // non-updatable jar from some other apex in the ART boot image => error error = "module 'some-non-updatable-apex-lib' is not allowed in the ART boot image" transform = func(config *dexpreopt.GlobalConfig) { config.ArtApexJars = []string{"some-non-updatable-apex-lib"} } testNoUpdatableJarsInBootImage(t, error, bp, transform) // updatable jar from some other apex in the framework boot image => error error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the framework boot image" transform = func(config *dexpreopt.GlobalConfig) { Loading @@ -4587,6 +4624,12 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { } testNoUpdatableJarsInBootImage(t, error, bp, transform) // non-updatable jar from some other apex in the framework boot image => ok transform = func(config *dexpreopt.GlobalConfig) { config.BootJars = []string{"some-non-updatable-apex-lib"} } testNoUpdatableJarsInBootImage(t, "", bp, transform) // nonexistent jar in the ART boot image => error error = "failed to find a dex jar path for module 'nonexistent'" transform = func(config *dexpreopt.GlobalConfig) { Loading @@ -4602,7 +4645,7 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { testNoUpdatableJarsInBootImage(t, error, bp, transform) // platform jar in the ART boot image => error error = "module 'some-platform-lib' is part of the platform and not allowed in the ART boot image" error = "module 'some-platform-lib' is not allowed in the ART boot image" transform = func(config *dexpreopt.GlobalConfig) { config.ArtApexJars = []string{"some-platform-lib"} } Loading
java/dexpreopt_bootjars.go +12 −11 Original line number Diff line number Diff line Loading @@ -264,27 +264,28 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul // Check that this module satisfies constraints for a particular boot image. apex, isApexModule := module.(android.ApexModule) fromUpdatableApex := isApexModule && apex.Updatable() if image.name == artBootImageName { if isApexModule && strings.HasPrefix(apex.ApexName(), "com.android.art.") { // ok, found the jar in the ART apex } else if isApexModule && !apex.IsForPlatform() { // this jar is part of an updatable apex other than ART, fail immediately ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexName()) // ok: found the jar in the ART apex } else if isApexModule && apex.IsForPlatform() && Bool(module.(*Library).deviceProperties.Hostdex) { // this is a special "hostdex" variant, skip it and resume search // exception (skip and continue): special "hostdex" platform variant return -1, nil } else if name == "jacocoagent" && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { // this is Jacoco platform variant for a coverage build, skip it and resume search // exception (skip and continue): Jacoco platform variant for a coverage build return -1, nil } else if fromUpdatableApex { // error: this jar is part of an updatable apex other than ART ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexName()) } else { // this (installable) jar is part of the platform, fail immediately ctx.Errorf("module '%s' is part of the platform and not allowed in the ART boot image", name) // error: this jar is part of the platform or a non-updatable apex ctx.Errorf("module '%s' is not allowed in the ART boot image", name) } } else if image.name == frameworkBootImageName { if !isApexModule || apex.IsForPlatform() { // ok, this jar is part of the platform if !fromUpdatableApex { // ok: this jar is part of the platform or a non-updatable apex } else { // this jar is part of an updatable apex, fail immediately // error: this jar is part of an updatable apex ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the framework boot image", name, apex.ApexName()) } } else { Loading