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 /packages/PrintSpooler | |
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 'packages/PrintSpooler')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java | 5 | ||||
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java b/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java index 377d2d5..49e6740 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java @@ -63,6 +63,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.List; @@ -757,7 +758,7 @@ public final class PrintSpoolerService extends Service { out = mStatePersistFile.startWrite(); XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(out, "utf-8"); + serializer.setOutput(out, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.startTag(null, TAG_SPOOLER); @@ -952,7 +953,7 @@ public final class PrintSpoolerService extends Service { } try { XmlPullParser parser = Xml.newPullParser(); - parser.setInput(in, null); + parser.setInput(in, StandardCharsets.UTF_8.name()); parseState(parser); } catch (IllegalStateException ise) { Slog.w(LOG_TAG, "Failed parsing ", ise); diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java b/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java index 22a7f86..80c28e0 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/FusedPrintersProvider.java @@ -46,6 +46,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; @@ -562,7 +563,7 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> { try { List<PrinterInfo> printers = new ArrayList<>(); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(in, null); + parser.setInput(in, StandardCharsets.UTF_8.name()); parseState(parser, printers); // Take a note which version of the history was read. mLastReadHistoryTimestamp = mStatePersistFile.getBaseFile().lastModified(); @@ -686,7 +687,7 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> { out = mStatePersistFile.startWrite(); XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(out, "utf-8"); + serializer.setOutput(out, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.startTag(null, TAG_PRINTERS); |