Revert "Build license metadata files in Soong"

Revert submission 1899703

Reason for revert: b/210158272
Reverted Changes:
I142c19284:Reuse license metadata files from Soong
Ife89b8f23:Add dependency license annotations
I8e7410837:Build license metadata files in Soong

Change-Id: I48f2bf2e2797ac9d38f7ece35ba616b823035607
diff --git a/apex/androidmk.go b/apex/androidmk.go
index f001fa2..7764b6b 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -309,17 +309,19 @@
 	return moduleNames
 }
 
-func (a *apexBundle) writeRequiredModules(w io.Writer) {
+func (a *apexBundle) writeRequiredModules(w io.Writer, apexBundleName string) {
 	var required []string
 	var targetRequired []string
 	var hostRequired []string
 	required = append(required, a.RequiredModuleNames()...)
 	targetRequired = append(targetRequired, a.TargetRequiredModuleNames()...)
 	hostRequired = append(hostRequired, a.HostRequiredModuleNames()...)
+	installMapSet := make(map[string]bool) // set of dependency module:location mappings
 	for _, fi := range a.filesInfo {
 		required = append(required, fi.requiredModuleNames...)
 		targetRequired = append(targetRequired, fi.targetRequiredModuleNames...)
 		hostRequired = append(hostRequired, fi.hostRequiredModuleNames...)
+		installMapSet[a.fullModuleName(apexBundleName, &fi)+":"+fi.installDir+"/"+fi.builtFile.Base()] = true
 	}
 
 	if len(required) > 0 {
@@ -331,6 +333,11 @@
 	if len(hostRequired) > 0 {
 		fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES +=", strings.Join(hostRequired, " "))
 	}
+	if len(installMapSet) > 0 {
+		var installs []string
+		installs = append(installs, android.SortedStringKeys(installMapSet)...)
+		fmt.Fprintln(w, "LOCAL_LICENSE_INSTALL_MAP +=", strings.Join(installs, " "))
+	}
 }
 
 func (a *apexBundle) androidMkForType() android.AndroidMkData {
@@ -352,7 +359,7 @@
 				if len(moduleNames) > 0 {
 					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
 				}
-				a.writeRequiredModules(w)
+				a.writeRequiredModules(w, name)
 				fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
 
 			} else {
@@ -394,7 +401,7 @@
 				if len(a.requiredDeps) > 0 {
 					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
 				}
-				a.writeRequiredModules(w)
+				a.writeRequiredModules(w, name)
 
 				if a.mergedNotices.Merged.Valid() {
 					fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNotices.Merged.Path().String())
diff --git a/apex/builder.go b/apex/builder.go
index 5910784..0880e2b 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -434,10 +434,7 @@
 	// Avoid creating duplicate build rules for multi-installed APEXes.
 	if proptools.BoolDefault(a.properties.Multi_install_skip_symbol_files, false) {
 		installSymbolFiles = false
-
 	}
-	// set of dependency module:location mappings
-	installMapSet := make(map[string]bool)
 
 	// TODO(jiyong): use the RuleBuilder
 	var copyCommands []string
@@ -445,6 +442,7 @@
 	pathWhenActivated := android.PathForModuleInPartitionInstall(ctx, "apex", apexName)
 	for _, fi := range a.filesInfo {
 		destPath := imageDir.Join(ctx, fi.path()).String()
+		var installedPath android.InstallPath
 		// Prepare the destination path
 		destPathDir := filepath.Dir(destPath)
 		if fi.class == appSet {
@@ -452,8 +450,6 @@
 		}
 		copyCommands = append(copyCommands, "mkdir -p "+destPathDir)
 
-		installMapPath := fi.builtFile
-
 		// Copy the built file to the directory. But if the symlink optimization is turned
 		// on, place a symlink to the corresponding file in /system partition instead.
 		if a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform() {
@@ -461,7 +457,6 @@
 			pathOnDevice := filepath.Join("/system", fi.path())
 			copyCommands = append(copyCommands, "ln -sfn "+pathOnDevice+" "+destPath)
 		} else {
-			var installedPath android.InstallPath
 			if fi.class == appSet {
 				copyCommands = append(copyCommands,
 					fmt.Sprintf("unzip -qDD -d %s %s", destPathDir,
@@ -480,19 +475,17 @@
 			if installSymbolFiles {
 				implicitInputs = append(implicitInputs, installedPath)
 			}
+		}
 
-			// Create additional symlinks pointing the file inside the APEX (if any). Note that
-			// this is independent from the symlink optimization.
-			for _, symlinkPath := range fi.symlinkPaths() {
-				symlinkDest := imageDir.Join(ctx, symlinkPath).String()
-				copyCommands = append(copyCommands, "ln -sfn "+filepath.Base(destPath)+" "+symlinkDest)
-				if installSymbolFiles {
-					installedSymlink := ctx.InstallSymlink(pathWhenActivated.Join(ctx, filepath.Dir(symlinkPath)), filepath.Base(symlinkPath), installedPath)
-					implicitInputs = append(implicitInputs, installedSymlink)
-				}
+		// Create additional symlinks pointing the file inside the APEX (if any). Note that
+		// this is independent from the symlink optimization.
+		for _, symlinkPath := range fi.symlinkPaths() {
+			symlinkDest := imageDir.Join(ctx, symlinkPath).String()
+			copyCommands = append(copyCommands, "ln -sfn "+filepath.Base(destPath)+" "+symlinkDest)
+			if installSymbolFiles {
+				installedSymlink := ctx.InstallSymlink(pathWhenActivated.Join(ctx, filepath.Dir(symlinkPath)), filepath.Base(symlinkPath), installedPath)
+				implicitInputs = append(implicitInputs, installedSymlink)
 			}
-
-			installMapPath = installedPath
 		}
 
 		// Copy the test files (if any)
@@ -509,8 +502,6 @@
 			copyCommands = append(copyCommands, "cp -f "+d.SrcPath.String()+" "+dataDest)
 			implicitInputs = append(implicitInputs, d.SrcPath)
 		}
-
-		installMapSet[installMapPath.String()+":"+fi.installDir+"/"+fi.builtFile.Base()] = true
 	}
 	implicitInputs = append(implicitInputs, a.manifestPbOut)
 	if installSymbolFiles {
@@ -519,12 +510,6 @@
 		implicitInputs = append(implicitInputs, installedManifest, installedKey)
 	}
 
-	if len(installMapSet) > 0 {
-		var installs []string
-		installs = append(installs, android.SortedStringKeys(installMapSet)...)
-		a.SetLicenseInstallMap(installs)
-	}
-
 	////////////////////////////////////////////////////////////////////////////////////////////
 	// Step 1.a: Write the list of files in this APEX to a txt file and compare it against
 	// the allowed list given via the allowed_files property. Build fails when the two lists