Fix WriteFileRule escaping

WriteFileRule shouldn't force the caller to ninja escape the input,
and should shell escape spaces.

Bug: 182612695
Test: manual
Change-Id: Ide2f1ed92783eef7883279238de209d992d8f735
diff --git a/android/defs.go b/android/defs.go
index 1a76721..1a7c459 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -145,7 +145,7 @@
 
 func buildWriteFileRule(ctx BuilderContext, outputFile WritablePath, content string) {
 	content = echoEscaper.Replace(content)
-	content = proptools.ShellEscape(content)
+	content = proptools.NinjaEscape(proptools.ShellEscapeIncludingSpaces(content))
 	if content == "" {
 		content = "''"
 	}
diff --git a/android/rule_builder.go b/android/rule_builder.go
index 17f211b..41d2fa6 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -537,7 +537,7 @@
 		}
 
 		// Create a rule to write the manifest as a the textproto.
-		WriteFileRule(r.ctx, r.sboxManifestPath, proptools.NinjaEscape(proto.MarshalTextString(&manifest)))
+		WriteFileRule(r.ctx, r.sboxManifestPath, proto.MarshalTextString(&manifest))
 
 		// Generate a new string to use as the command line of the sbox rule.  This uses
 		// a RuleBuilderCommand as a convenience method of building the command line, then