Merge "Save list of AndroidProducts.mk files"
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 956edce..703401c 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -92,6 +92,9 @@
 	// or .aidl files.
 	Srcs []string `android:"arch_variant"`
 
+	// list of optional source files that are part of API but not part of runtime library.
+	Api_srcs []string `android:"arch_variant"`
+
 	// list of of java libraries that will be in the classpath
 	Libs []string `android:"arch_variant"`
 
@@ -113,7 +116,8 @@
 	android.ModuleBase
 	android.DefaultableModuleBase
 
-	properties sdkLibraryProperties
+	properties       sdkLibraryProperties
+	deviceProperties CompilerDeviceProperties
 
 	publicApiStubsPath android.Paths
 	systemApiStubsPath android.Paths
@@ -315,7 +319,8 @@
 	}{}
 
 	props.Name = proptools.StringPtr(module.docsName(apiScope))
-	props.Srcs = module.properties.Srcs
+	props.Srcs = append(props.Srcs, module.properties.Srcs...)
+	props.Srcs = append(props.Srcs, module.properties.Api_srcs...)
 	props.Custom_template = proptools.StringPtr("droiddoc-templates-sdk")
 	props.Installable = proptools.BoolPtr(false)
 	props.Libs = module.properties.Libs
@@ -358,16 +363,12 @@
 	// API class is extending from the framework class. In that case, doclava needs
 	// to know whether the base class is hidden or not. Since that information is
 	// encoded as @hide string in the comment, we need source files for the classes,
-	// not the compiled ones. Also there are rare cases where part of SDK library is
-	// implemented in the framework (e.g. org.apache.http.legacy). In that case,
-	// we need framework source to make API stubs, though the sources are not
-	// required to build the runtime library.
+	// not the compiled ones.
 	props.Srcs_lib = proptools.StringPtr("framework")
 	props.Srcs_lib_whitelist_dirs = []string{"core/java"}
-	props.Srcs_lib_whitelist_pkgs = module.properties.Api_packages
 	// Add android.annotation package to give access to the framework-defined
 	// annotations such as SystemApi, NonNull, etc.
-	props.Srcs_lib_whitelist_pkgs = append(props.Srcs_lib_whitelist_pkgs, "android.annotation")
+	props.Srcs_lib_whitelist_pkgs = []string{"android.annotation"}
 	// These libs are required by doclava to parse the framework sources add via
 	// Src_lib and Src_lib_whitelist_* properties just above.
 	// If we don't add them to the classpath, errors messages are generated by doclava,
@@ -405,7 +406,7 @@
 		props.Product_specific = proptools.BoolPtr(true)
 	}
 
-	mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory(true)), &props)
+	mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory(true)), &props, &module.deviceProperties)
 }
 
 // Creates the xml file that publicizes the runtime library
@@ -523,6 +524,7 @@
 func sdkLibraryFactory() android.Module {
 	module := &sdkLibrary{}
 	module.AddProperties(&module.properties)
+	module.AddProperties(&module.deviceProperties)
 	android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
 	android.InitDefaultableModule(module)
 	return module