diff options
Diffstat (limited to 'java/app.go')
| -rwxr-xr-x | java/app.go | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/java/app.go b/java/app.go index e9941f2d2..d253a122e 100755 --- a/java/app.go +++ b/java/app.go @@ -47,6 +47,7 @@ func RegisterAppBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory) ctx.RegisterModuleType("android_app_import", AndroidAppImportFactory) ctx.RegisterModuleType("android_test_import", AndroidTestImportFactory) + ctx.RegisterModuleType("runtime_resource_overlay", RuntimeResourceOverlayFactory) } // AndroidManifest.xml merging @@ -1212,6 +1213,95 @@ func AndroidTestImportFactory() android.Module { return module } +type RuntimeResourceOverlay struct { + android.ModuleBase + android.DefaultableModuleBase + aapt + + properties RuntimeResourceOverlayProperties + + outputFile android.Path + installDir android.InstallPath +} + +type RuntimeResourceOverlayProperties struct { + // the name of a certificate in the default certificate directory or an android_app_certificate + // module name in the form ":module". + Certificate *string + + // optional theme name. If specified, the overlay package will be applied + // only when the ro.boot.vendor.overlay.theme system property is set to the same value. + Theme *string + + // if not blank, set to the version of the sdk to compile against. + // Defaults to compiling against the current platform. + Sdk_version *string + + // if not blank, set the minimum version of the sdk that the compiled artifacts will run against. + // Defaults to sdk_version if not set. + Min_sdk_version *string +} + +func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) { + sdkDep := decodeSdkDep(ctx, sdkContext(r)) + if sdkDep.hasFrameworkLibs() { + r.aapt.deps(ctx, sdkDep) + } + + cert := android.SrcIsModule(String(r.properties.Certificate)) + if cert != "" { + ctx.AddDependency(ctx.Module(), certificateTag, cert) + } +} + +func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleContext) { + // Compile and link resources + r.aapt.hasNoCode = true + r.aapt.buildActions(ctx, r) + + // Sign the built package + _, certificates := collectAppDeps(ctx, false) + certificates = processMainCert(r.ModuleBase, String(r.properties.Certificate), certificates, ctx) + signed := android.PathForModuleOut(ctx, "signed", r.Name()+".apk") + SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates) + + r.outputFile = signed + r.installDir = android.PathForModuleInstall(ctx, "overlay", String(r.properties.Theme)) + ctx.InstallFile(r.installDir, r.outputFile.Base(), r.outputFile) +} + +func (r *RuntimeResourceOverlay) sdkVersion() string { + return String(r.properties.Sdk_version) +} + +func (r *RuntimeResourceOverlay) systemModules() string { + return "" +} + +func (r *RuntimeResourceOverlay) minSdkVersion() string { + if r.properties.Min_sdk_version != nil { + return *r.properties.Min_sdk_version + } + return r.sdkVersion() +} + +func (r *RuntimeResourceOverlay) targetSdkVersion() string { + return r.sdkVersion() +} + +// runtime_resource_overlay generates a resource-only apk file that can overlay application and +// system resources at run time. +func RuntimeResourceOverlayFactory() android.Module { + module := &RuntimeResourceOverlay{} + module.AddProperties( + &module.properties, + &module.aaptProperties) + + InitJavaModule(module, android.DeviceSupported) + + return module +} + type UsesLibraryProperties struct { // A list of shared library modules that will be listed in uses-library tags in the AndroidManifest.xml file. Uses_libs []string |