Optionally overwrite package value in test config.
If package_name is set for an android_test module, package names in its
AndroidTest.xml config need to be updated too.
Test: test_config_fixer_test.py
Fixes: 145011263
Change-Id: I52f17ef1d1902364b9bcfec4f6e246bd655dbf09
diff --git a/java/app.go b/java/app.go
index c635703..b693ce9 100644
--- a/java/app.go
+++ b/java/app.go
@@ -632,6 +632,17 @@
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config,
a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites, a.testProperties.Auto_gen_config)
+ if a.overridableAppProperties.Package_name != nil {
+ fixedConfig := android.PathForModuleOut(ctx, "test_config_fixer", "AndroidTest.xml")
+ rule := android.NewRuleBuilder()
+ rule.Command().BuiltTool(ctx, "test_config_fixer").
+ FlagWithArg("--manifest ", a.manifestPath.String()).
+ FlagWithArg("--package-name ", *a.overridableAppProperties.Package_name).
+ Input(a.testConfig).
+ Output(fixedConfig)
+ rule.Build(pctx, ctx, "fix_test_config", "fix test config")
+ a.testConfig = fixedConfig
+ }
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
}