Merge "Fix: install flattened apex on system_ext"

This commit is contained in:
Jooyung Han
2019-11-27 07:30:54 +00:00
committed by Gerrit Code Review
3 changed files with 44 additions and 33 deletions

View File

@@ -1533,9 +1533,11 @@ func (m *ModuleBase) EnableNativeBridgeSupportByDefault() {
} }
func (m *ModuleBase) MakeAsSystemExt() { func (m *ModuleBase) MakeAsSystemExt() {
if !Bool(m.commonProperties.Vendor) && !Bool(m.commonProperties.Product_specific) { m.commonProperties.Vendor = boolPtr(false)
m.commonProperties.System_ext_specific = boolPtr(true) m.commonProperties.Proprietary = boolPtr(false)
} m.commonProperties.Soc_specific = boolPtr(false)
m.commonProperties.Product_specific = boolPtr(false)
m.commonProperties.System_ext_specific = boolPtr(true)
} }
// IsNativeBridgeSupported returns true if "native_bridge_supported" is explicitly set as "true" // IsNativeBridgeSupported returns true if "native_bridge_supported" is explicitly set as "true"

View File

@@ -178,7 +178,7 @@ func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
modules[i].(*apexBundle).properties.ApexType = zipApex modules[i].(*apexBundle).properties.ApexType = zipApex
case flattenedApexType: case flattenedApexType:
modules[i].(*apexBundle).properties.ApexType = flattenedApex modules[i].(*apexBundle).properties.ApexType = flattenedApex
if !mctx.Config().FlattenApex() { if !mctx.Config().FlattenApex() && ab.Platform() {
modules[i].(*apexBundle).MakeAsSystemExt() modules[i].(*apexBundle).MakeAsSystemExt()
} }
} }

View File

@@ -2144,38 +2144,47 @@ func TestApexWithShBinary(t *testing.T) {
ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh") ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh")
} }
func TestApexInProductPartition(t *testing.T) { func TestApexInVariousPartition(t *testing.T) {
ctx, _ := testApex(t, ` testcases := []struct {
apex { propName, parition, flattenedPartition string
name: "myapex", }{
key: "myapex.key", {"", "system", "system_ext"},
native_shared_libs: ["mylib"], {"product_specific: true", "product", "product"},
product_specific: true, {"soc_specific: true", "vendor", "vendor"},
file_contexts: "myapex_file_contexts", {"proprietary: true", "vendor", "vendor"},
} {"vendor: true", "vendor", "vendor"},
{"system_ext_specific: true", "system_ext", "system_ext"},
}
for _, tc := range testcases {
t.Run(tc.propName+":"+tc.parition, func(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
`+tc.propName+`
}
apex_key { apex_key {
name: "myapex.key", name: "myapex.key",
public_key: "testkey.avbpubkey", public_key: "testkey.avbpubkey",
private_key: "testkey.pem", private_key: "testkey.pem",
product_specific: true, }
} `)
cc_library { apex := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
name: "mylib", expected := buildDir + "/target/product/test_device/" + tc.parition + "/apex"
srcs: ["mylib.cpp"], actual := apex.installDir.String()
system_shared_libs: [], if actual != expected {
stl: "none", t.Errorf("wrong install path. expected %q. actual %q", expected, actual)
} }
`, withFiles(map[string][]byte{
"myapex_file_contexts": nil,
}))
apex := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) flattened := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
expected := buildDir + "/target/product/test_device/product/apex" expected = buildDir + "/target/product/test_device/" + tc.flattenedPartition + "/apex"
actual := apex.installDir.String() actual = flattened.installDir.String()
if actual != expected { if actual != expected {
t.Errorf("wrong install path. expected %q. actual %q", expected, actual) t.Errorf("wrong install path. expected %q. actual %q", expected, actual)
}
})
} }
} }