summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/app.go23
-rw-r--r--java/dex.go4
-rw-r--r--java/dexpreopt.go6
-rw-r--r--java/dexpreopt_check.go54
4 files changed, 59 insertions, 28 deletions
diff --git a/java/app.go b/java/app.go
index 1358fafec..dd9967516 100644
--- a/java/app.go
+++ b/java/app.go
@@ -172,7 +172,7 @@ type overridableAppProperties struct {
RotationMinSdkVersion *string
// the package name of this app. The package name in the manifest file is used if one was not given.
- Package_name *string
+ Package_name proptools.Configurable[string]
// the logging parent of this app.
Logging_parent *string
@@ -386,7 +386,8 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon
checkMinSdkVersionMts(ctx, a.MinSdkVersion(ctx))
applicationId := a.appTestHelperAppProperties.Manifest_values.ApplicationId
if applicationId != nil {
- if a.overridableAppProperties.Package_name != nil {
+ packageName := a.overridableAppProperties.Package_name.Get(ctx)
+ if packageName.IsPresent() {
ctx.PropertyErrorf("manifest_values.applicationId", "property is not supported when property package_name is set.")
}
a.aapt.manifestValues.applicationId = *applicationId
@@ -586,10 +587,11 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
}
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
- if overridden || a.overridableAppProperties.Package_name != nil {
+ packageNameProp := a.overridableAppProperties.Package_name.Get(ctx)
+ if overridden || packageNameProp.IsPresent() {
// The product override variable has a priority over the package_name property.
if !overridden {
- manifestPackageName = *a.overridableAppProperties.Package_name
+ manifestPackageName = packageNameProp.Get()
}
aaptLinkFlags = append(aaptLinkFlags, generateAaptRenamePackageFlags(manifestPackageName, a.renameResourcesPackage())...)
a.overriddenManifestPackageName = manifestPackageName
@@ -829,11 +831,12 @@ func (a *AndroidApp) createPrivappAllowlist(ctx android.ModuleContext) android.P
return android.PathForModuleSrc(ctx, *a.appProperties.Privapp_allowlist)
}
- if a.overridableAppProperties.Package_name == nil {
+ packageNameProp := a.overridableAppProperties.Package_name.Get(ctx)
+ if packageNameProp.IsEmpty() {
ctx.PropertyErrorf("privapp_allowlist", "package_name must be set to use privapp_allowlist")
}
- packageName := *a.overridableAppProperties.Package_name
+ packageName := packageNameProp.Get()
fileName := "privapp_allowlist_" + packageName + ".xml"
outPath := android.PathForModuleOut(ctx, fileName).OutputPath
ctx.Build(pctx, android.BuildParams{
@@ -1418,7 +1421,8 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
applicationId := a.appTestProperties.Manifest_values.ApplicationId
if applicationId != nil {
- if a.overridableAppProperties.Package_name != nil {
+ packageNameProp := a.overridableAppProperties.Package_name.Get(ctx)
+ if packageNameProp.IsPresent() {
ctx.PropertyErrorf("manifest_values.applicationId", "property is not supported when property package_name is set.")
}
a.aapt.manifestValues.applicationId = *applicationId
@@ -1469,10 +1473,11 @@ func (a *AndroidTest) FixTestConfig(ctx android.ModuleContext, testConfig androi
command.FlagWithArg("--test-file-name ", a.installApkName+".apk")
}
- if a.overridableAppProperties.Package_name != nil {
+ packageNameProp := a.overridableAppProperties.Package_name.Get(ctx)
+ if packageNameProp.IsPresent() {
fixNeeded = true
command.FlagWithInput("--manifest ", a.manifestPath).
- FlagWithArg("--package-name ", *a.overridableAppProperties.Package_name)
+ FlagWithArg("--package-name ", packageNameProp.Get())
}
if a.appTestProperties.Mainline_package_name != nil {
diff --git a/java/dex.go b/java/dex.go
index e16b05208..a3f699bf0 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -133,7 +133,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8",
`$d8Template${config.D8Cmd} ${config.D8Flags} $d8Flags --output $outDir --no-dex-input-jar $in && ` +
`$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` +
`${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in && ` +
- `rm -f "$outDir/classes*.dex" "$outDir/classes.dex.jar"`,
+ `rm -f "$outDir"/classes*.dex "$outDir/classes.dex.jar"`,
CommandDeps: []string{
"${config.D8Cmd}",
"${config.SoongZipCmd}",
@@ -172,7 +172,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8",
`rm -rf ${outUsageDir} && ` +
`$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` +
`${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in && ` +
- `rm -f "$outDir/classes*.dex" "$outDir/classes.dex.jar"`,
+ `rm -f "$outDir"/classes*.dex "$outDir/classes.dex.jar"`,
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
CommandDeps: []string{
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 63a863497..637da363c 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -494,6 +494,12 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
PresignedPrebuilt: d.isPresignedPrebuilt,
}
+ if ctx.Config().InstallApexSystemServerDexpreoptSamePartition() {
+ dexpreoptConfig.ApexPartition = android.PathForModuleInstall(ctx).Partition()
+ } else {
+ dexpreoptConfig.ApexPartition = "system"
+ }
+
d.configPath = android.PathForModuleOut(ctx, "dexpreopt", dexJarStem, "dexpreopt.config")
dexpreopt.WriteModuleConfig(ctx, dexpreoptConfig, d.configPath)
ctx.CheckbuildFile(d.configPath)
diff --git a/java/dexpreopt_check.go b/java/dexpreopt_check.go
index 33be60352..c97156541 100644
--- a/java/dexpreopt_check.go
+++ b/java/dexpreopt_check.go
@@ -17,6 +17,8 @@ package java
import (
"strings"
+ "github.com/google/blueprint"
+
"android/soong/android"
"android/soong/dexpreopt"
@@ -43,16 +45,12 @@ func RegisterDexpreoptCheckBuildComponents(ctx android.RegistrationContext) {
type dexpreoptSystemserverCheck struct {
android.SingletonModuleBase
- // Mapping from the module name to the install paths to the compilation artifacts.
- artifactsByModuleName map[string][]string
-
// The install paths to the compilation artifacts.
artifacts []string
}
func dexpreoptSystemserverCheckFactory() android.SingletonModule {
m := &dexpreoptSystemserverCheck{}
- m.artifactsByModuleName = make(map[string][]string)
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
return m
}
@@ -62,7 +60,25 @@ func getInstallPath(ctx android.ModuleContext, location string) android.InstallP
ctx, "", strings.TrimPrefix(location, "/"))
}
-func (m *dexpreoptSystemserverCheck) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+type systemServerDependencyTag struct {
+ blueprint.BaseDependencyTag
+}
+
+// systemServerJarDepTag willl be used for validation. Skip visiblility.
+func (b systemServerDependencyTag) ExcludeFromVisibilityEnforcement() {
+}
+
+var (
+ // dep tag for platform and apex system server jars
+ systemServerJarDepTag = systemServerDependencyTag{}
+)
+
+var _ android.ExcludeFromVisibilityEnforcementTag = systemServerJarDepTag
+
+// Add a depenendency on the system server jars. The dexpreopt files of those will be emitted to make.
+// The kati packaging system will verify that those files appear in installed files.
+// Adding the dependency allows the singleton module to determine whether an apex system server jar is system_ext specific.
+func (m *dexpreoptSystemserverCheck) DepsMutator(ctx android.BottomUpMutatorContext) {
global := dexpreopt.GetGlobalConfig(ctx)
targets := ctx.Config().Targets[android.Android]
@@ -72,23 +88,27 @@ func (m *dexpreoptSystemserverCheck) GenerateAndroidBuildActions(ctx android.Mod
return
}
- systemServerJars := global.AllSystemServerJars(ctx)
- for _, jar := range systemServerJars.CopyOfJars() {
- dexLocation := dexpreopt.GetSystemServerDexLocation(ctx, global, jar)
- odexLocation := dexpreopt.ToOdexPath(dexLocation, targets[0].Arch.ArchType)
+ ctx.AddDependency(ctx.Module(), systemServerJarDepTag, global.AllSystemServerJars(ctx).CopyOfJars()...)
+}
+
+func (m *dexpreoptSystemserverCheck) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ global := dexpreopt.GetGlobalConfig(ctx)
+ targets := ctx.Config().Targets[android.Android]
+
+ ctx.VisitDirectDepsWithTag(systemServerJarDepTag, func(systemServerJar android.Module) {
+ partition := "system"
+ if systemServerJar.InstallInSystemExt() && ctx.Config().InstallApexSystemServerDexpreoptSamePartition() {
+ partition = ctx.DeviceConfig().SystemExtPath() // system_ext
+ }
+ dexLocation := dexpreopt.GetSystemServerDexLocation(ctx, global, systemServerJar.Name())
+ odexLocation := dexpreopt.ToOdexPath(dexLocation, targets[0].Arch.ArchType, partition)
odexPath := getInstallPath(ctx, odexLocation)
vdexPath := getInstallPath(ctx, pathtools.ReplaceExtension(odexLocation, "vdex"))
- m.artifactsByModuleName[jar] = []string{odexPath.String(), vdexPath.String()}
- }
+ m.artifacts = append(m.artifacts, odexPath.String(), vdexPath.String())
+ })
}
func (m *dexpreoptSystemserverCheck) GenerateSingletonBuildActions(ctx android.SingletonContext) {
- // Only keep modules defined in Soong.
- ctx.VisitAllModules(func(module android.Module) {
- if artifacts, ok := m.artifactsByModuleName[module.Name()]; ok {
- m.artifacts = append(m.artifacts, artifacts...)
- }
- })
}
func (m *dexpreoptSystemserverCheck) MakeVars(ctx android.MakeVarsContext) {