Merge "Revert "Revert "Never strip and store dex files uncompressed when they are preopted on system."""
diff --git a/java/droiddoc.go b/java/droiddoc.go
index cbe6be6..787c4d7 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -695,14 +695,17 @@
 	j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths)
 
 	j.argFiles = ctx.ExpandSources(j.properties.Arg_files, nil)
-	argFilesMap := map[string]android.Path{}
+	argFilesMap := map[string]string{}
+	argFileLabels := []string{}
 
-	for _, f := range j.argFiles {
-		if _, exists := argFilesMap[f.Rel()]; !exists {
-			argFilesMap[f.Rel()] = f
+	for _, label := range j.properties.Arg_files {
+		var paths = ctx.ExpandSources([]string{label}, nil)
+		if _, exists := argFilesMap[label]; !exists {
+			argFilesMap[label] = strings.Join(paths.Strings(), " ")
+			argFileLabels = append(argFileLabels, label)
 		} else {
 			ctx.ModuleErrorf("multiple arg_files for %q, %q and %q",
-				f, argFilesMap[f.Rel()], f.Rel())
+				label, argFilesMap[label], paths)
 		}
 	}
 
@@ -710,10 +713,11 @@
 	j.args, err = android.Expand(String(j.properties.Args), func(name string) (string, error) {
 		if strings.HasPrefix(name, "location ") {
 			label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
-			if f, ok := argFilesMap[label]; ok {
-				return f.String(), nil
+			if paths, ok := argFilesMap[label]; ok {
+				return paths, nil
 			} else {
-				return "", fmt.Errorf("unknown location label %q", label)
+				return "", fmt.Errorf("unknown location label %q, expecting one of %q",
+					label, strings.Join(argFileLabels, ", "))
 			}
 		} else if name == "genDir" {
 			return android.PathForModuleGen(ctx).String(), nil
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 85ce533..3623e7c 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -100,7 +100,13 @@
 	// list of package names that must be hidden from the API
 	Hidden_api_packages []string
 
-	// Additional droiddoc options
+	// local files that are used within user customized droiddoc options.
+	Droiddoc_option_files []string
+
+	// additional droiddoc options
+	// Available variables for substitution:
+	//
+	//  $(location <label>): the path to the droiddoc_option_files with name <label>
 	Droiddoc_options []string
 
 	// the java library (in classpath) for documentation that provides java srcs and srcjars.
@@ -434,6 +440,7 @@
 		Srcs_lib_whitelist_dirs          []string
 		Srcs_lib_whitelist_pkgs          []string
 		Libs                             []string
+		Arg_files                        []string
 		Args                             *string
 		Api_tag_name                     *string
 		Api_filename                     *string
@@ -481,6 +488,7 @@
 	case apiScopeTest:
 		droiddocArgs = droiddocArgs + " -showAnnotation android.annotation.TestApi"
 	}
+	props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files
 	props.Args = proptools.StringPtr(droiddocArgs)
 
 	// List of APIs identified from the provided source files are created. They are later