Merge "runtime_resource_overlay can be included in APEXes"

This commit is contained in:
Treehugger Robot 2020-04-28 17:13:26 +00:00 committed by Gerrit Code Review
commit c869812b04
3 changed files with 56 additions and 0 deletions

View file

@ -62,6 +62,7 @@ var (
certificateTag = dependencyTag{name: "certificate"}
usesTag = dependencyTag{name: "uses"}
androidAppTag = dependencyTag{name: "androidApp", payload: true}
rroTag = dependencyTag{name: "rro", payload: true}
apexAvailWl = makeApexAvailableWhitelist()
inverseApexAvailWl = invertApexWhiteList(apexAvailWl)
@ -1118,6 +1119,9 @@ type overridableProperties struct {
// List of APKs to package inside APEX
Apps []string
// List of runtime resource overlays (RROs) inside APEX
Rros []string
// Names of modules to be overridden. Listed modules can only be other binaries
// (in Make or Soong).
// This does not completely prevent installation of the overridden binaries, but if both
@ -1528,6 +1532,8 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
androidAppTag, a.overridableProperties.Apps...)
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
rroTag, a.overridableProperties.Rros...)
}
func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
@ -1745,6 +1751,21 @@ func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
return af
}
func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
rroDir := "overlay"
dirInApex := filepath.Join(rroDir, rro.Theme())
fileToCopy := rro.OutputFile()
af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
af.certificate = rro.Certificate()
if a, ok := rro.(interface {
OverriddenManifestPackageName() string
}); ok {
af.overriddenPackageName = a.OverriddenManifestPackageName()
}
return af
}
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
type flattenedApexContext struct {
android.ModuleContext
@ -2038,6 +2059,12 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} else {
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
}
case rroTag:
if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
} else {
ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
}
case prebuiltTag:
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))

View file

@ -521,6 +521,7 @@ func TestDefaults(t *testing.T) {
native_shared_libs: ["mylib"],
java_libs: ["myjar"],
apps: ["AppFoo"],
rros: ["rro"],
}
prebuilt_etc {
@ -561,12 +562,19 @@ func TestDefaults(t *testing.T) {
system_modules: "none",
apex_available: [ "myapex" ],
}
runtime_resource_overlay {
name: "rro",
theme: "blue",
}
`)
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"etc/myetc",
"javalib/myjar.jar",
"lib64/mylib.so",
"app/AppFoo/AppFoo.apk",
"overlay/blue/rro.apk",
})
}

View file

@ -1424,6 +1424,15 @@ type RuntimeResourceOverlayProperties struct {
Overrides []string
}
// RuntimeResourceOverlayModule interface is used by the apex package to gather information from
// a RuntimeResourceOverlay module.
type RuntimeResourceOverlayModule interface {
android.Module
OutputFile() android.Path
Certificate() Certificate
Theme() string
}
func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) {
sdkDep := decodeSdkDep(ctx, sdkContext(r))
if sdkDep.hasFrameworkLibs() {
@ -1476,6 +1485,18 @@ func (r *RuntimeResourceOverlay) targetSdkVersion() sdkSpec {
return r.sdkVersion()
}
func (r *RuntimeResourceOverlay) Certificate() Certificate {
return r.certificate
}
func (r *RuntimeResourceOverlay) OutputFile() android.Path {
return r.outputFile
}
func (r *RuntimeResourceOverlay) Theme() string {
return String(r.properties.Theme)
}
// runtime_resource_overlay generates a resource-only apk file that can overlay application and
// system resources at run time.
func RuntimeResourceOverlayFactory() android.Module {