summaryrefslogtreecommitdiff
path: root/java/rro.go
diff options
context:
space:
mode:
author Artem Anashkin <asanashkin@salutedevices.com> 2024-12-16 17:31:55 +0300
committer Artem Anashkin <asanashkin@salutedevices.com> 2025-01-15 14:13:01 +0300
commit038866afba8963ce4b0ad0ea3580ed90d70895d4 (patch)
tree27fc59018c37cf3bc4b4ca90ad7942a812d9a608 /java/rro.go
parent18e0d97f0389fa66490e3c9af9aa3ac569244069 (diff)
Add AAPT flags to optimize the set of resources in the RRO apk.
The solution is based on adding flags in build/soong/java/app.go. It will reduce the amount of resources in RRO. Also, it solves the problem of extra locales in the Setting and TvSettings applications (see AssetManager2.h, GetResourceLocales()). Add 3 flags: 1. "--product" - specifies a list of product names to keep. 2. "-c" - provides a list of configurations. For example, if you have dependencies on the support library, which contains translations for multiple languages, you can filter resources just for the given language configuration, like English or Spanish. 3. "--preferred-density" - allows AAPT2 to select the closest matching density and strip out all others. Change-Id: I0da8bc05f349553188264824bfa5b53c27882ee3 Signed-off-by: Artem Anashkin <asanashkin@salutedevices.com>
Diffstat (limited to 'java/rro.go')
-rw-r--r--java/rro.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/java/rro.go b/java/rro.go
index ab4fafa7f..44d55646e 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -139,6 +139,25 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
r.aapt.hasNoCode = true
// Do not remove resources without default values nor dedupe resource configurations with the same value
aaptLinkFlags := []string{"--no-resource-deduping", "--no-resource-removal"}
+
+ // Add TARGET_AAPT_CHARACTERISTICS values to AAPT link flags if they exist and --product flags were not provided.
+ hasProduct := android.PrefixInList(r.aaptProperties.Aaptflags, "--product")
+ if !hasProduct && len(ctx.Config().ProductAAPTCharacteristics()) > 0 {
+ aaptLinkFlags = append(aaptLinkFlags, "--product", ctx.Config().ProductAAPTCharacteristics())
+ }
+
+ if !Bool(r.aaptProperties.Aapt_include_all_resources) {
+ // Product AAPT config
+ for _, aaptConfig := range ctx.Config().ProductAAPTConfig() {
+ aaptLinkFlags = append(aaptLinkFlags, "-c", aaptConfig)
+ }
+
+ // Product AAPT preferred config
+ if len(ctx.Config().ProductAAPTPreferredConfig()) > 0 {
+ aaptLinkFlags = append(aaptLinkFlags, "--preferred-density", ctx.Config().ProductAAPTPreferredConfig())
+ }
+ }
+
// Allow the override of "package name" and "overlay target package name"
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
if overridden || r.overridableProperties.Package_name != nil {