Merge "java_sdk_library - pass patch_module through to stubs library"
diff --git a/apex/apex.go b/apex/apex.go
index eafc186..329a6ba 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1936,21 +1936,9 @@
 	return true
 }
 
-// Ensures that the dependencies are marked as available for this APEX
-func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
-	// Let's be practical. Availability for test, host, and the VNDK apex isn't important
-	if ctx.Host() || a.testApex || a.vndkApex {
-		return
-	}
-
-	checkDep := func(ctx android.ModuleContext, am android.ApexModule) {
-		apexName := ctx.ModuleName()
-		if am.AvailableFor(apexName) || whitelistedApexAvailable(apexName, am) {
-			return
-		}
-		ctx.ModuleErrorf("requires %q that is not available for the APEX.", am.Name())
-	}
-
+// Visit dependencies that contributes to the payload of this APEX
+func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
+	do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) {
 	ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
 		am, ok := child.(android.ApexModule)
 		if !ok || !am.CanHaveApexVariants() {
@@ -1960,7 +1948,7 @@
 		// Check for the direct dependencies that contribute to the payload
 		if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
 			if dt.payload {
-				checkDep(ctx, am)
+				do(ctx, parent, am, false /* externalDep */)
 				return true
 			}
 			return false
@@ -1968,15 +1956,33 @@
 
 		// Check for the indirect dependencies if it is considered as part of the APEX
 		if am.DepIsInSameApex(ctx, am) {
-			checkDep(ctx, am)
+			do(ctx, parent, am, false /* externalDep */)
 			return true
 		}
 
+		do(ctx, parent, am, true /* externalDep */)
+
 		// As soon as the dependency graph crosses the APEX boundary, don't go further.
 		return false
 	})
 }
 
+// Ensures that the dependencies are marked as available for this APEX
+func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
+	// Let's be practical. Availability for test, host, and the VNDK apex isn't important
+	if ctx.Host() || a.testApex || a.vndkApex {
+		return
+	}
+
+	a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
+		apexName := ctx.ModuleName()
+		if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, to) {
+			return
+		}
+		ctx.ModuleErrorf("requires %q that is not available for the APEX.", to.Name())
+	})
+}
+
 func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
 	switch a.properties.ApexType {
diff --git a/apex/builder.go b/apex/builder.go
index 51818eb..e267e49 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -239,7 +239,7 @@
 	rule.Command().
 		Implicit(builtApex).
 		Text("(cd " + imageDir.String() + " ; ").
-		Text("find . -type f -printf \"%s %p\\n\") ").
+		Text("find . \\( -type f -o -type l \\) -printf \"%s %p\\n\") ").
 		Text(" | sort -nr > ").
 		Output(output)
 	rule.Build(pctx, ctx, "installed-files."+a.Name(), "Installed files")
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 720f79e..e353878 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -32,9 +32,6 @@
 
 	UseArtImage bool // use the art image (use other boot class path dex files without image)
 
-	GenerateApexImage bool // generate an extra boot image only containing jars from the runtime apex
-	UseApexImage      bool // use the apex image by default
-
 	HasSystemOther        bool     // store odex files that match PatternsOnSystemOther on the system_other partition
 	PatternsOnSystemOther []string // patterns (using '%' to denote a prefix match) to put odex on the system_other partition
 
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 5faec08..c81e199 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -111,14 +111,6 @@
 	if global.UseArtImage {
 		bootImage = artBootImageConfig(ctx)
 	}
-	if global.UseApexImage {
-		bootImage = frameworkJZBootImageConfig(ctx)
-		dexFiles = bootImage.dexPathsDeps.Paths()
-		dexLocations = bootImage.dexLocationsDeps
-		if global.UseArtImage {
-			bootImage = artJZBootImageConfig(ctx)
-		}
-	}
 
 	var archs []android.ArchType
 	for _, a := range ctx.MultiTargets() {
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 87f6d5e..607a437 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -197,13 +197,6 @@
 	// Include dexpreopt files for the primary boot image.
 	files := artBootImageConfig(ctx).imagesDeps
 
-	// For JIT-zygote config, also include dexpreopt files for the primary JIT-zygote image.
-	if dexpreoptGlobalConfig(ctx).UseApexImage {
-		for arch, paths := range artJZBootImageConfig(ctx).imagesDeps {
-			files[arch] = append(files[arch], paths...)
-		}
-	}
-
 	return files
 }
 
@@ -232,11 +225,6 @@
 	d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
 	// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
 	d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
-	if global.GenerateApexImage {
-		// Create boot images for the JIT-zygote experiment.
-		d.otherImages = append(d.otherImages, buildBootImage(ctx, artJZBootImageConfig(ctx)))
-		d.otherImages = append(d.otherImages, buildBootImage(ctx, frameworkJZBootImageConfig(ctx)))
-	}
 
 	dumpOatRules(ctx, d.defaultBootImage)
 }
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 637a32f..4c9add8 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -125,8 +125,6 @@
 	bootImageConfigKey       = android.NewOnceKey("bootImageConfig")
 	artBootImageName         = "art"
 	frameworkBootImageName   = "boot"
-	artJZBootImageName       = "jitzygote-art"
-	frameworkJZBootImageName = "jitzygote-boot"
 )
 
 // Construct the global boot image configs.
@@ -180,33 +178,9 @@
 			dexLocationsDeps: append(artLocations, frameworkLocations...),
 		}
 
-		// ART config for JIT-zygote boot image.
-		artJZCfg := bootImageConfig{
-			extension:        false,
-			name:             artJZBootImageName,
-			stem:             "apex",
-			installSubdir:    artSubdir,
-			modules:          artModules,
-			dexLocations:     artLocations,
-			dexLocationsDeps: artLocations,
-		}
-
-		// Framework config for JIT-zygote boot image extension.
-		frameworkJZCfg := bootImageConfig{
-			extension:        true,
-			name:             frameworkJZBootImageName,
-			stem:             "apex",
-			installSubdir:    frameworkSubdir,
-			modules:          frameworkModules,
-			dexLocations:     frameworkLocations,
-			dexLocationsDeps: append(artLocations, frameworkLocations...),
-		}
-
 		configs := map[string]*bootImageConfig{
 			artBootImageName:         &artCfg,
 			frameworkBootImageName:   &frameworkCfg,
-			artJZBootImageName:       &artJZCfg,
-			frameworkJZBootImageName: &frameworkJZCfg,
 		}
 
 		// common to all configs
@@ -249,11 +223,6 @@
 		frameworkCfg.primaryImages = artCfg.images
 		frameworkCfg.imageLocations = append(artCfg.imageLocations, frameworkCfg.imageLocations...)
 
-		// specific to the jitzygote-framework config
-		frameworkJZCfg.dexPathsDeps = append(artJZCfg.dexPathsDeps, frameworkJZCfg.dexPathsDeps...)
-		frameworkJZCfg.primaryImages = artJZCfg.images
-		frameworkJZCfg.imageLocations = append(artJZCfg.imageLocations, frameworkJZCfg.imageLocations...)
-
 		return configs
 	}).(map[string]*bootImageConfig)
 }
@@ -266,14 +235,6 @@
 	return *genBootImageConfigs(ctx)[frameworkBootImageName]
 }
 
-func artJZBootImageConfig(ctx android.PathContext) bootImageConfig {
-	return *genBootImageConfigs(ctx)[artJZBootImageName]
-}
-
-func frameworkJZBootImageConfig(ctx android.PathContext) bootImageConfig {
-	return *genBootImageConfigs(ctx)[frameworkJZBootImageName]
-}
-
 func defaultBootclasspath(ctx android.PathContext) []string {
 	return ctx.Config().OnceStringSlice(defaultBootclasspathKey, func() []string {
 		global := dexpreoptGlobalConfig(ctx)
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 098400b..959f1c7 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -534,6 +534,9 @@
 		ctx.AddMissingDependencies(sdkDep.java9Classpath)
 	} else if sdkDep.useFiles {
 		deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
+		deps.aidlPreprocess = sdkDep.aidl
+	} else {
+		deps.aidlPreprocess = sdkDep.aidl
 	}
 
 	ctx.VisitDirectDeps(func(module android.Module) {