Revert "Sandbox soong_build by changing to root directory"

This reverts commit 05c25ccb4adb5329add700b533416c226cdbfa96.

Reason for revert: broke absolute OUT_DIR
Bug: 146437378

Change-Id: I523ed79d40e1c1ef040212ba794a7a084abea75d
diff --git a/env/env.go b/env/env.go
index a98e1f6..bf58a99 100644
--- a/env/env.go
+++ b/env/env.go
@@ -27,7 +27,7 @@
 type envFileEntry struct{ Key, Value string }
 type envFileData []envFileEntry
 
-func EnvFileContents(envDeps map[string]string) ([]byte, error) {
+func WriteEnvFile(filename string, envDeps map[string]string) error {
 	contents := make(envFileData, 0, len(envDeps))
 	for key, value := range envDeps {
 		contents = append(contents, envFileEntry{key, value})
@@ -37,12 +37,17 @@
 
 	data, err := json.MarshalIndent(contents, "", "    ")
 	if err != nil {
-		return nil, err
+		return err
 	}
 
 	data = append(data, '\n')
 
-	return data, nil
+	err = ioutil.WriteFile(filename, data, 0664)
+	if err != nil {
+		return err
+	}
+
+	return nil
 }
 
 func StaleEnvFile(filename string) (bool, error) {