From aa65e17016152d0d73cd10ab3987bc3bd5c2ef91 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Fri, 22 Feb 2019 16:28:40 -0800 Subject: Add override_module. This new module type replaces the inherit-package function in make by allowing developers to override the name, the certificate, and the manifest package name of an android_app module. Bug: 122957760 Fixes: 123640028 Test: app_test.go + BrowserGoogle Change-Id: Iefe447e7078b25039233221361ef95c83a29973a --- java/app_test.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'java/app_test.go') diff --git a/java/app_test.go b/java/app_test.go index 317c75288..313844fa2 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -747,3 +747,57 @@ func TestPackageNameOverride(t *testing.T) { }) } } + +func TestOverrideModule(t *testing.T) { + ctx := testJava(t, ` + android_app { + name: "foo", + srcs: ["a.java"], + } + + override_module { + name: "bar", + base: "foo", + certificate: ":new_certificate", + manifest_package_name: "org.dandroid.bp", + } + + android_app_certificate { + name: "new_certificate", + certificate: "cert/new_cert", + } + `) + + // The base module still contains all the final outputs after overrides. + foo := ctx.ModuleForTests("foo", "android_common") + + // Check the final apk name + outputs := foo.AllOutputs() + e := buildDir + "/target/product/test_device/system/app/bar/bar.apk" + found := false + for _, o := range outputs { + if o == e { + found = true + break + } + } + if !found { + t.Errorf("Can't find %q in output files.\nAll outputs:%v", e, outputs) + } + + // Check the certificate paths + signapk := foo.Output("foo.apk") + signFlags := signapk.Args["certificates"] + e = "cert/new_cert.x509.pem cert/new_cert.pk8" + if e != signFlags { + t.Errorf("Incorrect signing flags, expected: %q, got: %q", e, signFlags) + } + + // Check the manifest package name + res := foo.Output("package-res.apk") + aapt2Flags := res.Args["flags"] + e = "--rename-manifest-package org.dandroid.bp" + if !strings.Contains(aapt2Flags, e) { + t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", e, aapt2Flags) + } +} -- cgit v1.2.3-59-g8ed1b