summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rwxr-xr-xjava/app.go22
-rw-r--r--java/app_test.go5
-rw-r--r--java/dexpreopt.go47
-rw-r--r--java/droidstubs.go2
-rw-r--r--java/droidstubs_test.go33
-rw-r--r--java/java.go8
-rw-r--r--java/sdk.go10
-rw-r--r--java/sdk_library.go2
-rw-r--r--java/sdk_library_test.go1
9 files changed, 92 insertions, 38 deletions
diff --git a/java/app.go b/java/app.go
index e7e52d471..1731970b3 100755
--- a/java/app.go
+++ b/java/app.go
@@ -984,8 +984,11 @@ type appTestProperties struct {
// The name of the android_app module that the tests will run against.
Instrumentation_for *string
- // if specified, the instrumentation target package name in the manifest is overwritten by it.
+ // If specified, the instrumentation target package name in the manifest is overwritten by it.
Instrumentation_target_package *string
+
+ // If specified, the mainline module package name in the test config is overwritten by it.
+ Mainline_package_name *string
}
type AndroidTest struct {
@@ -1063,6 +1066,11 @@ func (a *AndroidTest) FixTestConfig(ctx android.ModuleContext, testConfig androi
FlagWithArg("--package-name ", *a.overridableAppProperties.Package_name)
}
+ if a.appTestProperties.Mainline_package_name != nil {
+ fixNeeded = true
+ command.FlagWithArg("--mainline-package-name ", *a.appTestProperties.Mainline_package_name)
+ }
+
if fixNeeded {
rule.Build("fix_test_config", "fix test config")
return fixedConfig
@@ -1524,7 +1532,6 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
appAttrs.javaCommonAttributes = commonAttrs
appAttrs.bazelAapt = aapt
appAttrs.Deps = deps
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: a.Name()}, appAttrs)
} else {
ktName := a.Name() + "_kt"
commonAttrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, a.properties.Common_srcs))
@@ -1545,11 +1552,12 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
appAttrs.bazelAapt = &bazelAapt{Manifest: aapt.Manifest}
appAttrs.Deps = bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + ktName})
- ctx.CreateBazelTargetModule(
- props,
- android.CommonAttributes{Name: a.Name()},
- appAttrs,
- )
}
+ ctx.CreateBazelTargetModule(
+ props,
+ android.CommonAttributes{Name: a.Name()},
+ appAttrs,
+ )
+
}
diff --git a/java/app_test.go b/java/app_test.go
index 3fb67c188..c77f29d23 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2330,12 +2330,14 @@ func TestAndroidTest_FixTestConfig(t *testing.T) {
srcs: ["b.java"],
package_name: "com.android.bar.test",
instrumentation_for: "foo",
+ mainline_package_name: "com.android.bar",
}
override_android_test {
name: "baz_test",
base: "foo_test",
package_name: "com.android.baz.test",
+ mainline_package_name: "com.android.baz",
}
`)
@@ -2354,6 +2356,7 @@ func TestAndroidTest_FixTestConfig(t *testing.T) {
expectedFlags: []string{
"--manifest out/soong/.intermediates/bar_test/android_common/manifest_fixer/AndroidManifest.xml",
"--package-name com.android.bar.test",
+ "--mainline-package-name com.android.bar",
},
},
{
@@ -2363,6 +2366,8 @@ func TestAndroidTest_FixTestConfig(t *testing.T) {
"--manifest out/soong/.intermediates/foo_test/android_common_baz_test/manifest_fixer/AndroidManifest.xml",
"--package-name com.android.baz.test",
"--test-file-name baz_test.apk",
+ "out/soong/.intermediates/foo_test/android_common_baz_test/test_config_fixer/AndroidTest.xml",
+ "--mainline-package-name com.android.baz",
},
},
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 77cbe9cf4..c4b0af441 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -27,6 +27,7 @@ type DexpreopterInterface interface {
dexpreoptDisabled(ctx android.BaseModuleContext) bool
DexpreoptBuiltInstalledForApex() []dexpreopterInstall
AndroidMkEntriesForApex() []android.AndroidMkEntries
+ ProfilePathOnHost() android.Path
}
type dexpreopterInstall struct {
@@ -103,6 +104,9 @@ type dexpreopter struct {
// - Dexpreopt post-processing (using dexpreopt artifacts from a prebuilt system image to incrementally
// dexpreopt another partition).
configPath android.WritablePath
+
+ // The path to the profile on host.
+ profilePathOnHost android.Path
}
type DexpreoptProperties struct {
@@ -180,9 +184,8 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx))
if isApexVariant(ctx) {
- // Don't preopt APEX variant module unless the module is an APEX system server jar and we are
- // building the entire system image.
- if !isApexSystemServerJar || ctx.Config().UnbundledBuild() {
+ // Don't preopt APEX variant module unless the module is an APEX system server jar.
+ if !isApexSystemServerJar {
return true
}
} else {
@@ -368,21 +371,29 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr
installBase := filepath.Base(install.To)
arch := filepath.Base(installDir)
installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir)
+ isProfile := strings.HasSuffix(installBase, ".prof")
+
+ if isProfile {
+ d.profilePathOnHost = install.From
+ }
if isApexSystemServerJar {
- // APEX variants of java libraries are hidden from Make, so their dexpreopt
- // outputs need special handling. Currently, for APEX variants of java
- // libraries, only those in the system server classpath are handled here.
- // Preopting of boot classpath jars in the ART APEX are handled in
- // java/dexpreopt_bootjars.go, and other APEX jars are not preopted.
- // The installs will be handled by Make as sub-modules of the java library.
- d.builtInstalledForApex = append(d.builtInstalledForApex, dexpreopterInstall{
- name: arch + "-" + installBase,
- moduleName: moduleName(ctx),
- outputPathOnHost: install.From,
- installDirOnDevice: installPath,
- installFileOnDevice: installBase,
- })
+ // Profiles are handled separately because they are installed into the APEX.
+ if !isProfile {
+ // APEX variants of java libraries are hidden from Make, so their dexpreopt
+ // outputs need special handling. Currently, for APEX variants of java
+ // libraries, only those in the system server classpath are handled here.
+ // Preopting of boot classpath jars in the ART APEX are handled in
+ // java/dexpreopt_bootjars.go, and other APEX jars are not preopted.
+ // The installs will be handled by Make as sub-modules of the java library.
+ d.builtInstalledForApex = append(d.builtInstalledForApex, dexpreopterInstall{
+ name: arch + "-" + installBase,
+ moduleName: moduleName(ctx),
+ outputPathOnHost: install.From,
+ installDirOnDevice: installPath,
+ installFileOnDevice: installBase,
+ })
+ }
} else if !d.preventInstall {
ctx.InstallFile(installPath, installBase, install.From)
}
@@ -404,3 +415,7 @@ func (d *dexpreopter) AndroidMkEntriesForApex() []android.AndroidMkEntries {
}
return entries
}
+
+func (d *dexpreopter) ProfilePathOnHost() android.Path {
+ return d.profilePathOnHost
+}
diff --git a/java/droidstubs.go b/java/droidstubs.go
index d9613e536..8a521aabb 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -878,11 +878,13 @@ func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) {
Name *string
Api_surface *string
Api_file *string
+ Visibility []string
}{}
props.Name = proptools.StringPtr(d.Name() + ".api.contribution")
props.Api_surface = api_surface
props.Api_file = api_file
+ props.Visibility = []string{"//visibility:override", "//visibility:public"}
ctx.CreateModule(ApiContributionFactory, &props)
}
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 6c2293746..7a04d7326 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -370,3 +370,36 @@ func TestDroidStubsApiContributionGeneration(t *testing.T) {
ctx.ModuleForTests("foo.api.contribution", "")
}
+
+func TestGeneratedApiContributionVisibilityTest(t *testing.T) {
+ library_bp := `
+ java_api_library {
+ name: "bar",
+ api_surface: "public",
+ api_contributions: ["foo.api.contribution"],
+ }
+ `
+ ctx, _ := testJavaWithFS(t, `
+ droidstubs {
+ name: "foo",
+ srcs: ["A/a.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "A/current.txt",
+ removed_api_file: "A/removed.txt",
+ }
+ },
+ visibility: ["//a"],
+ }
+ `,
+ map[string][]byte{
+ "a/a.java": nil,
+ "a/current.txt": nil,
+ "a/removed.txt": nil,
+ "b/Android.bp": []byte(library_bp),
+ },
+ )
+
+ ctx.ModuleForTests("bar", "android_common")
+}
diff --git a/java/java.go b/java/java.go
index 659f98a7c..874f93576 100644
--- a/java/java.go
+++ b/java/java.go
@@ -517,14 +517,8 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext an
return normalizeJavaVersion(ctx, javaVersion)
} else if ctx.Device() {
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
- } else if ctx.Config().TargetsJava17() {
- // Temporary experimental flag to be able to try and build with
- // java version 17 options. The flag, if used, just sets Java
- // 17 as the default version, leaving any components that
- // target an older version intact.
- return JAVA_VERSION_17
} else {
- return JAVA_VERSION_11
+ return JAVA_VERSION_17
}
}
diff --git a/java/sdk.go b/java/sdk.go
index b0da5afba..10ae3f6e8 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -57,14 +57,10 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe
return JAVA_VERSION_8
} else if sdk.FinalOrFutureInt() <= 31 {
return JAVA_VERSION_9
- } else if ctx.Config().TargetsJava17() {
- // Temporary experimental flag to be able to try and build with
- // java version 17 options. The flag, if used, just sets Java
- // 17 as the default version, leaving any components that
- // target an older version intact.
- return JAVA_VERSION_17
- } else {
+ } else if sdk.FinalOrFutureInt() <= 32 {
return JAVA_VERSION_11
+ } else {
+ return JAVA_VERSION_17
}
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index b87236596..a2295f4a6 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1749,7 +1749,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
}
}
- mctx.CreateModule(DroidstubsFactory, &props)
+ mctx.CreateModule(DroidstubsFactory, &props).(*Droidstubs).CallHookIfAvailable(mctx)
}
func (module *SdkLibrary) compareAgainstLatestApi(apiScope *apiScope) bool {
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 210bfc3a3..1d0c13d4b 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -120,6 +120,7 @@ func TestJavaSdkLibrary(t *testing.T) {
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("foo"), "android_common")
result.ModuleForTests(apiScopeSystem.stubsSourceModuleName("foo"), "android_common")
result.ModuleForTests(apiScopeTest.stubsSourceModuleName("foo"), "android_common")
+ result.ModuleForTests(apiScopePublic.stubsSourceModuleName("foo")+".api.contribution", "")
result.ModuleForTests("foo"+sdkXmlFileSuffix, "android_common")
result.ModuleForTests("foo.api.public.28", "")
result.ModuleForTests("foo.api.system.28", "")