From 729c0bdb54980e9304ef95e9d2dae282a69e4ecf Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Tue, 8 Dec 2020 19:11:54 -0800 Subject: Prebuilt is enabled even if the source one is not. This fix a bug in a recent android_app_import-related change (I8215aa1a6dad74b503eaa1169a64f8c30dda287c) where it uses an incorrect module reference, and so disables a prebuilt module if its source-based counterpart is disabled. Test: app_test.go Bug: 152343232 Change-Id: Ic7f5ca40be58f06e44b5ec4945caf209ef2dae96 --- java/app_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'java/app_test.go') diff --git a/java/app_test.go b/java/app_test.go index ef5e84dd2..e13c6b9f0 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2566,6 +2566,34 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) { } } +func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) { + ctx, _ := testJava(t, ` + android_app { + name: "foo", + srcs: ["a.java"], + enabled: false, + } + + android_app_import { + name: "foo", + apk: "prebuilts/apk/app.apk", + certificate: "platform", + prefer: true, + } + `) + + variant := ctx.ModuleForTests("prebuilt_foo", "android_common") + a := variant.Module().(*AndroidAppImport) + // The prebuilt module should still be enabled and active even if the source-based counterpart + // is disabled. + if !a.prebuilt.UsePrebuilt() { + t.Errorf("prebuilt foo module is not active") + } + if !a.Enabled() { + t.Errorf("prebuilt foo module is disabled") + } +} + func TestAndroidTestImport(t *testing.T) { ctx, config := testJava(t, ` android_test_import { -- cgit v1.2.3-59-g8ed1b