Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f453164 authored by Narayan Kamath's avatar Narayan Kamath Committed by Gerrit Code Review
Browse files

Merge "Pass charset to XmlPullParser.setInput instead of null"

parents d3916c88 4f11754f
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collection;
import java.util.Collections;
import java.util.Collections;
@@ -541,7 +542,7 @@ public abstract class RegisteredServicesCache<V> {
            }
            }
            fis = mPersistentServicesFile.openRead();
            fis = mPersistentServicesFile.openRead();
            XmlPullParser parser = Xml.newPullParser();
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(fis, null);
            parser.setInput(fis, StandardCharsets.UTF_8.name());
            int eventType = parser.getEventType();
            int eventType = parser.getEventType();
            while (eventType != XmlPullParser.START_TAG
            while (eventType != XmlPullParser.START_TAG
                    && eventType != XmlPullParser.END_DOCUMENT) {
                    && eventType != XmlPullParser.END_DOCUMENT) {
@@ -591,7 +592,7 @@ public abstract class RegisteredServicesCache<V> {
        try {
        try {
            fos = mPersistentServicesFile.startWrite();
            fos = mPersistentServicesFile.startWrite();
            XmlSerializer out = new FastXmlSerializer();
            XmlSerializer out = new FastXmlSerializer();
            out.setOutput(fos, "utf-8");
            out.setOutput(fos, StandardCharsets.UTF_8.name());
            out.startDocument(null, true);
            out.startDocument(null, true);
            out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
            out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
            out.startTag(null, "services");
            out.startTag(null, "services");
+3 −2
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashMap;
@@ -991,7 +992,7 @@ public class ActivityChooserModel extends DataSetObservable {
        }
        }
        try {
        try {
            XmlPullParser parser = Xml.newPullParser();
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(fis, null);
            parser.setInput(fis, StandardCharsets.UTF_8.name());


            int type = XmlPullParser.START_DOCUMENT;
            int type = XmlPullParser.START_DOCUMENT;
            while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
            while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
@@ -1074,7 +1075,7 @@ public class ActivityChooserModel extends DataSetObservable {


            try {
            try {
                serializer.setOutput(fos, null);
                serializer.setOutput(fos, null);
                serializer.startDocument("UTF-8", true);
                serializer.startDocument(StandardCharsets.UTF_8.name(), true);
                serializer.startTag(null, TAG_HISTORICAL_RECORDS);
                serializer.startTag(null, TAG_HISTORICAL_RECORDS);


                final int recordCount = historicalRecords.size();
                final int recordCount = historicalRecords.size();
+5 −4
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStream;
import java.net.ProtocolException;
import java.net.ProtocolException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.HashSet;
@@ -181,7 +182,7 @@ public class XmlUtils {
    public static final void writeMapXml(Map val, OutputStream out)
    public static final void writeMapXml(Map val, OutputStream out)
            throws XmlPullParserException, java.io.IOException {
            throws XmlPullParserException, java.io.IOException {
        XmlSerializer serializer = new FastXmlSerializer();
        XmlSerializer serializer = new FastXmlSerializer();
        serializer.setOutput(out, "utf-8");
        serializer.setOutput(out, StandardCharsets.UTF_8.name());
        serializer.startDocument(null, true);
        serializer.startDocument(null, true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        writeMapXml(val, null, serializer);
        writeMapXml(val, null, serializer);
@@ -204,7 +205,7 @@ public class XmlUtils {
    throws XmlPullParserException, java.io.IOException
    throws XmlPullParserException, java.io.IOException
    {
    {
        XmlSerializer serializer = Xml.newSerializer();
        XmlSerializer serializer = Xml.newSerializer();
        serializer.setOutput(out, "utf-8");
        serializer.setOutput(out, StandardCharsets.UTF_8.name());
        serializer.startDocument(null, true);
        serializer.startDocument(null, true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        writeListXml(val, null, serializer);
        writeListXml(val, null, serializer);
@@ -731,7 +732,7 @@ public class XmlUtils {
    throws XmlPullParserException, java.io.IOException
    throws XmlPullParserException, java.io.IOException
    {
    {
        XmlPullParser   parser = Xml.newPullParser();
        XmlPullParser   parser = Xml.newPullParser();
        parser.setInput(in, null);
        parser.setInput(in, StandardCharsets.UTF_8.name());
        return (HashMap<String, ?>) readValueXml(parser, new String[1]);
        return (HashMap<String, ?>) readValueXml(parser, new String[1]);
    }
    }


@@ -752,7 +753,7 @@ public class XmlUtils {
    throws XmlPullParserException, java.io.IOException
    throws XmlPullParserException, java.io.IOException
    {
    {
        XmlPullParser   parser = Xml.newPullParser();
        XmlPullParser   parser = Xml.newPullParser();
        parser.setInput(in, null);
        parser.setInput(in, StandardCharsets.UTF_8.name());
        return (ArrayList)readValueXml(parser, new String[1]);
        return (ArrayList)readValueXml(parser, new String[1]);
    }
    }
    
    
+3 −2
Original line number Original line Diff line number Diff line
@@ -63,6 +63,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;


@@ -756,7 +757,7 @@ public final class PrintSpoolerService extends Service {
                out = mStatePersistFile.startWrite();
                out = mStatePersistFile.startWrite();


                XmlSerializer serializer = new FastXmlSerializer();
                XmlSerializer serializer = new FastXmlSerializer();
                serializer.setOutput(out, "utf-8");
                serializer.setOutput(out, StandardCharsets.UTF_8.name());
                serializer.startDocument(null, true);
                serializer.startDocument(null, true);
                serializer.startTag(null, TAG_SPOOLER);
                serializer.startTag(null, TAG_SPOOLER);


@@ -947,7 +948,7 @@ public final class PrintSpoolerService extends Service {
            }
            }
            try {
            try {
                XmlPullParser parser = Xml.newPullParser();
                XmlPullParser parser = Xml.newPullParser();
                parser.setInput(in, null);
                parser.setInput(in, StandardCharsets.UTF_8.name());
                parseState(parser);
                parseState(parser);
            } catch (IllegalStateException ise) {
            } catch (IllegalStateException ise) {
                Slog.w(LOG_TAG, "Failed parsing ", ise);
                Slog.w(LOG_TAG, "Failed parsing ", ise);
+3 −2
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashMap;
@@ -562,7 +563,7 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> {
                try {
                try {
                    List<PrinterInfo> printers = new ArrayList<>();
                    List<PrinterInfo> printers = new ArrayList<>();
                    XmlPullParser parser = Xml.newPullParser();
                    XmlPullParser parser = Xml.newPullParser();
                    parser.setInput(in, null);
                    parser.setInput(in, StandardCharsets.UTF_8.name());
                    parseState(parser, printers);
                    parseState(parser, printers);
                    // Take a note which version of the history was read.
                    // Take a note which version of the history was read.
                    mLastReadHistoryTimestamp = mStatePersistFile.getBaseFile().lastModified();
                    mLastReadHistoryTimestamp = mStatePersistFile.getBaseFile().lastModified();
@@ -686,7 +687,7 @@ public final class FusedPrintersProvider extends Loader<List<PrinterInfo>> {
                    out = mStatePersistFile.startWrite();
                    out = mStatePersistFile.startWrite();


                    XmlSerializer serializer = new FastXmlSerializer();
                    XmlSerializer serializer = new FastXmlSerializer();
                    serializer.setOutput(out, "utf-8");
                    serializer.setOutput(out, StandardCharsets.UTF_8.name());
                    serializer.startDocument(null, true);
                    serializer.startDocument(null, true);
                    serializer.startTag(null, TAG_PRINTERS);
                    serializer.startTag(null, TAG_PRINTERS);


Loading