Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aaa0c1ff authored by Colin Cross's avatar Colin Cross
Browse files

Fix prebuilts of overridden apps

AndroidApp had its own HideFromMake method and flag that shadowed
the one in ModuleBase.  This caused performOverrideMutator to set the
AndroidApp flag, but ModuleBase.skipInstall to read the ModuleBase
flag, resulting in a conflicting install rule being created.  Remove
AndroidApp's HideFromMake in favor of the ModuleBase one.

Bug: 232788722
Test: TestOverrideAndroidAppWithPrebuilt
Change-Id: I8c0dfcb50ff4dc1e4d0574f150b10d79908f46aa
parent 198f5892
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
}

func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
	if app.hideApexVariantFromMake || app.appProperties.HideFromMake {
	if app.hideApexVariantFromMake || app.IsHideFromMake() {
		return []android.AndroidMkEntries{android.AndroidMkEntries{
			Disabled: true,
		}}
+0 −5
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ type appProperties struct {

	// cc.Coverage related properties
	PreventInstall    bool `blueprint:"mutated"`
	HideFromMake      bool `blueprint:"mutated"`
	IsCoverageVariant bool `blueprint:"mutated"`

	// Whether this app is considered mainline updatable or not. When set to true, this will enforce
@@ -880,10 +879,6 @@ func (a *AndroidApp) SetPreventInstall() {
	a.appProperties.PreventInstall = true
}

func (a *AndroidApp) HideFromMake() {
	a.appProperties.HideFromMake = true
}

func (a *AndroidApp) MarkAsCoverageVariant(coverage bool) {
	a.appProperties.IsCoverageVariant = coverage
}
+35 −0
Original line number Diff line number Diff line
@@ -2038,6 +2038,41 @@ func TestOverrideAndroidAppOverrides(t *testing.T) {
	}
}

func TestOverrideAndroidAppWithPrebuilt(t *testing.T) {
	result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(
		t, `
		android_app {
			name: "foo",
			srcs: ["a.java"],
			sdk_version: "current",
		}

		override_android_app {
			name: "bar",
			base: "foo",
		}

		android_app_import {
			name: "bar",
			prefer: true,
			apk: "bar.apk",
			presigned: true,
		}
		`)

	// An app that has an override that also has a prebuilt should not be hidden.
	foo := result.ModuleForTests("foo", "android_common")
	if foo.Module().IsHideFromMake() {
		t.Errorf("expected foo to have HideFromMake false")
	}

	// An override that also has a prebuilt should be hidden.
	barOverride := result.ModuleForTests("foo", "android_common_bar")
	if !barOverride.Module().IsHideFromMake() {
		t.Errorf("expected bar override variant of foo to have HideFromMake true")
	}
}

func TestOverrideAndroidAppStem(t *testing.T) {
	ctx, _ := testJava(t, `
		android_app {