Pass charset to XmlPullParser.setInput instead of null
Passing null to XmlPullParser.setInput forces it to do additional
work, which can be easily avoided if we know the charset beforehand.
bug: b/20849543
Change-Id: Iaff97be9df2d0f99d7af8f19f65934439c9658e2
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 0ae6735..24ab3b8 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -170,6 +170,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -1290,7 +1291,7 @@
try {
fis = mPolicyFile.openRead();
final XmlPullParser in = Xml.newPullParser();
- in.setInput(fis, null);
+ in.setInput(fis, StandardCharsets.UTF_8.name());
int type;
int version = VERSION_INIT;
@@ -1425,7 +1426,7 @@
fos = mPolicyFile.startWrite();
XmlSerializer out = new FastXmlSerializer();
- out.setOutput(fos, "utf-8");
+ out.setOutput(fos, StandardCharsets.UTF_8.name());
out.startDocument(null, true);
out.startTag(null, TAG_POLICY_LIST);