Fix Ferrochrome bootloop

Don't use pipe reader/writer as there can be deadlock.

Bug: N/A
Test: N/A

Change-Id: I6622e52f0fa51477534fe1bc7c3bdb9c94b667f8
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/ConfigJson.java b/android/TerminalApp/java/com/android/virtualization/terminal/ConfigJson.java
index cec1b7a..5cf123e 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/ConfigJson.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/ConfigJson.java
@@ -38,14 +38,13 @@
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.PipedReader;
-import java.io.PipedWriter;
 import java.io.Reader;
 import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /** This class and its inner classes model vm_config.json. */
 class ConfigJson {
@@ -78,19 +77,15 @@
 
     /** Parses JSON file at jsonPath */
     static ConfigJson from(Context context, Path jsonPath) {
-        try (FileReader fileReader = new FileReader(jsonPath.toFile());
-                Reader r = replaceKeywords(fileReader, context)) {
-            return new Gson().fromJson(r, ConfigJson.class);
+        try (FileReader fileReader = new FileReader(jsonPath.toFile())) {
+            String content = replaceKeywords(fileReader, context);
+            return new Gson().fromJson(content, ConfigJson.class);
         } catch (Exception e) {
             throw new RuntimeException("Failed to parse " + jsonPath, e);
         }
     }
 
-    private static Reader replaceKeywords(Reader r, Context context) throws IOException {
-        PipedWriter pipeIn = new PipedWriter();
-        PipedReader pipeOut = new PipedReader();
-        pipeOut.connect(pipeIn);
-
+    private static String replaceKeywords(Reader r, Context context) throws IOException {
         Map<String, String> rules = new HashMap<>();
         rules.put("\\$PAYLOAD_DIR", InstallUtils.getInternalStorageDir(context).toString());
         rules.put("\\$USER_ID", String.valueOf(context.getUserId()));
@@ -103,7 +98,7 @@
         rules.put("\\$APP_DATA_DIR", appDataDir);
 
         try (BufferedReader br = new BufferedReader(r)) {
-            br.lines()
+            return br.lines()
                     .map(
                             line -> {
                                 for (Map.Entry<String, String> rule : rules.entrySet()) {
@@ -111,18 +106,8 @@
                                 }
                                 return line;
                             })
-                    .forEach(
-                            line -> {
-                                try {
-                                    pipeIn.write(line);
-                                    pipeIn.write('\n');
-                                } catch (IOException e) {
-                                    // this cannot happen as it is connected to a pipe.
-                                    throw new RuntimeException(e);
-                                }
-                            });
+                    .collect(Collectors.joining("\n"));
         }
-        return pipeOut;
     }
 
     private int getCpuTopology() {