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/core/java/com | |
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/core/java/com')
19 files changed, 67 insertions, 50 deletions
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java index 1366149..7d427d6 100644 --- a/services/core/java/com/android/server/AppOpsService.java +++ b/services/core/java/com/android/server/AppOpsService.java @@ -23,6 +23,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.Iterator; @@ -915,7 +916,7 @@ public class AppOpsService extends IAppOpsService.Stub { boolean success = false; try { XmlPullParser parser = Xml.newPullParser(); - parser.setInput(stream, null); + parser.setInput(stream, StandardCharsets.UTF_8.name()); int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { @@ -1075,7 +1076,7 @@ public class AppOpsService extends IAppOpsService.Stub { try { XmlSerializer out = new FastXmlSerializer(); - out.setOutput(stream, "utf-8"); + out.setOutput(stream, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.startTag(null, "app-ops"); diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java index 5dbf4c9..9b7b2d3 100644 --- a/services/core/java/com/android/server/DeviceIdleController.java +++ b/services/core/java/com/android/server/DeviceIdleController.java @@ -71,6 +71,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; /** * Keeps track of device idleness and drives low power mode based on that. @@ -679,7 +680,7 @@ public class DeviceIdleController extends SystemService { } try { XmlPullParser parser = Xml.newPullParser(); - parser.setInput(stream, null); + parser.setInput(stream, StandardCharsets.UTF_8.name()); readConfigFileLocked(parser); } catch (XmlPullParserException e) { } finally { @@ -756,7 +757,7 @@ public class DeviceIdleController extends SystemService { try { synchronized (this) { XmlSerializer out = new FastXmlSerializer(); - out.setOutput(memStream, "utf-8"); + out.setOutput(memStream, StandardCharsets.UTF_8.name()); writeConfigFileLocked(out); } } catch (IOException e) { diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index f5d323d..256a662 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -126,6 +126,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -3521,7 +3522,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub try { fos = subtypesFile.startWrite(); final XmlSerializer out = new FastXmlSerializer(); - out.setOutput(fos, "utf-8"); + out.setOutput(fos, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); out.startTag(null, NODE_SUBTYPES); @@ -3567,7 +3568,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub try { fis = subtypesFile.openRead(); final XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int type = parser.getEventType(); // Skip parsing until START_TAG while ((type = parser.next()) != XmlPullParser.START_TAG diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java index 003d0e7..c32de41 100644 --- a/services/core/java/com/android/server/MountService.java +++ b/services/core/java/com/android/server/MountService.java @@ -1204,7 +1204,7 @@ class MountService extends IMountService.Stub try { fis = mSettingsFile.openRead(); final XmlPullParser in = Xml.newPullParser(); - in.setInput(fis, null); + in.setInput(fis, StandardCharsets.UTF_8.name()); int type; while ((type = in.next()) != END_DOCUMENT) { @@ -1244,7 +1244,7 @@ class MountService extends IMountService.Stub fos = mSettingsFile.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_VOLUMES); writeIntAttribute(out, ATTR_VERSION, VERSION_FIX_PRIMARY); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 0ee1ae4..9ffb874 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -235,6 +235,7 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.ref.WeakReference; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -7671,7 +7672,7 @@ public final class ActivityManagerService extends ActivityManagerNative fos = mGrantFile.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_URI_GRANTS); for (UriPermission.Snapshot perm : persist) { @@ -7706,7 +7707,7 @@ public final class ActivityManagerService extends ActivityManagerNative try { fis = mGrantFile.openRead(); final XmlPullParser in = Xml.newPullParser(); - in.setInput(fis, null); + in.setInput(fis, StandardCharsets.UTF_8.name()); int type; while ((type = in.next()) != END_DOCUMENT) { diff --git a/services/core/java/com/android/server/am/CompatModePackages.java b/services/core/java/com/android/server/am/CompatModePackages.java index 0fe9231..814e8b4 100644 --- a/services/core/java/com/android/server/am/CompatModePackages.java +++ b/services/core/java/com/android/server/am/CompatModePackages.java @@ -21,6 +21,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.*; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -86,7 +87,7 @@ public final class CompatModePackages { try { fis = mFile.openRead(); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int eventType = parser.getEventType(); while (eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_DOCUMENT) { @@ -362,7 +363,7 @@ public final class CompatModePackages { try { fos = mFile.startWrite(); XmlSerializer out = new FastXmlSerializer(); - out.setOutput(fos, "utf-8"); + out.setOutput(fos, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); out.startTag(null, "compat-packages"); diff --git a/services/core/java/com/android/server/content/SyncStorageEngine.java b/services/core/java/com/android/server/content/SyncStorageEngine.java index f154c73..d68b615 100644 --- a/services/core/java/com/android/server/content/SyncStorageEngine.java +++ b/services/core/java/com/android/server/content/SyncStorageEngine.java @@ -58,6 +58,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; @@ -1814,7 +1815,7 @@ public class SyncStorageEngine extends Handler { Log.v(TAG_FILE, "Reading " + mAccountInfoFile.getBaseFile()); } XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int eventType = parser.getEventType(); while (eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_DOCUMENT) { @@ -2153,7 +2154,7 @@ public class SyncStorageEngine extends Handler { try { fos = mAccountInfoFile.startWrite(); XmlSerializer out = new FastXmlSerializer(); - out.setOutput(fos, "utf-8"); + out.setOutput(fos, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -2445,7 +2446,7 @@ public class SyncStorageEngine extends Handler { } XmlPullParser parser; parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int eventType = parser.getEventType(); while (eventType != XmlPullParser.START_TAG && @@ -2581,7 +2582,7 @@ public class SyncStorageEngine extends Handler { } fos = mPendingFile.startWrite(); XmlSerializer out = new FastXmlSerializer(); - out.setOutput(fos, "utf-8"); + out.setOutput(fos, StandardCharsets.UTF_8.name()); for (int i = 0; i < N; i++) { PendingOperation pop = mPendingOperations.get(i); @@ -2634,7 +2635,7 @@ public class SyncStorageEngine extends Handler { try { XmlSerializer out = new FastXmlSerializer(); - out.setOutput(fos, "utf-8"); + out.setOutput(fos, StandardCharsets.UTF_8.name()); writePendingOperationLocked(op, out); out.endDocument(); mPendingFile.finishWrite(fos); diff --git a/services/core/java/com/android/server/display/PersistentDataStore.java b/services/core/java/com/android/server/display/PersistentDataStore.java index 67b3695..d676b35 100644 --- a/services/core/java/com/android/server/display/PersistentDataStore.java +++ b/services/core/java/com/android/server/display/PersistentDataStore.java @@ -35,6 +35,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import libcore.io.IoUtils; @@ -195,7 +196,7 @@ final class PersistentDataStore { XmlPullParser parser; try { parser = Xml.newPullParser(); - parser.setInput(new BufferedInputStream(is), null); + parser.setInput(new BufferedInputStream(is), StandardCharsets.UTF_8.name()); loadFromXml(parser); } catch (IOException ex) { Slog.w(TAG, "Failed to load display manager persistent store data.", ex); @@ -215,7 +216,7 @@ final class PersistentDataStore { boolean success = false; try { XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(new BufferedOutputStream(os), "utf-8"); + serializer.setOutput(new BufferedOutputStream(os), StandardCharsets.UTF_8.name()); saveToXml(serializer); serializer.flush(); success = true; @@ -284,4 +285,4 @@ final class PersistentDataStore { serializer.endTag(null, "display-manager-state"); serializer.endDocument(); } -}
\ No newline at end of file +} diff --git a/services/core/java/com/android/server/input/PersistentDataStore.java b/services/core/java/com/android/server/input/PersistentDataStore.java index 92fa813..f6d7244 100644 --- a/services/core/java/com/android/server/input/PersistentDataStore.java +++ b/services/core/java/com/android/server/input/PersistentDataStore.java @@ -37,6 +37,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -214,7 +215,7 @@ final class PersistentDataStore { XmlPullParser parser; try { parser = Xml.newPullParser(); - parser.setInput(new BufferedInputStream(is), null); + parser.setInput(new BufferedInputStream(is), StandardCharsets.UTF_8.name()); loadFromXml(parser); } catch (IOException ex) { Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex); @@ -234,7 +235,7 @@ final class PersistentDataStore { boolean success = false; try { XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(new BufferedOutputStream(os), "utf-8"); + serializer.setOutput(new BufferedOutputStream(os), StandardCharsets.UTF_8.name()); saveToXml(serializer); serializer.flush(); success = true; diff --git a/services/core/java/com/android/server/job/JobStore.java b/services/core/java/com/android/server/job/JobStore.java index b64c677..24d4f15 100644 --- a/services/core/java/com/android/server/job/JobStore.java +++ b/services/core/java/com/android/server/job/JobStore.java @@ -41,6 +41,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.Iterator; import java.util.List; @@ -292,7 +293,7 @@ public class JobStore { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); XmlSerializer out = new FastXmlSerializer(); - out.setOutput(baos, "utf-8"); + out.setOutput(baos, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -450,7 +451,7 @@ public class JobStore { private List<JobStatus> readJobMapImpl(FileInputStream fis) throws XmlPullParserException, IOException { XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int eventType = parser.getEventType(); while (eventType != XmlPullParser.START_TAG && 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.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.Arrays; import java.util.List; @@ -1290,7 +1291,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub 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 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub 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); diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index de74a04..764d085 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -120,6 +120,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.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; @@ -391,7 +392,7 @@ public class NotificationManagerService extends SystemService { try { infile = mPolicyFile.openRead(); final XmlPullParser parser = Xml.newPullParser(); - parser.setInput(infile, null); + parser.setInput(infile, StandardCharsets.UTF_8.name()); int type; String tag; @@ -449,7 +450,7 @@ public class NotificationManagerService extends SystemService { try { final XmlSerializer out = new FastXmlSerializer(); - out.setOutput(stream, "utf-8"); + out.setOutput(stream, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.startTag(null, TAG_BODY); out.attribute(null, ATTR_VERSION, Integer.toString(DB_VERSION)); diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java index 09096ff..a1738a2 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerService.java +++ b/services/core/java/com/android/server/pm/PackageInstallerService.java @@ -105,6 +105,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; @@ -323,7 +324,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub { try { fis = mSessionsFile.openRead(); final XmlPullParser in = Xml.newPullParser(); - in.setInput(fis, null); + in.setInput(fis, StandardCharsets.UTF_8.name()); int type; while ((type = in.next()) != END_DOCUMENT) { @@ -410,7 +411,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub { fos = mSessionsFile.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_SESSIONS); final int size = mSessions.size(); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 145786f..944fa52 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -13054,7 +13054,7 @@ public class PackageManagerService extends IPackageManager.Stub { ByteArrayOutputStream dataStream = new ByteArrayOutputStream(); try { final XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(dataStream, "utf-8"); + serializer.setOutput(dataStream, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.startTag(null, TAG_PREFERRED_BACKUP); @@ -13083,7 +13083,7 @@ public class PackageManagerService extends IPackageManager.Stub { try { final XmlPullParser parser = Xml.newPullParser(); - parser.setInput(new ByteArrayInputStream(backup), null); + parser.setInput(new ByteArrayInputStream(backup), StandardCharsets.UTF_8.name()); int type; while ((type = parser.next()) != XmlPullParser.START_TAG @@ -13865,7 +13865,7 @@ public class PackageManagerService extends IPackageManager.Stub { BufferedOutputStream str = new BufferedOutputStream(fout); XmlSerializer serializer = new FastXmlSerializer(); try { - serializer.setOutput(str, "utf-8"); + serializer.setOutput(str, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature( "http://xmlpull.org/v1/doc/features.html#indent-output", true); diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 2e9656a..76ef19f 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -94,6 +94,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -1346,7 +1347,7 @@ final class Settings { str = new FileInputStream(userPackagesStateFile); } final XmlPullParser parser = Xml.newPullParser(); - parser.setInput(str, null); + parser.setInput(str, StandardCharsets.UTF_8.name()); int type; while ((type=parser.next()) != XmlPullParser.START_TAG @@ -1598,7 +1599,7 @@ final class Settings { final BufferedOutputStream str = new BufferedOutputStream(fstr); final XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(str, "utf-8"); + serializer.setOutput(str, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -1922,7 +1923,7 @@ final class Settings { //XmlSerializer serializer = XmlUtils.serializerInstance(); XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(str, "utf-8"); + serializer.setOutput(str, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -2339,7 +2340,7 @@ final class Settings { str = new FileInputStream(mSettingsFilename); } XmlPullParser parser = Xml.newPullParser(); - parser.setInput(str, null); + parser.setInput(str, StandardCharsets.UTF_8.name()); int type; while ((type = parser.next()) != XmlPullParser.START_TAG @@ -4288,7 +4289,7 @@ final class Settings { out = destination.startWrite(); XmlSerializer serializer = Xml.newSerializer(); - serializer.setOutput(out, "utf-8"); + serializer.setOutput(out, StandardCharsets.UTF_8.name()); serializer.setFeature( "http://xmlpull.org/v1/doc/features.html#indent-output", true); serializer.startDocument(null, true); diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index e463fad..40c8ca3 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -70,6 +70,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; import java.util.Set; @@ -670,7 +671,7 @@ public class UserManagerService extends IUserManager.Stub { try { fis = userListFile.openRead(); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { @@ -823,7 +824,7 @@ public class UserManagerService extends IUserManager.Stub { // XmlSerializer serializer = XmlUtils.serializerInstance(); final XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(bos, "utf-8"); + serializer.setOutput(bos, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -882,7 +883,7 @@ public class UserManagerService extends IUserManager.Stub { // XmlSerializer serializer = XmlUtils.serializerInstance(); final XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(bos, "utf-8"); + serializer.setOutput(bos, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); @@ -964,7 +965,7 @@ public class UserManagerService extends IUserManager.Stub { new AtomicFile(new File(mUsersDir, Integer.toString(id) + XML_SUFFIX)); fis = userFile.openRead(); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { @@ -1569,7 +1570,7 @@ public class UserManagerService extends IUserManager.Stub { try { fis = restrictionsFile.openRead(); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); + parser.setInput(fis, StandardCharsets.UTF_8.name()); XmlUtils.nextElement(parser); if (parser.getEventType() != XmlPullParser.START_TAG) { Slog.e(LOG_TAG, "Unable to read restrictions file " @@ -1658,7 +1659,7 @@ public class UserManagerService extends IUserManager.Stub { final BufferedOutputStream bos = new BufferedOutputStream(fos); final XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(bos, "utf-8"); + serializer.setOutput(bos, StandardCharsets.UTF_8.name()); serializer.startDocument(null, true); serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); diff --git a/services/core/java/com/android/server/tv/PersistentDataStore.java b/services/core/java/com/android/server/tv/PersistentDataStore.java index fcfaaea..f9b5b9a 100644 --- a/services/core/java/com/android/server/tv/PersistentDataStore.java +++ b/services/core/java/com/android/server/tv/PersistentDataStore.java @@ -44,6 +44,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -167,7 +168,7 @@ final class PersistentDataStore { XmlPullParser parser; try { parser = Xml.newPullParser(); - parser.setInput(new BufferedInputStream(is), null); + parser.setInput(new BufferedInputStream(is), StandardCharsets.UTF_8.name()); loadFromXml(parser); } catch (IOException | XmlPullParserException ex) { Slog.w(TAG, "Failed to load tv input manager persistent store data.", ex); @@ -200,7 +201,7 @@ final class PersistentDataStore { boolean success = false; try { XmlSerializer serializer = new FastXmlSerializer(); - serializer.setOutput(new BufferedOutputStream(os), "utf-8"); + serializer.setOutput(new BufferedOutputStream(os), StandardCharsets.UTF_8.name()); saveToXml(serializer); serializer.flush(); success = true; diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 755c414..4098698 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -79,6 +79,7 @@ import java.io.FileNotFoundException; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import org.xmlpull.v1.XmlPullParser; @@ -1165,7 +1166,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { try { stream = new FileOutputStream(journal.chooseForWrite(), false); XmlSerializer out = new FastXmlSerializer(); - out.setOutput(stream, "utf-8"); + out.setOutput(stream, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.startTag(null, "wp"); @@ -1248,7 +1249,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { try { stream = new FileInputStream(file); XmlPullParser parser = Xml.newPullParser(); - parser.setInput(stream, null); + parser.setInput(stream, StandardCharsets.UTF_8.name()); int type; do { diff --git a/services/core/java/com/android/server/wm/DisplaySettings.java b/services/core/java/com/android/server/wm/DisplaySettings.java index ba995f2..01f878c 100644 --- a/services/core/java/com/android/server/wm/DisplaySettings.java +++ b/services/core/java/com/android/server/wm/DisplaySettings.java @@ -32,6 +32,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.HashMap; /** @@ -108,7 +109,7 @@ public class DisplaySettings { boolean success = false; try { XmlPullParser parser = Xml.newPullParser(); - parser.setInput(stream, null); + parser.setInput(stream, StandardCharsets.UTF_8.name()); int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { @@ -193,7 +194,7 @@ public class DisplaySettings { try { XmlSerializer out = new FastXmlSerializer(); - out.setOutput(stream, "utf-8"); + out.setOutput(stream, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.startTag(null, "display-settings"); |