Add methods to get source file path and subdir of prebuilt_etc

The path and dir are used by apex to include prebuilt files in APEXs.

Bug: 112672359
Test: m apex.test
Change-Id: I780edc8f15e00e644c41fa2eb9dc73c25339c727
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 046512f..fbc9de2 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -49,6 +49,7 @@
 	properties prebuiltEtcProperties
 
 	sourceFilePath         Path
+	outputFilePath         OutputPath
 	installDirPath         OutputPath
 	additionalDependencies *Paths
 }
@@ -84,9 +85,25 @@
 	p.additionalDependencies = &paths
 }
 
+func (p *PrebuiltEtc) OutputFile() OutputPath {
+	return p.outputFilePath
+}
+
+func (p *PrebuiltEtc) SubDir() string {
+	return String(p.properties.Sub_dir)
+}
+
 func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
 	p.sourceFilePath = ctx.ExpandSource(String(p.properties.Src), "src")
+	p.outputFilePath = PathForModuleOut(ctx, ctx.ModuleName()).OutputPath
 	p.installDirPath = PathForModuleInstall(ctx, "etc", String(p.properties.Sub_dir))
+
+	// This ensures that outputFilePath has the same name as this module.
+	ctx.Build(pctx, BuildParams{
+		Rule:   Cp,
+		Output: p.outputFilePath,
+		Input:  p.sourceFilePath,
+	})
 }
 
 func (p *PrebuiltEtc) AndroidMk() AndroidMkData {
@@ -101,7 +118,7 @@
 			fmt.Fprintln(w, "LOCAL_MODULE :=", name+nameSuffix)
 			fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC")
 			fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional")
-			fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.sourceFilePath.String())
+			fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.outputFilePath.String())
 			fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
 			fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name)
 			if p.additionalDependencies != nil {