Ramdisk modules install to correct location

Install to recovery/root/first_stage_ramdisk if BOARD_USES_RECOVERY_AS_BOOT,
otherwise ramdisk. In addition, append /system if not InstallInRoot().

Test: pass
Bug: 147347110
Change-Id: Ie5895ac61a3d5d85f5d958a27c7980d6c79d997e
diff --git a/android/config.go b/android/config.go
index 1cb543d..f0f84e7 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1233,3 +1233,7 @@
 func (c *deviceConfig) DeviceSecondaryArchVariant() string {
 	return String(c.config.productVariables.DeviceSecondaryArchVariant)
 }
+
+func (c *deviceConfig) BoardUsesRecoveryAsBoot() bool {
+	return Bool(c.config.productVariables.BoardUsesRecoveryAsBoot)
+}
diff --git a/android/paths.go b/android/paths.go
index 7bfd8e1..da579d5 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -1256,8 +1256,14 @@
 	} else if ctx.InstallInTestcases() {
 		partition = "testcases"
 	} else if ctx.InstallInRamdisk() {
-		// TODO(elsk): should be conditional on RECOVERY_AS_BOOT
-		partition = "ramdisk"
+		if ctx.DeviceConfig().BoardUsesRecoveryAsBoot() {
+			partition = "recovery/root/first_stage_ramdisk"
+		} else {
+			partition = "ramdisk"
+		}
+		if !ctx.InstallInRoot() {
+			partition += "/system"
+		}
 	} else if ctx.InstallInRecovery() {
 		if ctx.InstallInRoot() {
 			partition = "recovery/root"
diff --git a/android/variable.go b/android/variable.go
index 2bf84dd..3228829 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -316,6 +316,8 @@
 	EnforceProductPartitionInterface *bool `json:",omitempty"`
 
 	InstallExtraFlattenedApexes *bool `json:",omitempty"`
+
+	BoardUsesRecoveryAsBoot *bool `json:",omitempty"`
 }
 
 func boolPtr(v bool) *bool {