Dist NOTICE outputs for app targets.
Bug: 136501164
Test: m NetworkStack, TreeHugger
Change-Id: I2279eeb0e50b1b5685e23130a8da6ab090f37f56
diff --git a/java/app.go b/java/app.go
index f58b0f8..e12b56c 100644
--- a/java/app.go
+++ b/java/app.go
@@ -141,6 +141,8 @@
installApkName string
additionalAaptFlags []string
+
+ noticeOutputs android.NoticeOutputs
}
func (a *AndroidApp) ExportedProguardFlagFiles() android.Paths {
@@ -357,11 +359,7 @@
return jniJarFile
}
-func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext, installDir android.OutputPath) android.OptionalPath {
- if !Bool(a.appProperties.Embed_notices) && !ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
- return android.OptionalPath{}
- }
-
+func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext, installDir android.OutputPath) {
// Collect NOTICE files from all dependencies.
seenModules := make(map[android.Module]bool)
noticePathSet := make(map[android.Path]bool)
@@ -391,7 +389,7 @@
}
if len(noticePathSet) == 0 {
- return android.OptionalPath{}
+ return
}
var noticePaths []android.Path
for path := range noticePathSet {
@@ -400,9 +398,8 @@
sort.Slice(noticePaths, func(i, j int) bool {
return noticePaths[i].String() < noticePaths[j].String()
})
- noticeFile := android.BuildNoticeOutput(ctx, installDir, a.installApkName+".apk", noticePaths)
- return android.OptionalPathForPath(noticeFile)
+ a.noticeOutputs = android.BuildNoticeOutput(ctx, installDir, a.installApkName+".apk", noticePaths)
}
// Reads and prepends a main cert from the default cert dir if it hasn't been set already, i.e. it
@@ -455,7 +452,10 @@
installDir = android.PathForModuleInstall(ctx, "app", a.installApkName)
}
- a.aapt.noticeFile = a.noticeBuildActions(ctx, installDir)
+ a.noticeBuildActions(ctx, installDir)
+ if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
+ a.aapt.noticeFile = a.noticeOutputs.HtmlGzOutput
+ }
// Process all building blocks, from AAPT to certificates.
a.aaptBuildActions(ctx)