[automerger skipped] Use the apex image when the device config asks for it.
am: 0ebdd3430e -s ours
am skip reason: change_id Id2fff6a4569d48b8e6a886cb82bdba205b0dd56a with SHA1 25c0e03520 is in history

Change-Id: I11d7fefe54e2d1ab692619ccd81b7d2a86aa785e
diff --git a/android/androidmk.go b/android/androidmk.go
index bd49e4c..42e1439 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -38,13 +38,15 @@
 }
 
 type AndroidMkData struct {
-	Class      string
-	SubName    string
-	DistFile   OptionalPath
-	OutputFile OptionalPath
-	Disabled   bool
-	Include    string
-	Required   []string
+	Class           string
+	SubName         string
+	DistFile        OptionalPath
+	OutputFile      OptionalPath
+	Disabled        bool
+	Include         string
+	Required        []string
+	Host_required   []string
+	Target_required []string
 
 	Custom func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData)
 
@@ -200,6 +202,8 @@
 	}
 
 	data.Required = append(data.Required, amod.commonProperties.Required...)
+	data.Host_required = append(data.Host_required, amod.commonProperties.Host_required...)
+	data.Target_required = append(data.Target_required, amod.commonProperties.Target_required...)
 
 	// Make does not understand LinuxBionic
 	if amod.Os() == LinuxBionic {
@@ -267,10 +271,7 @@
 	fmt.Fprintln(&data.preamble, "LOCAL_MODULE :=", name+data.SubName)
 	fmt.Fprintln(&data.preamble, "LOCAL_MODULE_CLASS :=", data.Class)
 	fmt.Fprintln(&data.preamble, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
-
-	if len(data.Required) > 0 {
-		fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
-	}
+	WriteRequiredModulesSettings(&data.preamble, data)
 
 	archStr := amod.Arch().ArchType.String()
 	host := false
@@ -360,3 +361,15 @@
 
 	fmt.Fprintln(w, "include "+data.Include)
 }
+
+func WriteRequiredModulesSettings(w io.Writer, data AndroidMkData) {
+	if len(data.Required) > 0 {
+		fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(data.Required, " "))
+	}
+	if len(data.Host_required) > 0 {
+		fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(data.Host_required, " "))
+	}
+	if len(data.Target_required) > 0 {
+		fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(data.Target_required, " "))
+	}
+}
diff --git a/android/config.go b/android/config.go
index 2e0750b..84dd66f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -501,6 +501,22 @@
 	return String(c.productVariables.Platform_sdk_codename)
 }
 
+func (c *config) PlatformSecurityPatch() string {
+	return String(c.productVariables.Platform_security_patch)
+}
+
+func (c *config) PlatformPreviewSdkVersion() string {
+	return String(c.productVariables.Platform_preview_sdk_version)
+}
+
+func (c *config) PlatformMinSupportedTargetSdkVersion() string {
+	return String(c.productVariables.Platform_min_supported_target_sdk_version)
+}
+
+func (c *config) PlatformBaseOS() string {
+	return String(c.productVariables.Platform_base_os)
+}
+
 func (c *config) MinSupportedSdkVersion() int {
 	return 16
 }
diff --git a/android/defs.go b/android/defs.go
index cd8b4e3..4890c66 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -20,7 +20,7 @@
 )
 
 var (
-	pctx = NewPackageContext("android/soong/common")
+	pctx = NewPackageContext("android/soong/android")
 
 	cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
 		Config.CpPreserveSymlinksFlags)
diff --git a/android/module.go b/android/module.go
index 201c27a..93966e1 100644
--- a/android/module.go
+++ b/android/module.go
@@ -133,6 +133,8 @@
 	InstallInRecovery() bool
 
 	RequiredModuleNames() []string
+	HostRequiredModuleNames() []string
+	TargetRequiredModuleNames() []string
 
 	// android.ModuleContext methods
 	// These are duplicated instead of embedded so that can eventually be wrapped to take an
@@ -269,6 +271,12 @@
 	// names of other modules to install if this module is installed
 	Required []string `android:"arch_variant"`
 
+	// names of other modules to install on host if this module is installed
+	Host_required []string `android:"arch_variant"`
+
+	// names of other modules to install on target if this module is installed
+	Target_required []string `android:"arch_variant"`
+
 	// relative path to a file to include in the list of notices for the device
 	Notice *string `android:"path"`
 
@@ -1459,6 +1467,14 @@
 	return ctx.module.base().commonProperties.Required
 }
 
+func (ctx *androidModuleContext) HostRequiredModuleNames() []string {
+	return ctx.module.base().commonProperties.Host_required
+}
+
+func (ctx *androidModuleContext) TargetRequiredModuleNames() []string {
+	return ctx.module.base().commonProperties.Target_required
+}
+
 func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
 	ret, err := ctx.GlobWithDeps(globPattern, excludes)
 	if err != nil {
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 2a3e07e..3cadaeb 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -17,7 +17,6 @@
 import (
 	"fmt"
 	"io"
-	"strings"
 )
 
 // TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
@@ -157,7 +156,7 @@
 			fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
 			fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", p.outputFilePath.Base())
 			fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !p.Installable())
-			fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(data.Required, " "))
+			WriteRequiredModulesSettings(w, data)
 			if p.additionalDependencies != nil {
 				fmt.Fprint(w, "LOCAL_ADDITIONAL_DEPENDENCIES :=")
 				for _, path := range *p.additionalDependencies {
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index e0ade7e..fbdbc97 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -150,13 +150,17 @@
 
 	data := AndroidMkData{}
 	data.Required = append(data.Required, "modA", "moduleB")
+	data.Host_required = append(data.Host_required, "hostModA", "hostModB")
+	data.Target_required = append(data.Target_required, "targetModA")
 
 	expected := map[string]string{
-		"LOCAL_MODULE":                "foo",
-		"LOCAL_MODULE_CLASS":          "ETC",
-		"LOCAL_MODULE_OWNER":          "abc",
-		"LOCAL_INSTALLED_MODULE_STEM": "foo.conf",
-		"LOCAL_REQUIRED_MODULES":      "modA moduleB",
+		"LOCAL_MODULE":                  "foo",
+		"LOCAL_MODULE_CLASS":            "ETC",
+		"LOCAL_MODULE_OWNER":            "abc",
+		"LOCAL_INSTALLED_MODULE_STEM":   "foo.conf",
+		"LOCAL_REQUIRED_MODULES":        "modA moduleB",
+		"LOCAL_HOST_REQUIRED_MODULES":   "hostModA hostModB",
+		"LOCAL_TARGET_REQUIRED_MODULES": "targetModA",
 	}
 
 	mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
diff --git a/android/variable.go b/android/variable.go
index 56ca666..68a24ab 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -85,10 +85,12 @@
 		// are used for dogfooding and performance testing, and should be as similar to user builds
 		// as possible.
 		Debuggable struct {
-			Cflags   []string
-			Cppflags []string
-			Init_rc  []string
-			Required []string
+			Cflags          []string
+			Cppflags        []string
+			Init_rc         []string
+			Required        []string
+			Host_required   []string
+			Target_required []string
 		}
 
 		// eng is true for -eng builds, and can be used to turn on additionaly heavyweight debugging
@@ -137,14 +139,18 @@
 	BuildNumberFromFile *string `json:",omitempty"`
 	DateFromFile        *string `json:",omitempty"`
 
-	Platform_version_name             *string  `json:",omitempty"`
-	Platform_sdk_version              *int     `json:",omitempty"`
-	Platform_sdk_codename             *string  `json:",omitempty"`
-	Platform_sdk_final                *bool    `json:",omitempty"`
-	Platform_version_active_codenames []string `json:",omitempty"`
-	Platform_version_future_codenames []string `json:",omitempty"`
-	Platform_vndk_version             *string  `json:",omitempty"`
-	Platform_systemsdk_versions       []string `json:",omitempty"`
+	Platform_version_name                     *string  `json:",omitempty"`
+	Platform_sdk_version                      *int     `json:",omitempty"`
+	Platform_sdk_codename                     *string  `json:",omitempty"`
+	Platform_sdk_final                        *bool    `json:",omitempty"`
+	Platform_version_active_codenames         []string `json:",omitempty"`
+	Platform_version_future_codenames         []string `json:",omitempty"`
+	Platform_vndk_version                     *string  `json:",omitempty"`
+	Platform_systemsdk_versions               []string `json:",omitempty"`
+	Platform_security_patch                   *string  `json:",omitempty"`
+	Platform_preview_sdk_version              *string  `json:",omitempty"`
+	Platform_min_supported_target_sdk_version *string  `json:",omitempty"`
+	Platform_base_os                          *string  `json:",omitempty"`
 
 	DeviceName              *string  `json:",omitempty"`
 	DeviceArch              *string  `json:",omitempty"`
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index 52bcf9c..8b996e0 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -126,6 +126,8 @@
 			"LOCAL_CONLYFLAGS":                    "conlyflags",
 			"LOCAL_CPPFLAGS":                      "cppflags",
 			"LOCAL_REQUIRED_MODULES":              "required",
+			"LOCAL_HOST_REQUIRED_MODULES":         "host_required",
+			"LOCAL_TARGET_REQUIRED_MODULES":       "target_required",
 			"LOCAL_OVERRIDES_MODULES":             "overrides",
 			"LOCAL_LDLIBS":                        "host_ldlibs",
 			"LOCAL_CLANG_CFLAGS":                  "clang_cflags",
diff --git a/apex/apex.go b/apex/apex.go
index ce1ed46..3327a56 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -119,7 +119,7 @@
 )
 
 func init() {
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 	pctx.Import("android/soong/java")
 	pctx.HostBinToolVariable("apexer", "apexer")
 	// ART minimal builds (using the master-art manifest) do not have the "frameworks/base"
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index 542f737..e754ad5 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -65,6 +65,7 @@
 	"android.hardware.neuralnetworks@1.0",
 	"android.hardware.neuralnetworks@1.1",
 	"android.hardware.neuralnetworks@1.2",
+	"android.hardware.nfc@1.0",
 	"android.hardware.nfc@1.1",
 	"android.hardware.nfc@1.2",
 	"android.hardware.oemlock@1.0",
@@ -110,8 +111,11 @@
 	"libdumpstateutil",
 	"libexpat",
 	"libfmq",
+	"libgatekeeper",
 	"libgui",
 	"libhidlcache",
+	"libkeymaster_messages",
+	"libkeymaster_portable",
 	"libmedia_helper",
 	"libmedia_omx",
 	"libmemtrack",
@@ -122,7 +126,9 @@
 	"libsoftkeymasterdevice",
 	"libsqlite",
 	"libssl",
+	"libstagefright_amrnb_common",
 	"libstagefright_bufferqueue_helper",
+	"libstagefright_enc_common",
 	"libstagefright_flacdec",
 	"libstagefright_foundation",
 	"libstagefright_omx",
@@ -150,8 +156,10 @@
 	"libstagefright_soft_vpxenc",
 	"libstagefright_xmlparser",
 	"libsysutils",
+	"libtinyxml2",
 	"libui",
 	"libvorbisidec",
 	"libxml2",
+	"libyuv",
 	"libziparchive",
 }
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 9265bff..e39bae5 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -63,7 +63,7 @@
 	android.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
 	android.RegisterSingletonType("ndk", NdkSingleton)
 
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 }
 
 func getNdkInstallBase(ctx android.PathContext) android.OutputPath {
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 74f7f27..0ecf566 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -172,6 +172,26 @@
 	return module
 }
 
+// vndk_prebuilt_shared installs Vendor Native Development kit (VNDK) snapshot
+// shared libraries for system build. Example:
+//
+//    vndk_prebuilt_shared {
+//        name: "libfoo",
+//        version: "27.1.0",
+//        vendor_available: true,
+//        vndk: {
+//            enabled: true,
+//        },
+//        export_include_dirs: ["include/external/libfoo/vndk_include"],
+//        arch: {
+//            arm64: {
+//                srcs: ["arm/lib64/libfoo.so"],
+//            },
+//            arm: {
+//                srcs: ["arm/lib/libfoo.so"],
+//            },
+//        },
+//    }
 func vndkPrebuiltSharedFactory() android.Module {
 	module := vndkPrebuiltSharedLibrary()
 	return module.Init()
diff --git a/cmd/soong_env/soong_env.go b/cmd/soong_env/soong_env.go
index 933e525..d305d83 100644
--- a/cmd/soong_env/soong_env.go
+++ b/cmd/soong_env/soong_env.go
@@ -15,7 +15,7 @@
 // soong_glob is the command line tool that checks if the list of files matching a glob has
 // changed, and only updates the output file list if it has changed.  It is used to optimize
 // out build.ninja regenerations when non-matching files are added.  See
-// android/soong/common/glob.go for a longer description.
+// android/soong/android/glob.go for a longer description.
 package main
 
 import (
diff --git a/java/androidmk.go b/java/androidmk.go
index 908286a..865c120 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -38,7 +38,7 @@
 		}
 		fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
 		fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
-		fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
+		android.WriteRequiredModulesSettings(w, data)
 		fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
 	}
 }
diff --git a/java/builder.go b/java/builder.go
index 44767a5..ce9a5ee 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -133,7 +133,7 @@
 )
 
 func init() {
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 	pctx.Import("android/soong/java/config")
 }
 
diff --git a/phony/phony.go b/phony/phony.go
index ed6a2fe..305a434 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -28,7 +28,9 @@
 
 type phony struct {
 	android.ModuleBase
-	requiredModuleNames []string
+	requiredModuleNames       []string
+	hostRequiredModuleNames   []string
+	targetRequiredModuleNames []string
 }
 
 func PhonyFactory() android.Module {
@@ -40,8 +42,12 @@
 
 func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	p.requiredModuleNames = ctx.RequiredModuleNames()
-	if len(p.requiredModuleNames) == 0 {
-		ctx.PropertyErrorf("required", "phony must not have empty required dependencies in order to be useful(and therefore permitted).")
+	p.hostRequiredModuleNames = ctx.HostRequiredModuleNames()
+	p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames()
+	if len(p.requiredModuleNames) == 0 &&
+		len(p.hostRequiredModuleNames) == 0 && len(p.targetRequiredModuleNames) == 0 {
+		ctx.PropertyErrorf("required", "phony must not have empty required dependencies "+
+			"in order to be useful(and therefore permitted).")
 	}
 }
 
@@ -54,7 +60,18 @@
 			if p.Host() {
 				fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
 			}
-			fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(p.requiredModuleNames, " "))
+			if len(p.requiredModuleNames) > 0 {
+				fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=",
+					strings.Join(p.requiredModuleNames, " "))
+			}
+			if len(p.hostRequiredModuleNames) > 0 {
+				fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=",
+					strings.Join(p.hostRequiredModuleNames, " "))
+			}
+			if len(p.targetRequiredModuleNames) > 0 {
+				fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=",
+					strings.Join(p.targetRequiredModuleNames, " "))
+			}
 			fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
 		},
 	}
diff --git a/python/builder.go b/python/builder.go
index e3b490c..36baecd 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -73,7 +73,7 @@
 
 func init() {
 	pctx.Import("github.com/google/blueprint/bootstrap")
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 
 	pctx.HostBinToolVariable("parCmd", "soong_zip")
 	pctx.HostBinToolVariable("mergeParCmd", "merge_zips")