Merge changes I96f0eb03,Ie883eb45

* changes:
  Parameterize scopes with additional droidstubs args
  Replace references to droiddoc with droidstubs
diff --git a/cc/cc.go b/cc/cc.go
index c42914b..88fede4 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -586,13 +586,6 @@
 	return c.depsInLinkOrder
 }
 
-func (c *Module) StubsSymbolFile() android.OptionalPath {
-	if library, ok := c.linker.(*libraryDecorator); ok {
-		return library.stubsSymbolFile
-	}
-	return android.OptionalPath{}
-}
-
 func (c *Module) StubsVersions() []string {
 	if c.linker != nil {
 		if library, ok := c.linker.(*libraryDecorator); ok {
diff --git a/cc/library.go b/cc/library.go
index 26e86f9..439a2c0 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -367,9 +367,6 @@
 	// Location of the file that should be copied to dist dir when requested
 	distFile android.OptionalPath
 
-	// stubs.symbol_file
-	stubsSymbolFile android.OptionalPath
-
 	versionScriptPath android.ModuleGenPath
 
 	post_install_cmds []string
@@ -606,7 +603,6 @@
 
 func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
 	if library.buildStubs() {
-		library.stubsSymbolFile = android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file)
 		objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex")
 		library.versionScriptPath = versionScript
 		return objs
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 4e4df5b..754b96a 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -271,10 +271,7 @@
 	}
 
 	if len(libInfo.StubsVersion) > 0 {
-		symbolFilePath := filepath.Join(nativeEtcDir, libInfo.StubsSymbolFile.Path().Base())
-		builder.CopyToSnapshot(libInfo.StubsSymbolFile.Path(), symbolFilePath)
 		stubsSet := outputProperties.AddPropertySet("stubs")
-		stubsSet.AddProperty("symbol_file", symbolFilePath)
 		stubsSet.AddProperty("versions", []string{libInfo.StubsVersion})
 	}
 }
@@ -283,7 +280,6 @@
 	nativeIncludeDir          = "include"
 	nativeGeneratedIncludeDir = "include_gen"
 	nativeStubDir             = "lib"
-	nativeEtcDir              = "etc"
 )
 
 // path to the native library. Relative to <sdk_root>/<api_dir>
@@ -348,9 +344,6 @@
 	// are not in use.
 	StubsVersion string
 
-	// The stubs symbol file.
-	StubsSymbolFile android.OptionalPath
-
 	// outputFile is not exported as it is always arch specific.
 	outputFile android.Path
 }
@@ -389,7 +382,6 @@
 
 	if ccModule.HasStubsVariants() {
 		p.StubsVersion = ccModule.StubsVersion()
-		p.StubsSymbolFile = ccModule.StubsSymbolFile()
 	}
 }
 
diff --git a/cmd/zipsync/zipsync.go b/cmd/zipsync/zipsync.go
index a6023d3..294e5ef 100644
--- a/cmd/zipsync/zipsync.go
+++ b/cmd/zipsync/zipsync.go
@@ -115,7 +115,7 @@
 
 			filename := filepath.Join(*outputDir, name)
 			if f.FileInfo().IsDir() {
-				must(os.MkdirAll(filename, f.FileInfo().Mode()))
+				must(os.MkdirAll(filename, 0777))
 			} else {
 				must(os.MkdirAll(filepath.Dir(filename), 0777))
 				in, err := f.Open()
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 1315aba..066694c 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -81,7 +81,7 @@
 
 func getDexLocation(ctx android.PathContext, target android.Target, subdir string, name string) string {
 	if target.Os.Class == android.Host {
-		return filepath.Join("out", "host", ctx.Config().PrebuiltOS(), subdir, name)
+		return filepath.Join(ctx.Config().Getenv("OUT_DIR"), "host", ctx.Config().PrebuiltOS(), subdir, name)
 	} else {
 		return filepath.Join("/", subdir, name)
 	}
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 9e6086f..780da9f 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -1766,7 +1766,6 @@
     sdk_member_name: "stubslib",
     installable: false,
     stubs: {
-        symbol_file: "etc/stubslib.map.txt",
         versions: ["3"],
     },
     arch: {
@@ -1783,7 +1782,6 @@
     name: "stubslib",
     prefer: false,
     stubs: {
-        symbol_file: "etc/stubslib.map.txt",
         versions: ["3"],
     },
     arch: {
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index 5ca83cc..4c3bac3 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -79,7 +79,7 @@
 		sandboxConfig.outDir = absPath(c.ctx, c.config.OutDir())
 		sandboxConfig.distDir = absPath(c.ctx, c.config.DistDir())
 
-		cmd := exec.CommandContext(c.ctx.Context, nsjailPath,
+		sandboxArgs := []string{
 			"-H", "android-build",
 			"-e",
 			"-u", "nobody",
@@ -88,10 +88,21 @@
 			"-B", sandboxConfig.srcDir,
 			"-B", "/tmp",
 			"-B", sandboxConfig.outDir,
-			"-B", sandboxConfig.distDir,
+		}
+
+		if _, err := os.Stat(sandboxConfig.distDir); !os.IsNotExist(err) {
+			//Mount dist dir as read-write if it already exists
+			sandboxArgs = append(sandboxArgs, "-B",
+				sandboxConfig.distDir)
+		}
+
+		sandboxArgs = append(sandboxArgs,
 			"--disable_clone_newcgroup",
 			"--",
 			"/bin/bash", "-c", `if [ $(hostname) == "android-build" ]; then echo "Android" "Success"; else echo Failure; fi`)
+
+		cmd := exec.CommandContext(c.ctx.Context, nsjailPath, sandboxArgs...)
+
 		cmd.Env = c.config.Environment().Environ()
 
 		c.ctx.Verboseln(cmd.Args)
@@ -164,9 +175,6 @@
 		//Mount out dir as read-write
 		"-B", sandboxConfig.outDir,
 
-		//Mount dist dir as read-write
-		"-B", sandboxConfig.distDir,
-
 		// Mount a writable tmp dir
 		"-B", "/tmp",
 
@@ -178,6 +186,11 @@
 		"-q",
 	}
 
+	if _, err := os.Stat(sandboxConfig.distDir); !os.IsNotExist(err) {
+		//Mount dist dir as read-write if it already exists
+		sandboxArgs = append(sandboxArgs, "-B", sandboxConfig.distDir)
+	}
+
 	if c.Sandbox.AllowBuildBrokenUsesNetwork && c.config.BuildBrokenUsesNetwork() {
 		c.ctx.Printf("AllowBuildBrokenUsesNetwork: %v", c.Sandbox.AllowBuildBrokenUsesNetwork)
 		c.ctx.Printf("BuildBrokenUsesNetwork: %v", c.config.BuildBrokenUsesNetwork())