Remove cc.moduleContext override of android.ModuleContext.*Specific

Overriding android.ModuleContext's implementations of *Specific()
methods in cc.moduleContext and then passing that back to
android.PathForModuleInstall to affect the install path causes
problems if android.ModuleBase.GenerateBuildActions also tries
to call android.PathForModuleInstall directly with the
android.ModuleContext as it gets a different result.

Add InstallIn* methods to the android.Module interface, implement
default versions in android.ModuleBase, and override them in
cc.Module and rust.Module.  Use them in android.PathsForModuleInstall
to allow the module to customize the behavior directly.

Test: TestInstallPartition
Change-Id: I7840e07eae34ac4f4d3490b021143d5f33a83626
This commit is contained in:
Colin Cross
2023-11-29 16:00:16 -08:00
parent 51428c451a
commit ea30d85a65
6 changed files with 63 additions and 29 deletions

View File

@@ -111,6 +111,9 @@ type ModuleInstallPathContext interface {
InstallInDebugRamdisk() bool
InstallInRecovery() bool
InstallInRoot() bool
InstallInOdm() bool
InstallInProduct() bool
InstallInVendor() bool
InstallForceOS() (*OsType, *ArchType)
}
@@ -152,6 +155,18 @@ func (ctx *baseModuleContextToModuleInstallPathContext) InstallInRoot() bool {
return ctx.Module().InstallInRoot()
}
func (ctx *baseModuleContextToModuleInstallPathContext) InstallInOdm() bool {
return ctx.Module().InstallInOdm()
}
func (ctx *baseModuleContextToModuleInstallPathContext) InstallInProduct() bool {
return ctx.Module().InstallInProduct()
}
func (ctx *baseModuleContextToModuleInstallPathContext) InstallInVendor() bool {
return ctx.Module().InstallInVendor()
}
func (ctx *baseModuleContextToModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
return ctx.Module().InstallForceOS()
}
@@ -1866,11 +1881,11 @@ func modulePartition(ctx ModuleInstallPathContext, device bool) string {
// the layout of recovery partion is the same as that of system partition
partition = "recovery/root/system"
}
} else if ctx.SocSpecific() {
} else if ctx.SocSpecific() || ctx.InstallInVendor() {
partition = ctx.DeviceConfig().VendorPath()
} else if ctx.DeviceSpecific() {
} else if ctx.DeviceSpecific() || ctx.InstallInOdm() {
partition = ctx.DeviceConfig().OdmPath()
} else if ctx.ProductSpecific() {
} else if ctx.ProductSpecific() || ctx.InstallInProduct() {
partition = ctx.DeviceConfig().ProductPath()
} else if ctx.SystemExtSpecific() {
partition = ctx.DeviceConfig().SystemExtPath()
@@ -2066,6 +2081,9 @@ type testModuleInstallPathContext struct {
inDebugRamdisk bool
inRecovery bool
inRoot bool
inOdm bool
inProduct bool
inVendor bool
forceOS *OsType
forceArch *ArchType
}
@@ -2108,6 +2126,18 @@ func (m testModuleInstallPathContext) InstallInRoot() bool {
return m.inRoot
}
func (m testModuleInstallPathContext) InstallInOdm() bool {
return m.inOdm
}
func (m testModuleInstallPathContext) InstallInProduct() bool {
return m.inProduct
}
func (m testModuleInstallPathContext) InstallInVendor() bool {
return m.inVendor
}
func (m testModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
return m.forceOS, m.forceArch
}