From ad0177b1fb6b78edd2f15c901c7586d37581a6d5 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Fri, 24 Apr 2020 15:22:40 -0700 Subject: [PATCH] Add overrides to runtime_resource_overlay (This is a cherry-pick change.) Bug: 154928457 Test: app_test.go Change-Id: Ia52bb9fd18c22b1a02d7b36afd41561cec0473f0 Merged-In: Ia52bb9fd18c22b1a02d7b36afd41561cec0473f0 --- java/androidmk.go | 1 + java/app.go | 7 +++++++ java/app_test.go | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/java/androidmk.go b/java/androidmk.go index 68da23ed8..2c2919218 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -676,6 +676,7 @@ func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries { func(entries *android.AndroidMkEntries) { entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString()) entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath()) + entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...) }, }, }} diff --git a/java/app.go b/java/app.go index afc4a60f8..3200955a7 100755 --- a/java/app.go +++ b/java/app.go @@ -1410,6 +1410,13 @@ type RuntimeResourceOverlayProperties struct { // list of android_app modules whose resources are extracted and linked against Resource_libs []string + + // Names of modules to be overridden. Listed modules can only be other overlays + // (in Make or Soong). + // This does not completely prevent installation of the overridden overlays, but if both + // overlays would be installed by default (in PRODUCT_PACKAGES) the other overlay will be removed + // from PRODUCT_PACKAGES. + Overrides []string } func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) { diff --git a/java/app_test.go b/java/app_test.go index 7b04e4629..09fc3ee49 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2470,6 +2470,7 @@ func TestRuntimeResourceOverlay(t *testing.T) { certificate: "platform", product_specific: true, theme: "faza", + overrides: ["foo"], } android_library { @@ -2517,14 +2518,15 @@ func TestRuntimeResourceOverlay(t *testing.T) { if expected != signingFlag { t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected, signingFlag) } - path := android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_CERTIFICATE"] + androidMkEntries := android.AndroidMkEntriesForTest(t, config, "", m.Module())[0] + path := androidMkEntries.EntryMap["LOCAL_CERTIFICATE"] expectedPath := []string{"build/make/target/product/security/platform.x509.pem"} if !reflect.DeepEqual(path, expectedPath) { t.Errorf("Unexpected LOCAL_CERTIFICATE value: %v, expected: %v", path, expectedPath) } // Check device location. - path = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"] + path = androidMkEntries.EntryMap["LOCAL_MODULE_PATH"] expectedPath = []string{"/tmp/target/product/test_device/product/overlay"} if !reflect.DeepEqual(path, expectedPath) { t.Errorf("Unexpected LOCAL_MODULE_PATH value: %v, expected: %v", path, expectedPath) @@ -2532,9 +2534,16 @@ func TestRuntimeResourceOverlay(t *testing.T) { // A themed module has a different device location m = ctx.ModuleForTests("foo_themed", "android_common") - path = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"] + androidMkEntries = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0] + path = androidMkEntries.EntryMap["LOCAL_MODULE_PATH"] expectedPath = []string{"/tmp/target/product/test_device/product/overlay/faza"} if !reflect.DeepEqual(path, expectedPath) { t.Errorf("Unexpected LOCAL_MODULE_PATH value: %v, expected: %v", path, expectedPath) } + + overrides := androidMkEntries.EntryMap["LOCAL_OVERRIDES_PACKAGES"] + expectedOverrides := []string{"foo"} + if !reflect.DeepEqual(overrides, expectedOverrides) { + t.Errorf("Unexpected LOCAL_OVERRIDES_PACKAGES value: %v, expected: %v", overrides, expectedOverrides) + } }