Export non-apex variants of modules to make

Currently, non-apex variants of modules that are in apexes are not
exported to make unless they're apex_available to the platform. This
means that you can't `m` those modules directly.

However, there is a workaround in the apex androidmk implementation that
emits make rules for the removed modules, but just redirects them to
build the apex itself. We want to remove that, but one of the problems
with doing so is that you can no longer `m` many modules afterwards.

To fix that, unhide the apex's dependencies from make. To ensure they're
not installed, call SkipInstall() on them, and update SkipInstall() to
be more strict by setting `LOCAL_UNINSTALLABLE_MODULE := true`.

Bug: 254205429
Test: Presubmits
Change-Id: Ib094feb2c437ad50d8319c58caa997759e7ce32f
diff --git a/android/packaging_test.go b/android/packaging_test.go
index 91ac1f3..f32d1c3 100644
--- a/android/packaging_test.go
+++ b/android/packaging_test.go
@@ -15,6 +15,7 @@
 package android
 
 import (
+	"strings"
 	"testing"
 
 	"github.com/google/blueprint"
@@ -28,6 +29,8 @@
 		Deps         []string
 		Skip_install *bool
 	}
+
+	builtFile Path
 }
 
 // dep tag used in this test. All dependencies are considered as installable.
@@ -48,13 +51,21 @@
 }
 
 func (m *componentTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
-	builtFile := PathForModuleOut(ctx, m.Name())
+	m.builtFile = PathForModuleOut(ctx, m.Name())
 	dir := ctx.Target().Arch.ArchType.Multilib
 	installDir := PathForModuleInstall(ctx, dir)
 	if proptools.Bool(m.props.Skip_install) {
 		m.SkipInstall()
 	}
-	ctx.InstallFile(installDir, m.Name(), builtFile)
+	ctx.InstallFile(installDir, m.Name(), m.builtFile)
+}
+
+func (m *componentTestModule) AndroidMkEntries() []AndroidMkEntries {
+	return []AndroidMkEntries{
+		{
+			OutputFile: OptionalPathForPath(m.builtFile),
+		},
+	}
 }
 
 // Module that itself is a package
@@ -251,6 +262,35 @@
 		`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
 }
 
+func TestSkipInstallProducesLocalUninstallableModule(t *testing.T) {
+	result := GroupFixturePreparers(
+		PrepareForTestWithArchMutator,
+		FixtureRegisterWithContext(func(ctx RegistrationContext) {
+			ctx.RegisterModuleType("component", componentTestModuleFactory)
+			ctx.RegisterModuleType("package_module", packageTestModuleFactory)
+		}),
+		FixtureWithRootAndroidBp(`
+component {
+	name: "foo",
+	skip_install: true,
+}
+
+package_module {
+	name: "package",
+	deps: ["foo"],
+}
+`),
+	).RunTest(t)
+	module := result.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*componentTestModule)
+	entries := AndroidMkEntriesForTest(t, result.TestContext, module)
+	builder := &strings.Builder{}
+	entries[0].write(builder)
+	androidMkString := builder.String()
+	if !strings.Contains(androidMkString, "LOCAL_UNINSTALLABLE_MODULE := true") {
+		t.Errorf("Expected android mk entries to contain \"LOCAL_UNINSTALLABLE_MODULE := true\", got: \n%s", androidMkString)
+	}
+}
+
 func TestPackagingBaseSingleTarget(t *testing.T) {
 	multiTarget := false
 	runPackagingTest(t, multiTarget,