summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rwxr-xr-xjava/app.go64
-rw-r--r--java/dexpreopt.go5
-rw-r--r--java/java.go7
-rw-r--r--java/rro.go19
-rw-r--r--java/rro_test.go56
-rw-r--r--java/sdk_library.go16
6 files changed, 150 insertions, 17 deletions
diff --git a/java/app.go b/java/app.go
index fc1ace07b..0750c46bb 100755
--- a/java/app.go
+++ b/java/app.go
@@ -18,6 +18,8 @@ package java
// related module types, including their override variants.
import (
+ "fmt"
+ "os"
"path/filepath"
"sort"
"strings"
@@ -721,6 +723,59 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
}
a.buildAppDependencyInfo(ctx)
+
+ config := ctx.Config().VendorConfig("vendor_clean_up_java")
+ if ctx.SocSpecific() || ctx.DeviceSpecific() {
+ output := filepath.Join(config.String("output"),
+ os.Getenv("TARGET_PRODUCT"),
+ config.String("file"))
+ split,_ := filepath.Split(output)
+ if config.String("config") == "warning" {
+ os.MkdirAll(split, os.ModePerm)
+ if outputs, err := os.OpenFile(output,
+ os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err == nil {
+ defer outputs.Close()
+ fmt.Fprintf(outputs,
+ "Module %s in %s hit the violation because it compile " +
+ "the java in vendor. Only prebuilt for Java Apk and Jar" +
+ " is allowed in vendor. for detail instruction, pls " +
+ "refer to go/JavaCleanUpInVendor \n",
+ ctx.ModuleName(),
+ ctx.ModuleDir())
+ } else {
+ fmt.Println("Err: ",err)
+ }
+ } else if config.String("config") == "enforcing"{
+ config_list := false
+ for _, splitstr:= range strings.Split(config.String("allowlist"), " "){
+ if strings.TrimSpace(splitstr) == ctx.ModuleName() {
+ config_list = true
+ }
+ }
+ if config_list == true {
+ os.MkdirAll(split, os.ModePerm)
+ if outputs_enforce, err := os.OpenFile(output,
+ os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err == nil {
+ defer outputs_enforce.Close()
+ fmt.Fprintf(outputs_enforce,
+ "Module %s in %s hit the violation because it compile " +
+ "the java in vendor. Only prebuilt for Java Apk and Jar" +
+ " is allowed in vendor. for detail instruction, pls " +
+ "refer to go/JavaCleanUpInVendor \n",
+ ctx.ModuleName(),
+ ctx.ModuleDir())
+ } else {
+ fmt.Println("Err: ",err)
+ }
+ } else {
+ ctx.PropertyErrorf("ERR", "Module " + ctx.ModuleName() +
+ " in " + ctx.ModuleDir() + " hit the violation because it " +
+ "compile the java in vendor. Only prebuilt for Java Apk and" +
+ " Jar is allowed in vendor. for detail instruction, pls" +
+ " refer to go/JavaCleanUpInVendor")
+ }
+ }
+ }
}
type appDepsInterface interface {
@@ -1213,7 +1268,7 @@ func (u *usesLibrary) addLib(lib string, optional bool) {
}
func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) {
- if !ctx.Config().UnbundledBuild() {
+ if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
ctx.AddVariationDependencies(nil, usesLibTag, u.usesLibraryProperties.Uses_libs...)
ctx.AddVariationDependencies(nil, usesLibTag, u.presentOptionalUsesLibs(ctx)...)
// Only add these extra dependencies if the module depends on framework libs. This avoids
@@ -1249,11 +1304,12 @@ func replaceInList(list []string, oldstr, newstr string) {
// to their dex jars on host and on device.
func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap {
clcMap := make(dexpreopt.ClassLoaderContextMap)
-
- if !ctx.Config().UnbundledBuild() {
+ // Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false.
+ // Added UnbundledBuildImage() condition to generate dexpreopt.config even though unbundled image is built.
+ if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
ctx.VisitDirectDeps(func(m android.Module) {
if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok {
- dep := ctx.OtherModuleName(m)
+ dep := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(m))
if lib, ok := m.(UsesLibraryDependency); ok {
libName := dep
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 2e46d74fa..0faae36ba 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -141,10 +141,9 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr
}
}
- // If it is neither app nor test, make config files regardless of its dexpreopt setting.
+ // If it is test, make config files regardless of its dexpreopt setting.
// The config files are required for apps defined in make which depend on the lib.
- // TODO(b/158843648): The config for apps should be generated as well regardless of setting.
- if (d.isApp || d.isTest) && d.dexpreoptDisabled(ctx) {
+ if d.isTest && d.dexpreoptDisabled(ctx) {
return
}
diff --git a/java/java.go b/java/java.go
index bbed42def..84a9d9aa4 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1180,7 +1180,8 @@ type Import struct {
properties ImportProperties
// output file containing classes.dex and resources
- dexJarFile android.Path
+ dexJarFile android.Path
+ dexJarInstallFile android.Path
combinedClasspathFile android.Path
classLoaderContexts dexpreopt.ClassLoaderContextMap
@@ -1335,6 +1336,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil {
j.dexJarFile = dexOutputPath
+ j.dexJarInstallFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName()))
// Initialize the hiddenapi structure.
j.initHiddenAPI(ctx, dexOutputPath, outputFile, nil)
@@ -1375,6 +1377,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile)
j.dexJarFile = dexOutputFile
+ j.dexJarInstallFile = android.PathForModuleInstall(ctx, "framework", jarName)
}
}
@@ -1416,7 +1419,7 @@ func (j *Import) DexJarBuildPath() android.Path {
}
func (j *Import) DexJarInstallPath() android.Path {
- return nil
+ return j.dexJarInstallFile
}
func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
diff --git a/java/rro.go b/java/rro.go
index 2e58c042f..0b4d0916a 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -90,6 +90,22 @@ type RuntimeResourceOverlayModule interface {
Theme() string
}
+// RRO's partition logic is different from the partition logic of other modules defined in soong/android/paths.go
+// The default partition for RRO is "/product" and not "/system"
+func rroPartition(ctx android.ModuleContext) string {
+ var partition string
+ if ctx.DeviceSpecific() {
+ partition = ctx.DeviceConfig().OdmPath()
+ } else if ctx.SocSpecific() {
+ partition = ctx.DeviceConfig().VendorPath()
+ } else if ctx.SystemExtSpecific() {
+ partition = ctx.DeviceConfig().SystemExtPath()
+ } else {
+ partition = ctx.DeviceConfig().ProductPath()
+ }
+ return partition
+}
+
func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) {
sdkDep := decodeSdkDep(ctx, android.SdkContext(r))
if sdkDep.hasFrameworkLibs() {
@@ -137,7 +153,8 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
r.certificate = certificates[0]
r.outputFile = signed
- r.installDir = android.PathForModuleInstall(ctx, "overlay", String(r.properties.Theme))
+ partition := rroPartition(ctx)
+ r.installDir = android.PathForModuleInPartitionInstall(ctx, partition, "overlay", String(r.properties.Theme))
ctx.InstallFile(r.installDir, r.outputFile.Base(), r.outputFile)
}
diff --git a/java/rro_test.go b/java/rro_test.go
index bad60bc16..27abbe4f3 100644
--- a/java/rro_test.go
+++ b/java/rro_test.go
@@ -177,7 +177,7 @@ func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
// Check device location.
path = android.AndroidMkEntriesForTest(t, ctx, m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
- expectedPath = []string{shared.JoinPath("out/target/product/test_device/system/overlay")}
+ expectedPath = []string{shared.JoinPath("out/target/product/test_device/product/overlay")}
android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_MODULE_PATH", config, expectedPath, path)
}
@@ -343,3 +343,57 @@ func TestEnforceRRO_propagatesToDependencies(t *testing.T) {
})
}
}
+
+func TestRuntimeResourceOverlayPartition(t *testing.T) {
+ bp := `
+ runtime_resource_overlay {
+ name: "device_specific",
+ device_specific: true,
+ }
+ runtime_resource_overlay {
+ name: "soc_specific",
+ soc_specific: true,
+ }
+ runtime_resource_overlay {
+ name: "system_ext_specific",
+ system_ext_specific: true,
+ }
+ runtime_resource_overlay {
+ name: "product_specific",
+ product_specific: true,
+ }
+ runtime_resource_overlay {
+ name: "default"
+ }
+ `
+ testCases := []struct {
+ name string
+ expectedPath string
+ }{
+ {
+ name: "device_specific",
+ expectedPath: "out/soong/target/product/test_device/odm/overlay",
+ },
+ {
+ name: "soc_specific",
+ expectedPath: "out/soong/target/product/test_device/vendor/overlay",
+ },
+ {
+ name: "system_ext_specific",
+ expectedPath: "out/soong/target/product/test_device/system_ext/overlay",
+ },
+ {
+ name: "product_specific",
+ expectedPath: "out/soong/target/product/test_device/product/overlay",
+ },
+ {
+ name: "default",
+ expectedPath: "out/soong/target/product/test_device/product/overlay",
+ },
+ }
+ for _, testCase := range testCases {
+ ctx, _ := testJava(t, bp)
+ mod := ctx.ModuleForTests(testCase.name, "android_common").Module().(*RuntimeResourceOverlay)
+ android.AssertPathRelativeToTopEquals(t, "Install dir is not correct for "+testCase.name, testCase.expectedPath, mod.installDir)
+ }
+}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 8c664383d..fe48e6144 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1923,8 +1923,12 @@ type SdkLibraryImport struct {
// Is nil if the source module does not exist.
xmlPermissionsFileModule *sdkLibraryXml
- // Path to the dex implementation jar obtained from the prebuilt_apex, if any.
+ // Build path to the dex implementation jar obtained from the prebuilt_apex, if any.
dexJarFile android.Path
+
+ // Expected install file path of the source module(sdk_library)
+ // or dex implementation jar obtained from the prebuilt_apex, if any.
+ installFile android.Path
}
var _ SdkLibraryDependency = (*SdkLibraryImport)(nil)
@@ -2142,6 +2146,9 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
var deapexerModule android.Module
+ // Assume that source module(sdk_library) is installed in /<sdk_library partition>/framework
+ module.installFile = android.PathForModuleInstall(ctx, "framework", module.Stem()+".jar")
+
// Record the paths to the prebuilt stubs library and stubs source.
ctx.VisitDirectDeps(func(to android.Module) {
tag := ctx.OtherModuleDependencyTag(to)
@@ -2205,6 +2212,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(module.BaseModuleName())); dexOutputPath != nil {
module.dexJarFile = dexOutputPath
+ module.installFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(module.BaseModuleName()))
module.initHiddenAPI(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
} else {
// This should never happen as a variant for a prebuilt_apex is only created if the
@@ -2259,11 +2267,7 @@ func (module *SdkLibraryImport) DexJarBuildPath() android.Path {
// to satisfy UsesLibraryDependency interface
func (module *SdkLibraryImport) DexJarInstallPath() android.Path {
- if module.implLibraryModule == nil {
- return nil
- } else {
- return module.implLibraryModule.DexJarInstallPath()
- }
+ return module.installFile
}
// to satisfy UsesLibraryDependency interface