Fix android_test install path.
Test: m nothing + diff soong mk and ninja files.
Bug: 140795853
Change-Id: I3667eac951dea7e447cf73219ff89199fca9ed63
diff --git a/java/app.go b/java/app.go
index afddb6a..014ead4 100644
--- a/java/app.go
+++ b/java/app.go
@@ -126,6 +126,8 @@
// the install APK name is normally the same as the module name, but can be overridden with PRODUCT_PACKAGE_NAME_OVERRIDES.
installApkName string
+ installDir android.OutputPath
+
additionalAaptFlags []string
noticeOutputs android.NoticeOutputs
@@ -319,7 +321,6 @@
} else {
installDir = filepath.Join("app", a.installApkName)
}
-
a.dexpreopter.installPath = android.PathForModuleInstall(ctx, installDir, a.installApkName+".apk")
a.dexpreopter.isInstallable = Bool(a.properties.Installable)
a.dexpreopter.uncompressedDex = a.shouldUncompressDex(ctx)
@@ -352,7 +353,7 @@
return jniJarFile
}
-func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext, installDir android.OutputPath) {
+func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext) {
// Collect NOTICE files from all dependencies.
seenModules := make(map[android.Module]bool)
noticePathSet := make(map[android.Path]bool)
@@ -392,7 +393,7 @@
return noticePaths[i].String() < noticePaths[j].String()
})
- a.noticeOutputs = android.BuildNoticeOutput(ctx, installDir, a.installApkName+".apk", noticePaths)
+ a.noticeOutputs = android.BuildNoticeOutput(ctx, a.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
@@ -438,17 +439,18 @@
// Check if the install APK name needs to be overridden.
a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(a.Name())
- var installDir android.OutputPath
if ctx.ModuleName() == "framework-res" {
// framework-res.apk is installed as system/framework/framework-res.apk
- installDir = android.PathForModuleInstall(ctx, "framework")
+ a.installDir = android.PathForModuleInstall(ctx, "framework")
} else if Bool(a.appProperties.Privileged) {
- installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName)
+ a.installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName)
+ } else if ctx.InstallInTestcases() {
+ a.installDir = android.PathForModuleInstall(ctx, a.installApkName)
} else {
- installDir = android.PathForModuleInstall(ctx, "app", a.installApkName)
+ a.installDir = android.PathForModuleInstall(ctx, "app", a.installApkName)
}
- a.noticeBuildActions(ctx, installDir)
+ a.noticeBuildActions(ctx)
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
a.aapt.noticeFile = a.noticeOutputs.HtmlGzOutput
}
@@ -494,9 +496,9 @@
a.bundleFile = bundleFile
// Install the app package.
- ctx.InstallFile(installDir, a.installApkName+".apk", a.outputFile)
+ ctx.InstallFile(a.installDir, a.installApkName+".apk", a.outputFile)
for _, split := range a.aapt.splits {
- ctx.InstallFile(installDir, a.installApkName+"_"+split.suffix+".apk", split.path)
+ ctx.InstallFile(a.installDir, a.installApkName+"_"+split.suffix+".apk", split.path)
}
}
@@ -598,6 +600,10 @@
data android.Paths
}
+func (a *AndroidTest) InstallInTestcases() bool {
+ return true
+}
+
func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Check if the instrumentation target package is overridden before generating build actions.
if a.appTestProperties.Instrumentation_for != nil {