diff options
author | Wojciech Staszkiewicz <staszkiewicz@google.com> | 2015-05-08 14:58:46 +0100 |
---|---|---|
committer | Wojciech Staszkiewicz <staszkiewicz@google.com> | 2015-05-14 10:24:34 +0100 |
commit | 9e9e2e73c6ec7bece20268196dc89ad0c8bafad4 (patch) | |
tree | c2bf1f99d8bc64db925a95dcab0b5ddec6b8de41 /services/usb | |
parent | 39087b1cec6a54e96ab9eafe8317952720790533 (diff) | |
download | frameworks_base-9e9e2e73c6ec7bece20268196dc89ad0c8bafad4.zip frameworks_base-9e9e2e73c6ec7bece20268196dc89ad0c8bafad4.tar.gz frameworks_base-9e9e2e73c6ec7bece20268196dc89ad0c8bafad4.tar.bz2 |
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
Diffstat (limited to 'services/usb')
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbSettingsManager.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbSettingsManager.java b/services/usb/java/com/android/server/usb/UsbSettingsManager.java index bfd1f13..2331a8b 100644 --- a/services/usb/java/com/android/server/usb/UsbSettingsManager.java +++ b/services/usb/java/com/android/server/usb/UsbSettingsManager.java @@ -57,6 +57,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -558,7 +559,7 @@ class UsbSettingsManager { try { fis = new FileInputStream(sSingleUserSettingsFile); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); XmlUtils.nextElement(parser); while (parser.getEventType() != XmlPullParser.END_DOCUMENT) { @@ -594,7 +595,7 @@ class UsbSettingsManager { try { stream = mSettingsFile.openRead(); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(stream, null); + parser.setInput(stream, StandardCharsets.UTF_8.name()); XmlUtils.nextElement(parser); while (parser.getEventType() != XmlPullParser.END_DOCUMENT) { @@ -623,7 +624,7 @@ class UsbSettingsManager { fos = mSettingsFile.startWrite(); FastXmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(fos, "utf-8"); + serializer.setOutput(fos, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startTag(null, "settings"); |