From c27ab6678bbf25cca5aec485f8ad1ed0bc3b3c83 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Thu, 30 May 2019 15:51:14 -0700 Subject: Touch up manifest if there's no source code. The new package manager behavior requires packages without source code to have an application element with hasCode attribute set to false in their manifest. With this change, Soong can now automatically insert one for codeless apps. Test: app_test.go, manifest_fixer_test.py Fixes: 124375490 Change-Id: Ied89a8d07c63805ab910859a4f7c45fc1c60bb73 --- java/java.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 31c6afec8..41e21b1f1 100644 --- a/java/java.go +++ b/java/java.go @@ -966,8 +966,6 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { - hasSrcs := false - j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs) deps := j.collectDeps(ctx) @@ -982,9 +980,6 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } srcFiles = j.genSources(ctx, srcFiles, flags) - if len(srcFiles) > 0 { - hasSrcs = true - } srcJars := srcFiles.FilterByExt(".srcjar") srcJars = append(srcJars, deps.srcJars...) @@ -1181,7 +1176,6 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { if len(deps.staticJars) > 0 { jars = append(jars, deps.staticJars...) - hasSrcs = true } manifest := j.overrideManifest @@ -1293,7 +1287,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.implementationAndResourcesJar = implementationAndResourcesJar - if ctx.Device() && hasSrcs && + if ctx.Device() && j.hasCode(ctx) && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) { // Dex compilation var dexOutputFile android.ModuleOutPath @@ -1498,6 +1492,11 @@ func (j *Module) CompilerDeps() []string { return jdeps } +func (j *Module) hasCode(ctx android.ModuleContext) bool { + srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs) + return len(srcFiles) > 0 || len(ctx.GetDirectDepsWithTag(staticLibTag)) > 0 +} + // // Java libraries (.jar file) // -- cgit v1.2.3-59-g8ed1b