Install flattened/unflattend apexes for GSI

GSI targets are supposed to have both 'flattened' and 'unflattened'
APEXes. By adding 'flattened' APEX as REQUIRED moduled for 'unflattened'
APEX, both will be installed togetther.

This is done by a new variable PRODUCT_INSTALL_EXTRA_FLATTENED_APEXES,
which is set only for GSI targets.

Bug: 137802149
Test: lunch aosp_arm64-userdebug && m
  resulting apex images under /system/apex
  and flattened apexes under /system/system_ext/apex

Change-Id: I336e2674e427b358542e0045b2a49dfa3d84095b
This commit is contained in:
Jooyung Han 2019-12-05 16:27:44 +09:00
parent 7b34ebf447
commit 3ab2c3e68c
4 changed files with 33 additions and 0 deletions

View File

@ -1091,6 +1091,10 @@ func (c *config) EnforceProductPartitionInterface() bool {
return Bool(c.productVariables.EnforceProductPartitionInterface) return Bool(c.productVariables.EnforceProductPartitionInterface)
} }
func (c *config) InstallExtraFlattenedApexes() bool {
return Bool(c.productVariables.InstallExtraFlattenedApexes)
}
func (c *config) ProductHiddenAPIStubs() []string { func (c *config) ProductHiddenAPIStubs() []string {
return c.productVariables.ProductHiddenAPIStubs return c.productVariables.ProductHiddenAPIStubs
} }

View File

@ -311,6 +311,8 @@ type productVariables struct {
MissingUsesLibraries []string `json:",omitempty"` MissingUsesLibraries []string `json:",omitempty"`
EnforceProductPartitionInterface *bool `json:",omitempty"` EnforceProductPartitionInterface *bool `json:",omitempty"`
InstallExtraFlattenedApexes *bool `json:",omitempty"`
} }
func boolPtr(v bool) *bool { func boolPtr(v bool) *bool {

View File

@ -905,6 +905,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} else { } else {
a.suffix = "" a.suffix = ""
a.primaryApexType = true a.primaryApexType = true
if ctx.Config().InstallExtraFlattenedApexes() {
a.externalDeps = append(a.externalDeps, a.Name()+flattenedSuffix)
}
} }
case zipApex: case zipApex:
if proptools.String(a.properties.Payload_type) == "zip" { if proptools.String(a.properties.Payload_type) == "zip" {

View File

@ -2458,6 +2458,29 @@ func TestApexWithTests(t *testing.T) {
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n") ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
} }
func TestInstallExtraFlattenedApexes(t *testing.T) {
ctx, config := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
`, func(fs map[string][]byte, config android.Config) {
config.TestProductVariables.InstallExtraFlattenedApexes = proptools.BoolPtr(true)
})
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
ensureListContains(t, ab.externalDeps, "myapex.flattened")
mk := android.AndroidMkDataForTest(t, config, "", ab)
var builder strings.Builder
mk.Custom(&builder, ab.Name(), "TARGET_", "", mk)
androidMk := builder.String()
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += myapex.flattened")
}
func TestApexUsesOtherApex(t *testing.T) { func TestApexUsesOtherApex(t *testing.T) {
ctx, _ := testApex(t, ` ctx, _ := testApex(t, `
apex { apex {