diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/app_import.go | 3 | ||||
| -rw-r--r-- | java/app_import_test.go | 91 | ||||
| -rw-r--r-- | java/ravenwood.go | 35 | ||||
| -rw-r--r-- | java/ravenwood_test.go | 14 |
4 files changed, 122 insertions, 21 deletions
diff --git a/java/app_import.go b/java/app_import.go index fa87997cf..045a89a34 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -431,6 +431,9 @@ func (a *AndroidAppImport) validatePresignedApk(ctx android.ModuleContext, srcAp var extraArgs []string if a.Privileged() { extraArgs = append(extraArgs, "--privileged") + if ctx.Config().UncompressPrivAppDex() { + extraArgs = append(extraArgs, "--uncompress-priv-app-dex") + } } if proptools.Bool(a.properties.Skip_preprocessed_apk_checks) { extraArgs = append(extraArgs, "--skip-preprocessed-apk-checks") diff --git a/java/app_import_test.go b/java/app_import_test.go index 496fc1308..54a5e7518 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go @@ -777,30 +777,79 @@ func TestAndroidTestImport_Preprocessed(t *testing.T) { } func TestAndroidAppImport_Preprocessed(t *testing.T) { - ctx, _ := testJava(t, ` - android_app_import { - name: "foo", - apk: "prebuilts/apk/app.apk", - presigned: true, - preprocessed: true, - } - `) + for _, dontUncompressPrivAppDexs := range []bool{false, true} { + name := fmt.Sprintf("dontUncompressPrivAppDexs:%t", dontUncompressPrivAppDexs) + t.Run(name, func(t *testing.T) { + result := android.GroupFixturePreparers( + PrepareForTestWithJavaDefaultModules, + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.UncompressPrivAppDex = proptools.BoolPtr(!dontUncompressPrivAppDexs) + }), + ).RunTestWithBp(t, ` + android_app_import { + name: "foo", + apk: "prebuilts/apk/app.apk", + presigned: true, + preprocessed: true, + } - apkName := "foo.apk" - variant := ctx.ModuleForTests("foo", "android_common") - outputBuildParams := variant.Output(apkName).BuildParams - if outputBuildParams.Rule.String() != android.Cp.String() { - t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String()) - } + android_app_import { + name: "bar", + apk: "prebuilts/apk/app.apk", + presigned: true, + privileged: true, + preprocessed: true, + } + `) + + // non-privileged app + apkName := "foo.apk" + variant := result.ModuleForTests("foo", "android_common") + outputBuildParams := variant.Output(apkName).BuildParams + if outputBuildParams.Rule.String() != android.Cp.String() { + t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String()) + } - // Make sure compression and aligning were validated. - if outputBuildParams.Validation == nil { - t.Errorf("Expected validation rule, but was not found") - } + // Make sure compression and aligning were validated. + if outputBuildParams.Validation == nil { + t.Errorf("Expected validation rule, but was not found") + } + + validationBuildParams := variant.Output("validated-prebuilt/check.stamp").BuildParams + if validationBuildParams.Rule.String() != checkPresignedApkRule.String() { + t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String()) + } - validationBuildParams := variant.Output("validated-prebuilt/check.stamp").BuildParams - if validationBuildParams.Rule.String() != checkPresignedApkRule.String() { - t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String()) + expectedScriptArgs := "--preprocessed" + actualScriptArgs := validationBuildParams.Args["extraArgs"] + android.AssertStringEquals(t, "check script extraArgs", expectedScriptArgs, actualScriptArgs) + + // privileged app + apkName = "bar.apk" + variant = result.ModuleForTests("bar", "android_common") + outputBuildParams = variant.Output(apkName).BuildParams + if outputBuildParams.Rule.String() != android.Cp.String() { + t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String()) + } + + // Make sure compression and aligning were validated. + if outputBuildParams.Validation == nil { + t.Errorf("Expected validation rule, but was not found") + } + + validationBuildParams = variant.Output("validated-prebuilt/check.stamp").BuildParams + if validationBuildParams.Rule.String() != checkPresignedApkRule.String() { + t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String()) + } + + expectedScriptArgs = "--privileged" + if !dontUncompressPrivAppDexs { + expectedScriptArgs += " --uncompress-priv-app-dex" + } + expectedScriptArgs += " --preprocessed" + actualScriptArgs = validationBuildParams.Args["extraArgs"] + android.AssertStringEquals(t, "check script extraArgs", expectedScriptArgs, actualScriptArgs) + }) } } diff --git a/java/ravenwood.go b/java/ravenwood.go index 908619d5f..84c285cc7 100644 --- a/java/ravenwood.go +++ b/java/ravenwood.go @@ -33,6 +33,8 @@ func RegisterRavenwoodBuildComponents(ctx android.RegistrationContext) { var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"} var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"} var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"} +var ravenwoodDataTag = dependencyTag{name: "ravenwooddata"} +var ravenwoodTestResourceApkTag = dependencyTag{name: "ravenwoodtestresapk"} const ravenwoodUtilsName = "ravenwood-utils" const ravenwoodRuntimeName = "ravenwood-runtime" @@ -53,6 +55,13 @@ func getLibPath(archType android.ArchType) string { type ravenwoodTestProperties struct { Jni_libs []string + + // Specify another android_app module here to copy it to the test directory, so that + // the ravenwood test can access it. + // TODO: For now, we simply refer to another android_app module and copy it to the + // test directory. Eventually, android_ravenwood_test should support all the resource + // related properties and build resources from the `res/` directory. + Resource_apk *string } type ravenwoodTest struct { @@ -114,6 +123,11 @@ func (r *ravenwoodTest) DepsMutator(ctx android.BottomUpMutatorContext) { for _, lib := range r.ravenwoodTestProperties.Jni_libs { ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib) } + + // Resources APK + if resourceApk := proptools.String(r.ravenwoodTestProperties.Resource_apk); resourceApk != "" { + ctx.AddVariationDependencies(nil, ravenwoodTestResourceApkTag, resourceApk) + } } func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -175,6 +189,14 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { installDeps = append(installDeps, installJni) } + resApkInstallPath := installPath.Join(ctx, "ravenwood-res-apks") + if resApk := ctx.GetDirectDepsWithTag(ravenwoodTestResourceApkTag); len(resApk) > 0 { + for _, installFile := range resApk[0].FilesToInstall() { + installResApk := ctx.InstallFile(resApkInstallPath, "ravenwood-res.apk", installFile) + installDeps = append(installDeps, installResApk) + } + } + // Install our JAR with all dependencies ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...) } @@ -198,6 +220,9 @@ type ravenwoodLibgroupProperties struct { Libs []string Jni_libs []string + + // We use this to copy framework-res.apk to the ravenwood runtime directory. + Data []string } type ravenwoodLibgroup struct { @@ -236,6 +261,9 @@ func (r *ravenwoodLibgroup) DepsMutator(ctx android.BottomUpMutatorContext) { for _, lib := range r.ravenwoodLibgroupProperties.Jni_libs { ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib) } + for _, data := range r.ravenwoodLibgroupProperties.Data { + ctx.AddVariationDependencies(nil, ravenwoodDataTag, data) + } } func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -266,6 +294,13 @@ func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContex ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path) } + dataInstallPath := installPath.Join(ctx, "ravenwood-data") + for _, data := range r.ravenwoodLibgroupProperties.Data { + libModule := ctx.GetDirectDepWithTag(data, ravenwoodDataTag) + file := android.OutputFileForModule(ctx, libModule, "") + ctx.InstallFile(dataInstallPath, file.Base(), file) + } + // Normal build should perform install steps ctx.Phony(r.BaseModuleName(), android.PathForPhony(ctx, r.BaseModuleName()+"-install")) } diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go index 59612645c..d26db930d 100644 --- a/java/ravenwood_test.go +++ b/java/ravenwood_test.go @@ -57,6 +57,14 @@ var prepareRavenwoodRuntime = android.GroupFixturePreparers( name: "framework-rules.ravenwood", srcs: ["Rules.java"], } + android_app { + name: "app1", + sdk_version: "current", + } + android_app { + name: "app2", + sdk_version: "current", + } android_ravenwood_libgroup { name: "ravenwood-runtime", libs: [ @@ -67,6 +75,9 @@ var prepareRavenwoodRuntime = android.GroupFixturePreparers( "ravenwood-runtime-jni1", "ravenwood-runtime-jni2", ], + data: [ + "app1", + ], } android_ravenwood_libgroup { name: "ravenwood-utils", @@ -102,6 +113,7 @@ func TestRavenwoodRuntime(t *testing.T) { runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni1.so") runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/libred.so") runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so") + runtime.Output(installPathPrefix + "/ravenwood-runtime/ravenwood-data/app1.apk") utils := ctx.ModuleForTests("ravenwood-utils", "android_common") utils.Output(installPathPrefix + "/ravenwood-utils/framework-rules.ravenwood.jar") } @@ -143,6 +155,7 @@ func TestRavenwoodTest(t *testing.T) { "jni-lib2", "ravenwood-runtime-jni2", ], + resource_apk: "app2", sdk_version: "test_current", } `) @@ -169,6 +182,7 @@ func TestRavenwoodTest(t *testing.T) { module.Output(installPathPrefix + "/ravenwood-test/lib64/jni-lib1.so") module.Output(installPathPrefix + "/ravenwood-test/lib64/libblue.so") module.Output(installPathPrefix + "/ravenwood-test/lib64/libpink.so") + module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-res.apk") // ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted. for _, o := range module.AllOutputs() { |