Merge "enforce updatable apexes to set min_sdk_version" am: 4783297585

Change-Id: I45112b8d0d4c3b0d51ec41c604559d82913a8cdd
This commit is contained in:
Treehugger Robot
2020-04-27 10:07:57 +00:00
committed by Automerger Merge Worker
2 changed files with 32 additions and 2 deletions

View File

@@ -1021,8 +1021,10 @@ type apexBundleProperties struct {
IsCoverageVariant bool `blueprint:"mutated"` IsCoverageVariant bool `blueprint:"mutated"`
// Whether this APEX is considered updatable or not. When set to true, this will enforce additional // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
// rules for making sure that the APEX is truely updatable. This will also disable the size optimizations // rules for making sure that the APEX is truly updatable.
// like symlinking to the system libs. Default is false. // - To be updatable, min_sdk_version should be set as well
// This will also disable the size optimizations like symlinking to the system libs.
// Default is false.
Updatable *bool Updatable *bool
// The minimum SDK version that this apex must be compatibile with. // The minimum SDK version that this apex must be compatibile with.
@@ -1794,6 +1796,14 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
}) })
} }
func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
if proptools.Bool(a.properties.Updatable) {
if String(a.properties.Min_sdk_version) == "" {
ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
}
}
}
// Collects the list of module names that directly or indirectly contributes to the payload of this APEX // Collects the list of module names that directly or indirectly contributes to the payload of this APEX
func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) { func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) {
a.depInfos = make(map[string]depInfo) a.depInfos = make(map[string]depInfo)
@@ -1859,6 +1869,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} }
a.checkApexAvailability(ctx) a.checkApexAvailability(ctx)
a.checkUpdatable(ctx)
a.collectDepsInfo(ctx) a.collectDepsInfo(ctx)

View File

@@ -4099,6 +4099,7 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
native_shared_libs: ["mylib"], native_shared_libs: ["mylib"],
java_libs: ["myjar"], java_libs: ["myjar"],
updatable: true, updatable: true,
min_sdk_version: "current",
} }
apex_key { apex_key {
@@ -4396,6 +4397,22 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg, bp string, transformDe
} }
} }
func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
apex {
name: "myapex",
key: "myapex.key",
updatable: true,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
`)
}
func TestNoUpdatableJarsInBootImage(t *testing.T) { func TestNoUpdatableJarsInBootImage(t *testing.T) {
bp := ` bp := `
java_library { java_library {
@@ -4434,6 +4451,7 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
key: "some-updatable-apex.key", key: "some-updatable-apex.key",
java_libs: ["some-updatable-apex-lib"], java_libs: ["some-updatable-apex-lib"],
updatable: true, updatable: true,
min_sdk_version: "current",
} }
apex { apex {
@@ -4455,6 +4473,7 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
key: "com.android.art.something.key", key: "com.android.art.something.key",
java_libs: ["some-art-lib"], java_libs: ["some-art-lib"],
updatable: true, updatable: true,
min_sdk_version: "current",
} }
apex_key { apex_key {