Do not remove RRO resources

Resource configs should not be deduped when building RROs since it
would be impossible to override some resource configs with the same
value as the default config. Also, aapt2 removes resources that do not
have default configurations. If an overlay attempts to overlay a
non-default configuration without overlaying the default, the resource
will be removed and the value will not be overlaid at all.

Bug: 146227008
Fixes: 119811120
Test: app_test.go
Change-Id: I834a58b18d1e74a0f6b3de3d0523009788787e42
This commit is contained in:
Jaewoong Jung 2020-01-24 10:30:02 -08:00
parent 8c94763bf7
commit f0f747c949
2 changed files with 11 additions and 1 deletions

View File

@ -1257,7 +1257,8 @@ func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext)
func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Compile and link resources
r.aapt.hasNoCode = true
r.aapt.buildActions(ctx, r)
// Do not remove resources without default values nor dedupe resource configurations with the same value
r.aapt.buildActions(ctx, r, "--no-resource-deduping", "--no-resource-removal")
// Sign the built package
_, certificates := collectAppDeps(ctx, false)

View File

@ -2214,6 +2214,7 @@ func TestRuntimeResourceOverlay(t *testing.T) {
name: "foo",
certificate: "platform",
product_specific: true,
aaptflags: ["--keep-raw-values"],
}
runtime_resource_overlay {
@ -2226,6 +2227,14 @@ func TestRuntimeResourceOverlay(t *testing.T) {
m := ctx.ModuleForTests("foo", "android_common")
// Check AAPT2 link flags.
aapt2Flags := m.Output("package-res.apk").Args["flags"]
expectedFlags := []string{"--keep-raw-values", "--no-resource-deduping", "--no-resource-removal"}
absentFlags := android.RemoveListFromList(expectedFlags, strings.Split(aapt2Flags, " "))
if len(absentFlags) > 0 {
t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
}
// Check cert signing flag.
signedApk := m.Output("signed/foo.apk")
signingFlag := signedApk.Args["certificates"]