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() {
if !Bool(m.commonProperties.Vendor) && !Bool(m.commonProperties.Product_specific) {
m.commonProperties.Vendor = boolPtr(false)
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"

View File

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

View File

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