Merge changes I9e38ac73,I9412147f

* changes:
  Honor PreventInstall for APKs and dexpreopt files
  Add dependency from hostdex installed module to Make intermediates
diff --git a/java/androidmk.go b/java/androidmk.go
index 35b4c8e..4c115d5 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -47,6 +47,7 @@
 					if library.dexJarFile.IsSet() {
 						entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
 					}
+					entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", library.hostdexInstallFile)
 					entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
 					entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
 					entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
diff --git a/java/app.go b/java/app.go
index 7c195fc..c08ec06 100755
--- a/java/app.go
+++ b/java/app.go
@@ -471,6 +471,7 @@
 	a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
 	a.dexpreopter.classLoaderContexts = a.classLoaderContexts
 	a.dexpreopter.manifestFile = a.mergedManifestFile
+	a.dexpreopter.preventInstall = a.appProperties.PreventInstall
 
 	if ctx.ModuleName() != "framework-res" {
 		a.Module.compile(ctx, a.aaptSrcJar)
@@ -720,7 +721,9 @@
 	apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
 
 	// Install the app package.
-	if (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() {
+	if (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() &&
+		!a.appProperties.PreventInstall {
+
 		var extraInstalledPaths android.Paths
 		for _, extra := range a.extraOutputFiles {
 			installed := ctx.InstallFile(a.installDir, extra.Base(), extra)
diff --git a/java/base.go b/java/base.go
index 859baaf..6930bcd 100644
--- a/java/base.go
+++ b/java/base.go
@@ -407,6 +407,9 @@
 	// installed file for binary dependency
 	installFile android.Path
 
+	// installed file for hostdex copy
+	hostdexInstallFile android.InstallPath
+
 	// list of .java files and srcjars that was passed to javac
 	compiledJavaSrcs android.Paths
 	compiledSrcJars  android.Paths
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 8ab5a45..7c081b6 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -66,6 +66,7 @@
 	isApp               bool
 	isTest              bool
 	isPresignedPrebuilt bool
+	preventInstall      bool
 
 	manifestFile        android.Path
 	statusFile          android.WritablePath
@@ -356,7 +357,7 @@
 				installDirOnDevice:  installPath,
 				installFileOnDevice: installBase,
 			})
-		} else {
+		} else if !d.preventInstall {
 			ctx.InstallFile(installPath, installBase, install.From)
 		}
 	}
diff --git a/java/java.go b/java/java.go
index 3bb9a92..2f9e03a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -571,7 +571,8 @@
 		}
 		hostDexNeeded := Bool(j.deviceProperties.Hostdex) && !ctx.Host()
 		if hostDexNeeded {
-			ctx.InstallFile(android.PathForHostDexInstall(ctx, "framework"),
+			j.hostdexInstallFile = ctx.InstallFile(
+				android.PathForHostDexInstall(ctx, "framework"),
 				j.Stem()+"-hostdex.jar", j.outputFile)
 		}
 		var installDir android.InstallPath