Replace ctx.ExpandSources with android.PathsForModuleSrc

Move the logic from ctx.ExpandSources into android.PathsForModuleSrc
and ctx.ExpandSource into android.PathForModuleSrc, and deprecate
them.  When combined with the pathDepsMutator this will let all
properties that take source paths also take filegroups or genrule
outputs, as long as they are tagged with `android:"path"`.

Test: All soong tests
Change-Id: I01625e76b5da19240e9649bf26a014eeeafcab8f
diff --git a/java/aar.go b/java/aar.go
index 29578e2..1a5ea4d 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -130,7 +130,7 @@
 	// Find implicit or explicit asset and resource dirs
 	assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets")
 	resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res")
-	resourceZips := ctx.ExpandSources(a.aaptProperties.Resource_zips, nil)
+	resourceZips := android.PathsForModuleSrc(ctx, a.aaptProperties.Resource_zips)
 
 	var linkDeps android.Paths
 
diff --git a/java/app.go b/java/app.go
index 45e3a83..8f5d010 100644
--- a/java/app.go
+++ b/java/app.go
@@ -470,7 +470,7 @@
 	a.generateAndroidBuildActions(ctx)
 
 	a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites)
-	a.data = ctx.ExpandSources(a.testProperties.Data, nil)
+	a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
 }
 
 func (a *AndroidTest) DepsMutator(ctx android.BottomUpMutatorContext) {
diff --git a/java/droiddoc.go b/java/droiddoc.go
index a85da0e..e163617 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -696,7 +696,7 @@
 	})
 	// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
 	// may contain filegroup or genrule.
-	srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
+	srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
 	flags := j.collectAidlFlags(ctx, deps)
 	srcFiles = j.genSources(ctx, srcFiles, flags)
 
@@ -715,12 +715,12 @@
 	}
 	j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths)
 
-	j.argFiles = ctx.ExpandSources(j.properties.Arg_files, nil)
+	j.argFiles = android.PathsForModuleSrc(ctx, j.properties.Arg_files)
 	argFilesMap := map[string]string{}
 	argFileLabels := []string{}
 
 	for _, label := range j.properties.Arg_files {
-		var paths = ctx.ExpandSources([]string{label}, nil)
+		var paths = android.PathsForModuleSrc(ctx, []string{label})
 		if _, exists := argFilesMap[label]; !exists {
 			argFilesMap[label] = strings.Join(paths.Strings(), " ")
 			argFileLabels = append(argFileLabels, label)
@@ -936,13 +936,13 @@
 
 	if len(d.properties.Html_dirs) > 0 {
 		htmlDir := d.properties.Html_dirs[0]
-		*implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(d.properties.Html_dirs[0], "**/*")}, nil)...)
+		*implicits = append(*implicits, android.PathsForModuleSrc(ctx, []string{filepath.Join(d.properties.Html_dirs[0], "**/*")})...)
 		args = args + " -htmldir " + htmlDir
 	}
 
 	if len(d.properties.Html_dirs) > 1 {
 		htmlDir2 := d.properties.Html_dirs[1]
-		*implicits = append(*implicits, ctx.ExpandSources([]string{filepath.Join(htmlDir2, "**/*")}, nil)...)
+		*implicits = append(*implicits, android.PathsForModuleSrc(ctx, []string{filepath.Join(htmlDir2, "**/*")})...)
 		args = args + " -htmldir2 " + htmlDir2
 	}
 
@@ -950,7 +950,7 @@
 		ctx.PropertyErrorf("html_dirs", "Droiddoc only supports up to 2 html dirs")
 	}
 
-	knownTags := ctx.ExpandSources(d.properties.Knowntags, nil)
+	knownTags := android.PathsForModuleSrc(ctx, d.properties.Knowntags)
 	*implicits = append(*implicits, knownTags...)
 
 	for _, kt := range knownTags {
@@ -1415,12 +1415,12 @@
 				"has to be non-empty if annotations was enabled (unless validating nullability)")
 		}
 		if migratingNullability {
-			previousApi := ctx.ExpandSource(String(d.properties.Previous_api), "previous_api")
+			previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
 			*implicits = append(*implicits, previousApi)
 			flags += " --migrate-nullness " + previousApi.String()
 		}
 		if s := String(d.properties.Validate_nullability_from_list); s != "" {
-			flags += " --validate-nullability-from-list " + ctx.ExpandSource(s, "validate_nullability_from_list").String()
+			flags += " --validate-nullability-from-list " + android.PathForModuleSrc(ctx, s).String()
 		}
 		if validatingNullability {
 			d.nullabilityWarningsFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_nullability_warnings.txt")
@@ -1793,7 +1793,7 @@
 func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	path := String(d.properties.Path)
 	d.dir = android.PathForModuleSrc(ctx, path)
-	d.deps = ctx.ExpandSources([]string{filepath.Join(path, "**/*")}, nil)
+	d.deps = android.PathsForModuleSrc(ctx, []string{filepath.Join(path, "**/*")})
 }
 
 //
diff --git a/java/java.go b/java/java.go
index 986e425..e0da006 100644
--- a/java/java.go
+++ b/java/java.go
@@ -942,7 +942,7 @@
 	if flags.javaVersion == "1.9" {
 		j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
 	}
-	srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
+	srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
 	if hasSrcExt(srcFiles.Strings(), ".proto") {
 		flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)
 	}
@@ -958,7 +958,7 @@
 	j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.Strings()...)
 
 	if j.properties.Jarjar_rules != nil {
-		j.expandJarjarRules = ctx.ExpandSource(*j.properties.Jarjar_rules, "jarjar_rules")
+		j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
 	}
 
 	jarName := ctx.ModuleName() + ".jar"
@@ -1133,10 +1133,10 @@
 
 	manifest := j.overrideManifest
 	if !manifest.Valid() && j.properties.Manifest != nil {
-		manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest"))
+		manifest = android.OptionalPathForPath(android.PathForModuleSrc(ctx, *j.properties.Manifest))
 	}
 
-	services := ctx.ExpandSources(j.properties.Services, nil)
+	services := android.PathsForModuleSrc(ctx, j.properties.Services)
 	if len(services) > 0 {
 		servicesJar := android.PathForModuleOut(ctx, "services", jarName)
 		var zipargs []string
@@ -1547,7 +1547,7 @@
 
 func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites)
-	j.data = ctx.ExpandSources(j.testProperties.Data, nil)
+	j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
 
 	j.Library.GenerateAndroidBuildActions(ctx)
 }
@@ -1641,7 +1641,7 @@
 		j.isWrapperVariant = true
 
 		if j.binaryProperties.Wrapper != nil {
-			j.wrapperFile = ctx.ExpandSource(*j.binaryProperties.Wrapper, "wrapper")
+			j.wrapperFile = android.PathForModuleSrc(ctx, *j.binaryProperties.Wrapper)
 		} else {
 			j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
 		}
@@ -1765,7 +1765,7 @@
 }
 
 func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	jars := ctx.ExpandSources(j.properties.Jars, nil)
+	jars := android.PathsForModuleSrc(ctx, j.properties.Jars)
 
 	jarName := ctx.ModuleName() + ".jar"
 	outputFile := android.PathForModuleOut(ctx, "combined", jarName)
diff --git a/java/java_resources.go b/java/java_resources.go
index 4622963..7161168 100644
--- a/java/java_resources.go
+++ b/java/java_resources.go
@@ -46,7 +46,7 @@
 		}
 	}
 
-	excludeFiles = append(excludeFiles, ctx.ExpandSources(excludeResourceFiles, nil).Strings()...)
+	excludeFiles = append(excludeFiles, android.PathsForModuleSrc(ctx, excludeResourceFiles).Strings()...)
 
 	excludeFiles = append(excludeFiles, resourceExcludes...)
 
@@ -96,7 +96,7 @@
 func resourceFilesToJarArgs(ctx android.ModuleContext,
 	res, exclude []string) (args []string, deps android.Paths) {
 
-	files := ctx.ExpandSources(res, exclude)
+	files := android.PathsForModuleSrcExcludes(ctx, res, exclude)
 
 	lastDir := ""
 	for i, f := range files {