Distinguish HideFromMake from SkipInstall

Invoking HideFromMake today would also make the module uninstallable.
This was a safe assumption since the packaging sytem was in build/make -
if a module is not visible to make, it is also uninstallable.

With the advent of soong packaging system, this might not always be
true. This CL disentangles SkipInstall from HideFromMake. This CL also
sets SkipInstall on modules where the installation rules should not be
emitted, e.g. to prevent duplicate installation rules between platform
and apex variants of libraries

Test: m nothing --no-skip-soong-tests
Test: no diff in aosp_cf_x86_64_phone's system file_list.txt
Change-Id: I80cdd60d2ebdba22fd37e748eb00242cc412bda1
diff --git a/android/module.go b/android/module.go
index 1148430..a918d6e 100644
--- a/android/module.go
+++ b/android/module.go
@@ -85,6 +85,7 @@
 	PartitionTag(DeviceConfig) string
 	HideFromMake()
 	IsHideFromMake() bool
+	SkipInstall()
 	IsSkipInstall() bool
 	MakeUninstallable()
 	ReplacedByPrebuilt()
@@ -1421,6 +1422,7 @@
 func (m *ModuleBase) MakeUninstallable() {
 	m.commonProperties.UninstallableApexPlatformVariant = true
 	m.HideFromMake()
+	m.SkipInstall()
 }
 
 func (m *ModuleBase) ReplacedByPrebuilt() {
diff --git a/android/module_context.go b/android/module_context.go
index 9fa3a62..9fa3fa3 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -497,10 +497,6 @@
 		return true
 	}
 
-	if m.module.base().commonProperties.HideFromMake {
-		return true
-	}
-
 	// We'll need a solution for choosing which of modules with the same name in different
 	// namespaces to install.  For now, reuse the list of namespaces exported to Make as the
 	// list of namespaces to install in a Soong-only build.
@@ -519,6 +515,10 @@
 		return false
 	}
 
+	if m.module.base().commonProperties.HideFromMake {
+		return false
+	}
+
 	if proptools.Bool(m.module.base().commonProperties.No_full_install) {
 		return false
 	}
diff --git a/android/module_proxy.go b/android/module_proxy.go
index 2a65072..a60a5a8 100644
--- a/android/module_proxy.go
+++ b/android/module_proxy.go
@@ -122,6 +122,10 @@
 	panic("method is not implemented on ModuleProxy")
 }
 
+func (m ModuleProxy) SkipInstall() {
+	panic("method is not implemented on ModuleProxy")
+}
+
 func (m ModuleProxy) IsSkipInstall() bool {
 	panic("method is not implemented on ModuleProxy")
 }
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 5d75b62..51e72af 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -569,6 +569,7 @@
 		for _, moduleInFamily := range allModulesInFamily {
 			if moduleInFamily.Name() != selectedModuleInFamily.Name() {
 				moduleInFamily.HideFromMake()
+				moduleInFamily.SkipInstall()
 				// If this is a prebuilt module, unset properties.UsePrebuilt
 				// properties.UsePrebuilt might evaluate to true via soong config var fallback mechanism
 				// Set it to false explicitly so that the following mutator does not replace rdeps to this unselected prebuilt
@@ -639,6 +640,7 @@
 			}
 		} else {
 			m.HideFromMake()
+			m.SkipInstall()
 		}
 	}
 }
diff --git a/cc/cc.go b/cc/cc.go
index 4cda633..551f2cd 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2166,6 +2166,7 @@
 		// modules can be hidden from make as some are needed for resolving make side
 		// dependencies.
 		c.HideFromMake()
+		c.SkipInstall()
 	} else if !installable(c, apexInfo) {
 		c.SkipInstall()
 	}
diff --git a/java/java.go b/java/java.go
index c9bda72..53b3481 100644
--- a/java/java.go
+++ b/java/java.go
@@ -944,6 +944,7 @@
 		// Even though the source javalib is not used, we need to hide it to prevent duplicate installation rules.
 		// TODO (b/331665856): Implement a principled solution for this.
 		j.HideFromMake()
+		j.SkipInstall()
 	}
 	j.provideHiddenAPIPropertyInfo(ctx)
 
diff --git a/java/sdk_library.go b/java/sdk_library.go
index dfbde0e..f6dfcdd 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1403,6 +1403,7 @@
 		// Even though the source javalib is not used, we need to hide it to prevent duplicate installation rules.
 		// TODO (b/331665856): Implement a principled solution for this.
 		module.HideFromMake()
+		module.SkipInstall()
 	}
 
 	module.stem = proptools.StringDefault(module.overridableProperties.Stem, ctx.ModuleName())
diff --git a/rust/rust.go b/rust/rust.go
index 6b91ccb..9e06cd4 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -974,6 +974,7 @@
 			// side dependencies. In particular, proc-macros need to be captured in the
 			// host snapshot.
 			mod.HideFromMake()
+			mod.SkipInstall()
 		} else if !mod.installable(apexInfo) {
 			mod.SkipInstall()
 		}