diff options
author | 2023-08-31 15:48:23 +0000 | |
---|---|---|
committer | 2023-10-23 18:26:53 +0000 | |
commit | 96ea8845c56518e0f8d39c254464cc690b00e0c5 (patch) | |
tree | 466298a3c1b3e396ce9f827e7cc3e184a4286ef4 /java/app.go | |
parent | 786c44f9f37808dc1cc9edd3a19cd6d422e885d3 (diff) |
add manifest_values application id property to soong
Bug:278905106
Test: go test ./java --run TestManifestValuesApplicationIdSetsPackageName
and locally built a module and checked manifest pacakge_name
Change-Id: I5c8fd27c177b9e255dce197706f62580894008cb
Diffstat (limited to 'java/app.go')
-rwxr-xr-x | java/app.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/java/app.go b/java/app.go index 0cb72e256..7b9e6bb14 100755 --- a/java/app.go +++ b/java/app.go @@ -308,6 +308,13 @@ func (a *AndroidApp) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato } func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleContext) { + applicationId := a.appTestHelperAppProperties.Manifest_values.ApplicationId + if applicationId != nil { + if a.overridableAppProperties.Package_name != nil { + ctx.PropertyErrorf("manifest_values.applicationId", "property is not supported when property package_name is set.") + } + a.aapt.manifestValues.applicationId = *applicationId + } a.generateAndroidBuildActions(ctx) } @@ -1107,6 +1114,12 @@ func AndroidAppFactory() android.Module { return module } +// A dictionary of values to be overridden in the manifest. +type Manifest_values struct { + // Overrides the value of package_name in the manifest + ApplicationId *string +} + type appTestProperties struct { // The name of the android_app module that the tests will run against. Instrumentation_for *string @@ -1116,6 +1129,8 @@ type appTestProperties struct { // If specified, the mainline module package name in the test config is overwritten by it. Mainline_package_name *string + + Manifest_values Manifest_values } type AndroidTest struct { @@ -1160,6 +1175,13 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.additionalAaptFlags = append(a.additionalAaptFlags, "--rename-instrumentation-target-package "+manifestPackageName) } } + applicationId := a.appTestProperties.Manifest_values.ApplicationId + if applicationId != nil { + if a.overridableAppProperties.Package_name != nil { + ctx.PropertyErrorf("manifest_values.applicationId", "property is not supported when property package_name is set.") + } + a.aapt.manifestValues.applicationId = *applicationId + } a.generateAndroidBuildActions(ctx) for _, module := range a.testProperties.Test_mainline_modules { @@ -1264,6 +1286,8 @@ type appTestHelperAppProperties struct { // Install the test into a folder named for the module in all test suites. Per_testcase_directory *bool + + Manifest_values Manifest_values } type AndroidTestHelperApp struct { |