Add testOnly attribute to AndroidManifest file of apex_test
If the build file contains the apex_test module, add the testOnly attribute to the application element of the corresponding AndroidManifest file and set its value to true. If the testOnly attribute is already present and has value false, then do nothing. Tests added in manifest_fixer_test.py to check if the updated AndroidManifest file has the testOnly attribute set to true or not. Bug: 213310150 Test: atest --host manifest_fixer_test Test: m nothing Test: manually checked the AndroidManifest file generated Change-Id: I36247dbe0261c342d451a4422c314fd8fe0c2369
This commit is contained in:
@@ -397,6 +397,22 @@ func (a *apexBundle) buildBundleConfig(ctx android.ModuleContext) android.Output
|
||||
return output.OutputPath
|
||||
}
|
||||
|
||||
func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android.Path) android.Path {
|
||||
return java.ManifestFixer(java.ManifestFixerParams{
|
||||
Ctx: ctx,
|
||||
Manifest: androidManifestFile,
|
||||
SdkContext: nil,
|
||||
ClassLoaderContexts: nil,
|
||||
IsLibrary: false,
|
||||
UseEmbeddedNativeLibs: false,
|
||||
UsesNonSdkApis: false,
|
||||
UseEmbeddedDex: false,
|
||||
HasNoCode: false,
|
||||
TestOnly: true,
|
||||
LoggingParent: "",
|
||||
})
|
||||
}
|
||||
|
||||
// buildUnflattendApex creates build rules to build an APEX using apexer.
|
||||
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||
apexType := a.properties.ApexType
|
||||
@@ -595,6 +611,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||
|
||||
if a.properties.AndroidManifest != nil {
|
||||
androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest))
|
||||
|
||||
if a.testApex {
|
||||
androidManifestFile = markManifestTestOnly(ctx, androidManifestFile)
|
||||
}
|
||||
|
||||
implicitInputs = append(implicitInputs, androidManifestFile)
|
||||
optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
|
||||
}
|
||||
|
Reference in New Issue
Block a user