Simplify deapexer support

Uses the apex relative path to the file as the identifier that is used
to obtain the path to the corresponding file extracted from the apex.
That is instead of a special constructed string id.

Bug: 177892522
Test: m nothing
Merged-In: I5dc77c8fb272bac289b8891d1eac801e541af1f5
Change-Id: I5dc77c8fb272bac289b8891d1eac801e541af1f5
(cherry picked from commit b4bbf2ca10cc8509e3ae0ab104e9e3b55861831b)
diff --git a/apex/deapexer.go b/apex/deapexer.go
index 9088c49..c70da15 100644
--- a/apex/deapexer.go
+++ b/apex/deapexer.go
@@ -40,16 +40,6 @@
 // This is intentionally not registered by name as it is not intended to be used from within an
 // `Android.bp` file.
 
-// DeapexerExportedFile defines the properties needed to expose a file from the deapexer module.
-type DeapexerExportedFile struct {
-	// The tag parameter which must be passed to android.DeapexerInfo's PrebuiltExportPath(name, tag)
-	// method to retrieve the path to the unpacked file.
-	Tag string
-
-	// The path within the APEX that needs to be exported.
-	Path string `android:"path"`
-}
-
 // DeapexerProperties specifies the properties supported by the deapexer module.
 //
 // As these are never intended to be supplied in a .bp file they use a different naming convention
@@ -62,7 +52,9 @@
 	CommonModules []string
 
 	// List of files exported from the .apex file by this module
-	ExportedFiles []DeapexerExportedFile
+	//
+	// Each entry is a path from the apex root, e.g. javalib/core-libart.jar.
+	ExportedFiles []string
 }
 
 type SelectedApexProperties struct {
@@ -107,27 +99,23 @@
 
 	exports := make(map[string]android.Path)
 
-	// Create mappings from name+tag to all the required exported paths.
-	for _, e := range p.properties.ExportedFiles {
-		tag := e.Tag
-		path := e.Path
-
+	// Create mappings from apex relative path to the extracted file's path.
+	exportedPaths := make(android.Paths, 0, len(exports))
+	for _, path := range p.properties.ExportedFiles {
 		// Populate the exports that this makes available.
-		exports[tag] = deapexerOutput.Join(ctx, path)
+		extractedPath := deapexerOutput.Join(ctx, path)
+		exports[path] = extractedPath
+		exportedPaths = append(exportedPaths, extractedPath)
 	}
 
 	// If the prebuilt_apex exports any files then create a build rule that unpacks the apex using
 	// deapexer and verifies that all the required files were created. Also, make the mapping from
-	// name+tag to path available for other modules.
+	// apex relative path to extracted file path available for other modules.
 	if len(exports) > 0 {
 		// Make the information available for other modules.
 		ctx.SetProvider(android.DeapexerProvider, android.NewDeapexerInfo(exports))
 
 		// Create a sorted list of the files that this exports.
-		exportedPaths := make(android.Paths, 0, len(exports))
-		for _, p := range exports {
-			exportedPaths = append(exportedPaths, p)
-		}
 		exportedPaths = android.SortedUniquePaths(exportedPaths)
 
 		// The apex needs to export some files so create a ninja rule to unpack the apex and check that
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 5179242..9504b07 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -553,8 +553,7 @@
 
 	// Compute the deapexer properties from the transitive dependencies of this module.
 	commonModules := []string{}
-	exportedFilesByKey := map[string]string{}
-	requiringModulesByKey := map[string]android.Module{}
+	exportedFiles := []string{}
 	ctx.WalkDeps(func(child, parent android.Module) bool {
 		tag := ctx.OtherModuleDependencyTag(child)
 
@@ -568,16 +567,7 @@
 			commonModules = append(commonModules, name)
 
 			requiredFiles := child.(android.RequiredFilesFromPrebuiltApex).RequiredFilesFromPrebuiltApex(ctx)
-			for k, v := range requiredFiles {
-				if f, ok := exportedFilesByKey[k]; ok && f != v {
-					otherModule := requiringModulesByKey[k]
-					ctx.ModuleErrorf("inconsistent paths have been requested for key %q, %s requires path %s while %s requires path %s",
-						k, child, v, otherModule, f)
-					continue
-				}
-				exportedFilesByKey[k] = v
-				requiringModulesByKey[k] = child
-			}
+			exportedFiles = append(exportedFiles, requiredFiles...)
 
 			// Visit the dependencies of this module just in case they also require files from the
 			// prebuilt apex.
@@ -595,12 +585,7 @@
 	}
 
 	// Populate the exported files property in a fixed order.
-	for _, tag := range android.SortedStringKeys(exportedFilesByKey) {
-		deapexerProperties.ExportedFiles = append(deapexerProperties.ExportedFiles, DeapexerExportedFile{
-			Tag:  tag,
-			Path: exportedFilesByKey[tag],
-		})
-	}
+	deapexerProperties.ExportedFiles = android.SortedUniqueStrings(exportedFiles)
 
 	props := struct {
 		Name          *string