use of org.xmlpull.v1.XmlSerializer in project android_frameworks_base by DirtyUnicorns.
the class NotificationManagerService method writePolicyXml.
private void writePolicyXml(OutputStream stream, boolean forBackup) throws IOException {
final XmlSerializer out = new FastXmlSerializer();
out.setOutput(stream, StandardCharsets.UTF_8.name());
out.startDocument(null, true);
out.startTag(null, TAG_NOTIFICATION_POLICY);
out.attribute(null, ATTR_VERSION, Integer.toString(DB_VERSION));
mZenModeHelper.writeXml(out, forBackup);
mRankingHelper.writeXml(out, forBackup);
out.endTag(null, TAG_NOTIFICATION_POLICY);
out.endDocument();
}
use of org.xmlpull.v1.XmlSerializer in project android_frameworks_base by DirtyUnicorns.
the class XmlUtils method writeMapXml.
/**
* Flatten a Map into an output stream as XML. The map can later be
* read back with readMapXml().
*
* @param val The map to be flattened.
* @param out Where to write the XML data.
*
* @see #writeMapXml(Map, String, XmlSerializer)
* @see #writeListXml
* @see #writeValueXml
* @see #readMapXml
*/
public static final void writeMapXml(Map val, OutputStream out) throws XmlPullParserException, java.io.IOException {
XmlSerializer serializer = new FastXmlSerializer();
serializer.setOutput(out, StandardCharsets.UTF_8.name());
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
writeMapXml(val, null, serializer);
serializer.endDocument();
}
use of org.xmlpull.v1.XmlSerializer in project android_frameworks_base by DirtyUnicorns.
the class XmlUtils method writeListXml.
/**
* Flatten a List into an output stream as XML. The list can later be
* read back with readListXml().
*
* @param val The list to be flattened.
* @param out Where to write the XML data.
*
* @see #writeListXml(List, String, XmlSerializer)
* @see #writeMapXml
* @see #writeValueXml
* @see #readListXml
*/
public static final void writeListXml(List val, OutputStream out) throws XmlPullParserException, java.io.IOException {
XmlSerializer serializer = Xml.newSerializer();
serializer.setOutput(out, StandardCharsets.UTF_8.name());
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
writeListXml(val, null, serializer);
serializer.endDocument();
}
use of org.xmlpull.v1.XmlSerializer in project android_frameworks_base by DirtyUnicorns.
the class DeviceIdleController method handleWriteConfigFile.
void handleWriteConfigFile() {
final ByteArrayOutputStream memStream = new ByteArrayOutputStream();
try {
synchronized (this) {
XmlSerializer out = new FastXmlSerializer();
out.setOutput(memStream, StandardCharsets.UTF_8.name());
writeConfigFileLocked(out);
}
} catch (IOException e) {
}
synchronized (mConfigFile) {
FileOutputStream stream = null;
try {
stream = mConfigFile.startWrite();
memStream.writeTo(stream);
stream.flush();
FileUtils.sync(stream);
stream.close();
mConfigFile.finishWrite(stream);
} catch (IOException e) {
Slog.w(TAG, "Error writing config file", e);
mConfigFile.failWrite(stream);
}
}
}
use of org.xmlpull.v1.XmlSerializer in project android_frameworks_base by DirtyUnicorns.
the class DisplaySettings method writeSettingsLocked.
public void writeSettingsLocked() {
FileOutputStream stream;
try {
stream = mFile.startWrite();
} catch (IOException e) {
Slog.w(TAG, "Failed to write display settings: " + e);
return;
}
try {
XmlSerializer out = new FastXmlSerializer();
out.setOutput(stream, StandardCharsets.UTF_8.name());
out.startDocument(null, true);
out.startTag(null, "display-settings");
for (Entry entry : mEntries.values()) {
out.startTag(null, "display");
out.attribute(null, "name", entry.name);
if (entry.overscanLeft != 0) {
out.attribute(null, "overscanLeft", Integer.toString(entry.overscanLeft));
}
if (entry.overscanTop != 0) {
out.attribute(null, "overscanTop", Integer.toString(entry.overscanTop));
}
if (entry.overscanRight != 0) {
out.attribute(null, "overscanRight", Integer.toString(entry.overscanRight));
}
if (entry.overscanBottom != 0) {
out.attribute(null, "overscanBottom", Integer.toString(entry.overscanBottom));
}
out.endTag(null, "display");
}
out.endTag(null, "display-settings");
out.endDocument();
mFile.finishWrite(stream);
} catch (IOException e) {
Slog.w(TAG, "Failed to write display settings, restoring backup.", e);
mFile.failWrite(stream);
}
}
Aggregations