blob: d6dca3836d61868aca931bd76163d773dcbc9435 [file] [log] [blame]
Jaewoong Jungf9b44652020-12-21 12:29:12 -08001// Copyright 2020 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17// This file contains the module implementations for android_app_import and android_test_import.
18
19import (
20 "reflect"
21
22 "github.com/google/blueprint/proptools"
23
24 "android/soong/android"
Wei Li340ee8e2022-03-18 17:33:24 -070025 "android/soong/provenance"
Jaewoong Jungf9b44652020-12-21 12:29:12 -080026)
27
28func init() {
29 RegisterAppImportBuildComponents(android.InitRegistrationContext)
30
31 initAndroidAppImportVariantGroupTypes()
32}
33
34func RegisterAppImportBuildComponents(ctx android.RegistrationContext) {
35 ctx.RegisterModuleType("android_app_import", AndroidAppImportFactory)
36 ctx.RegisterModuleType("android_test_import", AndroidTestImportFactory)
37}
38
39type AndroidAppImport struct {
40 android.ModuleBase
41 android.DefaultableModuleBase
42 android.ApexModuleBase
43 prebuilt android.Prebuilt
44
45 properties AndroidAppImportProperties
46 dpiVariants interface{}
47 archVariants interface{}
48
49 outputFile android.Path
50 certificate Certificate
51
52 dexpreopter
53
54 usesLibrary usesLibrary
55
56 preprocessed bool
57
58 installPath android.InstallPath
59
60 hideApexVariantFromMake bool
Wei Li340ee8e2022-03-18 17:33:24 -070061
62 provenanceMetaDataFile android.OutputPath
Jaewoong Jungf9b44652020-12-21 12:29:12 -080063}
64
65type AndroidAppImportProperties struct {
66 // A prebuilt apk to import
Jooyung Hanf05ca9c2021-06-28 21:48:51 +090067 Apk *string `android:"path"`
Jaewoong Jungf9b44652020-12-21 12:29:12 -080068
69 // The name of a certificate in the default certificate directory or an android_app_certificate
70 // module name in the form ":module". Should be empty if presigned or default_dev_cert is set.
71 Certificate *string
72
Jaewoong Jung25ae8de2021-03-08 17:37:46 -080073 // Names of extra android_app_certificate modules to sign the apk with in the form ":module".
74 Additional_certificates []string
75
Jaewoong Jungf9b44652020-12-21 12:29:12 -080076 // Set this flag to true if the prebuilt apk is already signed. The certificate property must not
77 // be set for presigned modules.
78 Presigned *bool
79
Jaewoong Jung1c1b6e62021-03-09 15:02:31 -080080 // Name of the signing certificate lineage file or filegroup module.
81 Lineage *string `android:"path"`
Jaewoong Jungf9b44652020-12-21 12:29:12 -080082
Rupert Shuttleworth8eab8692021-11-03 10:39:39 -040083 // For overriding the --rotation-min-sdk-version property of apksig
84 RotationMinSdkVersion *string
85
Jaewoong Jungf9b44652020-12-21 12:29:12 -080086 // Sign with the default system dev certificate. Must be used judiciously. Most imported apps
87 // need to either specify a specific certificate or be presigned.
88 Default_dev_cert *bool
89
90 // Specifies that this app should be installed to the priv-app directory,
91 // where the system will grant it additional privileges not available to
92 // normal apps.
93 Privileged *bool
94
95 // Names of modules to be overridden. Listed modules can only be other binaries
96 // (in Make or Soong).
97 // This does not completely prevent installation of the overridden binaries, but if both
98 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
99 // from PRODUCT_PACKAGES.
100 Overrides []string
101
102 // Optional name for the installed app. If unspecified, it is derived from the module name.
103 Filename *string
Bill Peckhama036da92021-01-08 16:09:09 -0800104
105 // If set, create package-export.apk, which other packages can
106 // use to get PRODUCT-agnostic resource data like IDs and type definitions.
107 Export_package_resources *bool
Spandan Dasd1fac642021-05-18 17:01:41 +0000108
109 // Optional. Install to a subdirectory of the default install path for the module
110 Relative_install_path *string
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800111}
112
113func (a *AndroidAppImport) IsInstallable() bool {
114 return true
115}
116
117// Updates properties with variant-specific values.
118func (a *AndroidAppImport) processVariants(ctx android.LoadHookContext) {
119 config := ctx.Config()
120
121 dpiProps := reflect.ValueOf(a.dpiVariants).Elem().FieldByName("Dpi_variants")
122 // Try DPI variant matches in the reverse-priority order so that the highest priority match
123 // overwrites everything else.
124 // TODO(jungjw): Can we optimize this by making it priority order?
125 for i := len(config.ProductAAPTPrebuiltDPI()) - 1; i >= 0; i-- {
126 MergePropertiesFromVariant(ctx, &a.properties, dpiProps, config.ProductAAPTPrebuiltDPI()[i])
127 }
128 if config.ProductAAPTPreferredConfig() != "" {
129 MergePropertiesFromVariant(ctx, &a.properties, dpiProps, config.ProductAAPTPreferredConfig())
130 }
131
132 archProps := reflect.ValueOf(a.archVariants).Elem().FieldByName("Arch")
133 archType := ctx.Config().AndroidFirstDeviceTarget.Arch.ArchType
134 MergePropertiesFromVariant(ctx, &a.properties, archProps, archType.Name)
135
136 if String(a.properties.Apk) == "" {
137 // Disable this module since the apk property is still empty after processing all matching
138 // variants. This likely means there is no matching variant, and the default variant doesn't
139 // have an apk property value either.
140 a.Disable()
141 }
142}
143
144func MergePropertiesFromVariant(ctx android.EarlyModuleContext,
145 dst interface{}, variantGroup reflect.Value, variant string) {
146 src := variantGroup.FieldByName(proptools.FieldNameForProperty(variant))
147 if !src.IsValid() {
148 return
149 }
150
151 err := proptools.ExtendMatchingProperties([]interface{}{dst}, src.Interface(), nil, proptools.OrderAppend)
152 if err != nil {
153 if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
154 ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
155 } else {
156 panic(err)
157 }
158 }
159}
160
Bill Peckhama036da92021-01-08 16:09:09 -0800161func (a *AndroidAppImport) isPrebuiltFrameworkRes() bool {
162 return a.Name() == "prebuilt_framework-res"
163}
164
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800165func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) {
166 cert := android.SrcIsModule(String(a.properties.Certificate))
167 if cert != "" {
168 ctx.AddDependency(ctx.Module(), certificateTag, cert)
169 }
170
Jaewoong Jung25ae8de2021-03-08 17:37:46 -0800171 for _, cert := range a.properties.Additional_certificates {
172 cert = android.SrcIsModule(cert)
173 if cert != "" {
174 ctx.AddDependency(ctx.Module(), certificateTag, cert)
175 } else {
176 ctx.PropertyErrorf("additional_certificates",
177 `must be names of android_app_certificate modules in the form ":module"`)
178 }
179 }
180
Bill Peckhama036da92021-01-08 16:09:09 -0800181 a.usesLibrary.deps(ctx, !a.isPrebuiltFrameworkRes())
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800182}
183
184func (a *AndroidAppImport) uncompressEmbeddedJniLibs(
185 ctx android.ModuleContext, inputPath android.Path, outputPath android.OutputPath) {
186 // Test apps don't need their JNI libraries stored uncompressed. As a matter of fact, messing
187 // with them may invalidate pre-existing signature data.
188 if ctx.InstallInTestcases() && (Bool(a.properties.Presigned) || a.preprocessed) {
189 ctx.Build(pctx, android.BuildParams{
190 Rule: android.Cp,
191 Output: outputPath,
192 Input: inputPath,
193 })
194 return
195 }
196 rule := android.NewRuleBuilder(pctx, ctx)
197 rule.Command().
198 Textf(`if (zipinfo %s 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath).
199 BuiltTool("zip2zip").
200 FlagWithInput("-i ", inputPath).
201 FlagWithOutput("-o ", outputPath).
202 FlagWithArg("-0 ", "'lib/**/*.so'").
203 Textf(`; else cp -f %s %s; fi`, inputPath, outputPath)
204 rule.Build("uncompress-embedded-jni-libs", "Uncompress embedded JIN libs")
205}
206
207// Returns whether this module should have the dex file stored uncompressed in the APK.
208func (a *AndroidAppImport) shouldUncompressDex(ctx android.ModuleContext) bool {
209 if ctx.Config().UnbundledBuild() || a.preprocessed {
210 return false
211 }
212
Ulya Trafimovich0061c0d2021-09-01 15:40:38 +0100213 // Uncompress dex in APKs of priv-apps if and only if DONT_UNCOMPRESS_PRIV_APPS_DEXS is false.
214 if a.Privileged() {
215 return ctx.Config().UncompressPrivAppDex()
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800216 }
217
218 return shouldUncompressDex(ctx, &a.dexpreopter)
219}
220
221func (a *AndroidAppImport) uncompressDex(
222 ctx android.ModuleContext, inputPath android.Path, outputPath android.OutputPath) {
223 rule := android.NewRuleBuilder(pctx, ctx)
224 rule.Command().
225 Textf(`if (zipinfo %s '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath).
226 BuiltTool("zip2zip").
227 FlagWithInput("-i ", inputPath).
228 FlagWithOutput("-o ", outputPath).
229 FlagWithArg("-0 ", "'classes*.dex'").
230 Textf(`; else cp -f %s %s; fi`, inputPath, outputPath)
231 rule.Build("uncompress-dex", "Uncompress dex files")
232}
233
234func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
235 a.generateAndroidBuildActions(ctx)
236}
237
238func (a *AndroidAppImport) InstallApkName() string {
239 return a.BaseModuleName()
240}
241
242func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext) {
243 apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
244 if !apexInfo.IsForPlatform() {
245 a.hideApexVariantFromMake = true
246 }
247
248 numCertPropsSet := 0
249 if String(a.properties.Certificate) != "" {
250 numCertPropsSet++
251 }
252 if Bool(a.properties.Presigned) {
253 numCertPropsSet++
254 }
255 if Bool(a.properties.Default_dev_cert) {
256 numCertPropsSet++
257 }
258 if numCertPropsSet != 1 {
259 ctx.ModuleErrorf("One and only one of certficate, presigned, and default_dev_cert properties must be set")
260 }
261
Sam Delmerico82602492022-06-10 17:05:42 +0000262 _, _, certificates := collectAppDeps(ctx, a, false, false)
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800263
264 // TODO: LOCAL_EXTRACT_APK/LOCAL_EXTRACT_DPI_APK
265 // TODO: LOCAL_PACKAGE_SPLITS
266
267 srcApk := a.prebuilt.SingleSourcePath(ctx)
268
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800269 // TODO: Install or embed JNI libraries
270
271 // Uncompress JNI libraries in the apk
272 jnisUncompressed := android.PathForModuleOut(ctx, "jnis-uncompressed", ctx.ModuleName()+".apk")
273 a.uncompressEmbeddedJniLibs(ctx, srcApk, jnisUncompressed.OutputPath)
274
Spandan Dasd1fac642021-05-18 17:01:41 +0000275 var pathFragments []string
276 relInstallPath := String(a.properties.Relative_install_path)
Bill Peckhama036da92021-01-08 16:09:09 -0800277
278 if a.isPrebuiltFrameworkRes() {
279 // framework-res.apk is installed as system/framework/framework-res.apk
Spandan Dasd1fac642021-05-18 17:01:41 +0000280 if relInstallPath != "" {
281 ctx.PropertyErrorf("relative_install_path", "Relative_install_path cannot be set for framework-res")
282 }
283 pathFragments = []string{"framework"}
Bill Peckhama036da92021-01-08 16:09:09 -0800284 a.preprocessed = true
285 } else if Bool(a.properties.Privileged) {
Spandan Dasd1fac642021-05-18 17:01:41 +0000286 pathFragments = []string{"priv-app", relInstallPath, a.BaseModuleName()}
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800287 } else if ctx.InstallInTestcases() {
Spandan Dasd1fac642021-05-18 17:01:41 +0000288 pathFragments = []string{relInstallPath, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch()}
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800289 } else {
Spandan Dasd1fac642021-05-18 17:01:41 +0000290 pathFragments = []string{"app", relInstallPath, a.BaseModuleName()}
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800291 }
292
Spandan Dasd1fac642021-05-18 17:01:41 +0000293 installDir := android.PathForModuleInstall(ctx, pathFragments...)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000294 a.dexpreopter.isApp = true
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800295 a.dexpreopter.installPath = installDir.Join(ctx, a.BaseModuleName()+".apk")
296 a.dexpreopter.isPresignedPrebuilt = Bool(a.properties.Presigned)
297 a.dexpreopter.uncompressedDex = a.shouldUncompressDex(ctx)
298
299 a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
300 a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
301
Ulya Trafimovichfe927a22021-02-26 14:36:48 +0000302 if a.usesLibrary.enforceUsesLibraries() {
303 srcApk = a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk)
304 }
305
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800306 a.dexpreopter.dexpreopt(ctx, jnisUncompressed)
307 if a.dexpreopter.uncompressedDex {
308 dexUncompressed := android.PathForModuleOut(ctx, "dex-uncompressed", ctx.ModuleName()+".apk")
309 a.uncompressDex(ctx, jnisUncompressed, dexUncompressed.OutputPath)
310 jnisUncompressed = dexUncompressed
311 }
312
313 apkFilename := proptools.StringDefault(a.properties.Filename, a.BaseModuleName()+".apk")
314
315 // TODO: Handle EXTERNAL
316
317 // Sign or align the package if package has not been preprocessed
Bill Peckhama036da92021-01-08 16:09:09 -0800318
319 if a.isPrebuiltFrameworkRes() {
320 a.outputFile = srcApk
321 certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
322 if len(certificates) != 1 {
323 ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
324 }
325 a.certificate = certificates[0]
326 } else if a.preprocessed {
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800327 a.outputFile = srcApk
328 a.certificate = PresignedCertificate
329 } else if !Bool(a.properties.Presigned) {
330 // If the certificate property is empty at this point, default_dev_cert must be set to true.
331 // Which makes processMainCert's behavior for the empty cert string WAI.
332 certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800333 a.certificate = certificates[0]
334 signed := android.PathForModuleOut(ctx, "signed", apkFilename)
335 var lineageFile android.Path
336 if lineage := String(a.properties.Lineage); lineage != "" {
337 lineageFile = android.PathForModuleSrc(ctx, lineage)
338 }
Rupert Shuttleworth8eab8692021-11-03 10:39:39 -0400339
340 rotationMinSdkVersion := String(a.properties.RotationMinSdkVersion)
341
342 SignAppPackage(ctx, signed, jnisUncompressed, certificates, nil, lineageFile, rotationMinSdkVersion)
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800343 a.outputFile = signed
344 } else {
345 alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)
346 TransformZipAlign(ctx, alignedApk, jnisUncompressed)
347 a.outputFile = alignedApk
348 a.certificate = PresignedCertificate
349 }
350
351 // TODO: Optionally compress the output apk.
352
353 if apexInfo.IsForPlatform() {
354 a.installPath = ctx.InstallFile(installDir, apkFilename, a.outputFile)
Wei Li340ee8e2022-03-18 17:33:24 -0700355 artifactPath := android.PathForModuleSrc(ctx, *a.properties.Apk)
356 a.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, artifactPath, a.installPath)
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800357 }
358
359 // TODO: androidmk converter jni libs
360}
361
362func (a *AndroidAppImport) Prebuilt() *android.Prebuilt {
363 return &a.prebuilt
364}
365
366func (a *AndroidAppImport) Name() string {
367 return a.prebuilt.Name(a.ModuleBase.Name())
368}
369
370func (a *AndroidAppImport) OutputFile() android.Path {
371 return a.outputFile
372}
373
374func (a *AndroidAppImport) JacocoReportClassesFile() android.Path {
375 return nil
376}
377
378func (a *AndroidAppImport) Certificate() Certificate {
379 return a.certificate
380}
381
Wei Li340ee8e2022-03-18 17:33:24 -0700382func (a *AndroidAppImport) ProvenanceMetaDataFile() android.OutputPath {
383 return a.provenanceMetaDataFile
384}
385
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800386var dpiVariantGroupType reflect.Type
387var archVariantGroupType reflect.Type
388var supportedDpis = []string{"ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"}
389
390func initAndroidAppImportVariantGroupTypes() {
391 dpiVariantGroupType = createVariantGroupType(supportedDpis, "Dpi_variants")
392
393 archNames := make([]string, len(android.ArchTypeList()))
394 for i, archType := range android.ArchTypeList() {
395 archNames[i] = archType.Name
396 }
397 archVariantGroupType = createVariantGroupType(archNames, "Arch")
398}
399
400// Populates all variant struct properties at creation time.
401func (a *AndroidAppImport) populateAllVariantStructs() {
402 a.dpiVariants = reflect.New(dpiVariantGroupType).Interface()
403 a.AddProperties(a.dpiVariants)
404
405 a.archVariants = reflect.New(archVariantGroupType).Interface()
406 a.AddProperties(a.archVariants)
407}
408
409func (a *AndroidAppImport) Privileged() bool {
410 return Bool(a.properties.Privileged)
411}
412
413func (a *AndroidAppImport) DepIsInSameApex(_ android.BaseModuleContext, _ android.Module) bool {
414 // android_app_import might have extra dependencies via uses_libs property.
415 // Don't track the dependency as we don't automatically add those libraries
416 // to the classpath. It should be explicitly added to java_libs property of APEX
417 return false
418}
419
Jiyong Park92315372021-04-02 08:45:46 +0900420func (a *AndroidAppImport) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
421 return android.SdkSpecPrivate
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800422}
423
Jiyong Park92315372021-04-02 08:45:46 +0900424func (a *AndroidAppImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
425 return android.SdkSpecPrivate
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800426}
427
Colin Cross8355c152021-08-10 19:24:07 -0700428func (a *AndroidAppImport) LintDepSets() LintDepSets {
429 return LintDepSets{}
430}
431
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800432var _ android.ApexModule = (*AndroidAppImport)(nil)
433
434// Implements android.ApexModule
435func (j *AndroidAppImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
436 sdkVersion android.ApiLevel) error {
437 // Do not check for prebuilts against the min_sdk_version of enclosing APEX
438 return nil
439}
440
441func createVariantGroupType(variants []string, variantGroupName string) reflect.Type {
442 props := reflect.TypeOf((*AndroidAppImportProperties)(nil))
443
444 variantFields := make([]reflect.StructField, len(variants))
445 for i, variant := range variants {
446 variantFields[i] = reflect.StructField{
447 Name: proptools.FieldNameForProperty(variant),
448 Type: props,
449 }
450 }
451
452 variantGroupStruct := reflect.StructOf(variantFields)
453 return reflect.StructOf([]reflect.StructField{
454 {
455 Name: variantGroupName,
456 Type: variantGroupStruct,
457 },
458 })
459}
460
461// android_app_import imports a prebuilt apk with additional processing specified in the module.
462// DPI-specific apk source files can be specified using dpi_variants. Example:
463//
Colin Crossd079e0b2022-08-16 10:27:33 -0700464// android_app_import {
465// name: "example_import",
466// apk: "prebuilts/example.apk",
467// dpi_variants: {
468// mdpi: {
469// apk: "prebuilts/example_mdpi.apk",
470// },
471// xhdpi: {
472// apk: "prebuilts/example_xhdpi.apk",
473// },
474// },
475// presigned: true,
476// }
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800477func AndroidAppImportFactory() android.Module {
478 module := &AndroidAppImport{}
479 module.AddProperties(&module.properties)
480 module.AddProperties(&module.dexpreoptProperties)
481 module.AddProperties(&module.usesLibrary.usesLibraryProperties)
482 module.populateAllVariantStructs()
483 android.AddLoadHook(module, func(ctx android.LoadHookContext) {
484 module.processVariants(ctx)
485 })
486
487 android.InitApexModule(module)
488 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
489 android.InitDefaultableModule(module)
490 android.InitSingleSourcePrebuiltModule(module, &module.properties, "Apk")
491
Ulya Trafimovich22890c42021-01-05 12:04:17 +0000492 module.usesLibrary.enforce = true
493
Jaewoong Jungf9b44652020-12-21 12:29:12 -0800494 return module
495}
496
497type androidTestImportProperties struct {
498 // Whether the prebuilt apk can be installed without additional processing. Default is false.
499 Preprocessed *bool
500}
501
502type AndroidTestImport struct {
503 AndroidAppImport
504
505 testProperties testProperties
506
507 testImportProperties androidTestImportProperties
508
509 data android.Paths
510}
511
512func (a *AndroidTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
513 a.preprocessed = Bool(a.testImportProperties.Preprocessed)
514
515 a.generateAndroidBuildActions(ctx)
516
517 a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
518}
519
520func (a *AndroidTestImport) InstallInTestcases() bool {
521 return true
522}
523
524// android_test_import imports a prebuilt test apk with additional processing specified in the
525// module. DPI or arch variant configurations can be made as with android_app_import.
526func AndroidTestImportFactory() android.Module {
527 module := &AndroidTestImport{}
528 module.AddProperties(&module.properties)
529 module.AddProperties(&module.dexpreoptProperties)
530 module.AddProperties(&module.testProperties)
531 module.AddProperties(&module.testImportProperties)
532 module.populateAllVariantStructs()
533 android.AddLoadHook(module, func(ctx android.LoadHookContext) {
534 module.processVariants(ctx)
535 })
536
537 module.dexpreopter.isTest = true
538
539 android.InitApexModule(module)
540 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
541 android.InitDefaultableModule(module)
542 android.InitSingleSourcePrebuiltModule(module, &module.properties, "Apk")
543
544 return module
545}