diff options
-rw-r--r-- | java/ravenwood.go | 42 | ||||
-rw-r--r-- | java/ravenwood_test.go | 10 |
2 files changed, 52 insertions, 0 deletions
diff --git a/java/ravenwood.go b/java/ravenwood.go index 4c9fdc212..4c43a9ffb 100644 --- a/java/ravenwood.go +++ b/java/ravenwood.go @@ -14,6 +14,8 @@ package java import ( + "strconv" + "android/soong/android" "android/soong/tradefed" @@ -36,6 +38,14 @@ var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"} var ravenwoodTestResourceApkTag = dependencyTag{name: "ravenwoodtestresapk"} var ravenwoodTestInstResourceApkTag = dependencyTag{name: "ravenwoodtest-inst-res-apk"} +var genManifestProperties = pctx.AndroidStaticRule("genManifestProperties", + blueprint.RuleParams{ + Command: "echo targetSdkVersionInt=$targetSdkVersionInt > $out && " + + "echo targetSdkVersionRaw=$targetSdkVersionRaw >> $out && " + + "echo packageName=$packageName >> $out && " + + "echo instPackageName=$instPackageName >> $out", + }, "targetSdkVersionInt", "targetSdkVersionRaw", "packageName", "instPackageName") + const ravenwoodUtilsName = "ravenwood-utils" const ravenwoodRuntimeName = "ravenwood-runtime" @@ -68,6 +78,17 @@ type ravenwoodTestProperties struct { // the ravenwood test can access it. This APK will be loaded as resources of the test // instrumentation app itself. Inst_resource_apk *string + + // Specify the package name of the test target apk. + // This will be set to the target Context's package name. + // (i.e. Instrumentation.getTargetContext().getPackageName()) + // If this is omitted, Package_name will be used. + Package_name *string + + // Specify the package name of this test module. + // This will be set to the test Context's package name. + //(i.e. Instrumentation.getContext().getPackageName()) + Inst_package_name *string } type ravenwoodTest struct { @@ -216,6 +237,27 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { copyResApk(ravenwoodTestResourceApkTag, "ravenwood-res.apk") copyResApk(ravenwoodTestInstResourceApkTag, "ravenwood-inst-res.apk") + // Generate manifest properties + propertiesOutputPath := android.PathForModuleGen(ctx, "ravenwood.properties") + + targetSdkVersion := proptools.StringDefault(r.deviceProperties.Target_sdk_version, "") + targetSdkVersionInt := r.TargetSdkVersion(ctx).FinalOrFutureInt() // FinalOrFutureInt may be 10000. + packageName := proptools.StringDefault(r.ravenwoodTestProperties.Package_name, "") + instPackageName := proptools.StringDefault(r.ravenwoodTestProperties.Inst_package_name, "") + ctx.Build(pctx, android.BuildParams{ + Rule: genManifestProperties, + Description: "genManifestProperties", + Output: propertiesOutputPath, + Args: map[string]string{ + "targetSdkVersionInt": strconv.Itoa(targetSdkVersionInt), + "targetSdkVersionRaw": targetSdkVersion, + "packageName": packageName, + "instPackageName": instPackageName, + }, + }) + installProps := ctx.InstallFile(installPath, "ravenwood.properties", propertiesOutputPath) + installDeps = append(installDeps, installProps) + // Install our JAR with all dependencies ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...) } diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go index 5d62ede74..6394a9ac9 100644 --- a/java/ravenwood_test.go +++ b/java/ravenwood_test.go @@ -177,6 +177,12 @@ func TestRavenwoodTest(t *testing.T) { resource_apk: "app2", inst_resource_apk: "app3", sdk_version: "test_current", + target_sdk_version: "34", + package_name: "a.b.c", + inst_package_name: "x.y.z", + } + android_ravenwood_test { + name: "ravenwood-test-empty", } `) @@ -199,12 +205,16 @@ func TestRavenwoodTest(t *testing.T) { // Verify that we've emitted test artifacts in expected location outputJar := module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.jar") module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.config") + module.Output(installPathPrefix + "/ravenwood-test/ravenwood.properties") 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") module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-inst-res.apk") + module = ctx.ModuleForTests("ravenwood-test-empty", "android_common") + module.Output(installPathPrefix + "/ravenwood-test-empty/ravenwood.properties") + // ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted. for _, o := range module.AllOutputs() { android.AssertStringDoesNotContain(t, "runtime libs shouldn't be included", o, "/ravenwood-test/lib64/ravenwood-runtime") |