Include partition tag in apexkeys.txt.

The partition tag helps merge_target_files.py determine
which apexkeys.txt to select from the framework partial
target files and which to select from the vendor partial
target files. The partition tag is the pysical partition
name, for example, a system_ext module on a device where
system_ext is at system/system_ext has a system
partition tag.

Bug: 138942268
Change-Id: Ia07887b34f1aa77dae94ef23610dfef83c1a5849
This commit is contained in:
Bill Peckham 2020-03-20 18:33:20 -07:00
parent 58d1090032
commit fff3f8a3f8
2 changed files with 39 additions and 4 deletions

View File

@ -894,6 +894,40 @@ func (m *ModuleBase) SystemExtSpecific() bool {
return Bool(m.commonProperties.System_ext_specific)
}
func (m *ModuleBase) PartitionTag(config DeviceConfig) string {
partition := "system"
if m.SocSpecific() {
// A SoC-specific module could be on the vendor partition at
// "vendor" or the system partition at "system/vendor".
if config.VendorPath() == "vendor" {
partition = "vendor"
}
} else if m.DeviceSpecific() {
// A device-specific module could be on the odm partition at
// "odm", the vendor partition at "vendor/odm", or the system
// partition at "system/vendor/odm".
if config.OdmPath() == "odm" {
partition = "odm"
} else if strings.HasPrefix(config.OdmPath (), "vendor/") {
partition = "vendor"
}
} else if m.ProductSpecific() {
// A product-specific module could be on the product partition
// at "product" or the system partition at "system/product".
if config.ProductPath() == "product" {
partition = "product"
}
} else if m.SystemExtSpecific() {
// A system_ext-specific module could be on the system_ext
// partition at "system_ext" or the system partition at
// "system/system_ext".
if config.SystemExtPath() == "system_ext" {
partition = "system_ext"
}
}
return partition
}
func (m *ModuleBase) Enabled() bool {
if m.commonProperties.Enabled == nil {
return !m.Os().DefaultDisabled

View File

@ -133,17 +133,18 @@ func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
module := apexModulesMap[key]
if m, ok := module.(*apexBundle); ok {
fmt.Fprintf(&filecontent,
"name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q\\n",
"name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\\n",
m.Name()+".apex",
m.public_key_file.String(),
m.private_key_file.String(),
m.container_certificate_file.String(),
m.container_private_key_file.String())
m.container_private_key_file.String(),
m.PartitionTag(ctx.DeviceConfig()))
} else if m, ok := module.(*Prebuilt); ok {
fmt.Fprintf(&filecontent,
"name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q\\n",
"name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\\n",
m.InstallFilename(),
"PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED")
"PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", m.PartitionTag(ctx.DeviceConfig()))
}
}