apex: prebuilt_firmware installs in /etc/firmware

Installation path of prebuilt_firmware varies accoding to target
partitions. When it is for system, it installs a file in
/system/etc/firmware while it installs in /vendor/firmware for vendor.

We'd better be consistent about installation path when it is
for APEXes regardless of target partition. Otherwise, ueventd would need
to scan both /apex/*/etc/firmware and /apex/*/firmware.

Having /etc prefix for prebuilt modules helps module owners to predict
the layout of the contents.

Bug: 162701747
Bug: 167942098
Test: soong tests
Test: loading vibrator firmware from vibrator apex (sunfish)
Change-Id: I7a7105026426f8a7a156bc947304930f761c81f3
This commit is contained in:
Jooyung Han 2020-09-21 11:02:57 +09:00
parent 41243c1d5f
commit 8e5685ddca
2 changed files with 42 additions and 32 deletions

View File

@ -2282,30 +2282,40 @@ func TestVendorApex_use_vndk_as_stable(t *testing.T) {
ensureListContains(t, requireNativeLibs, ":vndk") ensureListContains(t, requireNativeLibs, ":vndk")
} }
func TestVendorApex_withPrebuiltFirmware(t *testing.T) { func TestApex_withPrebuiltFirmware(t *testing.T) {
ctx, _ := testApex(t, ` testCases := []struct {
apex { name string
name: "myapex", additionalProp string
key: "myapex.key", }{
prebuilts: ["myfirmware"], {"system apex with prebuilt_firmware", ""},
vendor: true, {"vendor apex with prebuilt_firmware", "vendor: true,"},
} }
apex_key { for _, tc := range testCases {
name: "myapex.key", t.Run(tc.name, func(t *testing.T) {
public_key: "testkey.avbpubkey", ctx, _ := testApex(t, `
private_key: "testkey.pem", apex {
} name: "myapex",
prebuilt_firmware { key: "myapex.key",
name: "myfirmware", prebuilts: ["myfirmware"],
src: "myfirmware.bin", `+tc.additionalProp+`
filename_from_src: true, }
vendor: true, apex_key {
} name: "myapex.key",
`) public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ }
"firmware/myfirmware.bin", prebuilt_firmware {
}) name: "myfirmware",
src: "myfirmware.bin",
filename_from_src: true,
`+tc.additionalProp+`
}
`)
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"etc/firmware/myfirmware.bin",
})
})
}
} }
func TestAndroidMk_UseVendorRequired(t *testing.T) { func TestAndroidMk_UseVendorRequired(t *testing.T) {

View File

@ -172,13 +172,7 @@ func (p *PrebuiltEtc) SubDir() string {
} }
func (p *PrebuiltEtc) BaseDir() string { func (p *PrebuiltEtc) BaseDir() string {
// If soc install dir was specified and SOC specific is set, set the installDirPath to the specified return p.installDirBase
// socInstallDirBase.
installBaseDir := p.installDirBase
if p.SocSpecific() && p.socInstallDirBase != "" {
installBaseDir = p.socInstallDirBase
}
return installBaseDir
} }
func (p *PrebuiltEtc) Installable() bool { func (p *PrebuiltEtc) Installable() bool {
@ -205,7 +199,13 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir") ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
} }
p.installDirPath = android.PathForModuleInstall(ctx, p.BaseDir(), p.SubDir()) // If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
// socInstallDirBase.
installBaseDir := p.installDirBase
if p.SocSpecific() && p.socInstallDirBase != "" {
installBaseDir = p.socInstallDirBase
}
p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
// This ensures that outputFilePath has the correct name for others to // This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name. // use, as the source file may have a different name.