use of com.android.internal.util.FastXmlSerializer in project android_frameworks_base by ParanoidAndroid.
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, "utf-8");
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);
}
}
use of com.android.internal.util.FastXmlSerializer in project android_frameworks_base by ParanoidAndroid.
the class UsbSettingsManager method writeSettingsLocked.
private void writeSettingsLocked() {
if (DEBUG)
Slog.v(TAG, "writeSettingsLocked()");
FileOutputStream fos = null;
try {
fos = mSettingsFile.startWrite();
FastXmlSerializer serializer = new FastXmlSerializer();
serializer.setOutput(fos, "utf-8");
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, "settings");
for (DeviceFilter filter : mDevicePreferenceMap.keySet()) {
serializer.startTag(null, "preference");
serializer.attribute(null, "package", mDevicePreferenceMap.get(filter));
filter.write(serializer);
serializer.endTag(null, "preference");
}
for (AccessoryFilter filter : mAccessoryPreferenceMap.keySet()) {
serializer.startTag(null, "preference");
serializer.attribute(null, "package", mAccessoryPreferenceMap.get(filter));
filter.write(serializer);
serializer.endTag(null, "preference");
}
serializer.endTag(null, "settings");
serializer.endDocument();
mSettingsFile.finishWrite(fos);
} catch (IOException e) {
Slog.e(TAG, "Failed to write settings", e);
if (fos != null) {
mSettingsFile.failWrite(fos);
}
}
}
use of com.android.internal.util.FastXmlSerializer in project platform_frameworks_base by android.
the class BootReceiver method writeTimestamps.
private void writeTimestamps(HashMap<String, Long> timestamps) {
synchronized (sFile) {
final FileOutputStream stream;
try {
stream = sFile.startWrite();
} catch (IOException e) {
Slog.w(TAG, "Failed to write timestamp file: " + e);
return;
}
try {
XmlSerializer out = new FastXmlSerializer();
out.setOutput(stream, StandardCharsets.UTF_8.name());
out.startDocument(null, true);
out.startTag(null, "log-files");
Iterator<String> itor = timestamps.keySet().iterator();
while (itor.hasNext()) {
String filename = itor.next();
out.startTag(null, "log");
out.attribute(null, "filename", filename);
out.attribute(null, "timestamp", timestamps.get(filename).toString());
out.endTag(null, "log");
}
out.endTag(null, "log-files");
out.endDocument();
sFile.finishWrite(stream);
} catch (IOException e) {
Slog.w(TAG, "Failed to write timestamp file, using the backup: " + e);
sFile.failWrite(stream);
}
}
}
use of com.android.internal.util.FastXmlSerializer in project platform_frameworks_base by android.
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 com.android.internal.util.FastXmlSerializer in project platform_frameworks_base by android.
the class SyncStorageEngine method writeAccountInfoLocked.
/**
* Write all account information to the account file.
*/
private void writeAccountInfoLocked() {
if (Log.isLoggable(TAG_FILE, Log.VERBOSE)) {
Slog.v(TAG_FILE, "Writing new " + mAccountInfoFile.getBaseFile());
}
FileOutputStream fos = null;
try {
fos = mAccountInfoFile.startWrite();
XmlSerializer out = new FastXmlSerializer();
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, "accounts");
out.attribute(null, "version", Integer.toString(ACCOUNTS_VERSION));
out.attribute(null, XML_ATTR_NEXT_AUTHORITY_ID, Integer.toString(mNextAuthorityId));
out.attribute(null, XML_ATTR_SYNC_RANDOM_OFFSET, Integer.toString(mSyncRandomOffset));
// Write the Sync Automatically flags for each user
final int M = mMasterSyncAutomatically.size();
for (int m = 0; m < M; m++) {
int userId = mMasterSyncAutomatically.keyAt(m);
Boolean listen = mMasterSyncAutomatically.valueAt(m);
out.startTag(null, XML_TAG_LISTEN_FOR_TICKLES);
out.attribute(null, XML_ATTR_USER, Integer.toString(userId));
out.attribute(null, XML_ATTR_ENABLED, Boolean.toString(listen));
out.endTag(null, XML_TAG_LISTEN_FOR_TICKLES);
}
final int N = mAuthorities.size();
for (int i = 0; i < N; i++) {
AuthorityInfo authority = mAuthorities.valueAt(i);
EndPoint info = authority.target;
out.startTag(null, "authority");
out.attribute(null, "id", Integer.toString(authority.ident));
out.attribute(null, XML_ATTR_USER, Integer.toString(info.userId));
out.attribute(null, XML_ATTR_ENABLED, Boolean.toString(authority.enabled));
out.attribute(null, "account", info.account.name);
out.attribute(null, "type", info.account.type);
out.attribute(null, "authority", info.provider);
out.attribute(null, "syncable", Integer.toString(authority.syncable));
out.endTag(null, "authority");
}
out.endTag(null, "accounts");
out.endDocument();
mAccountInfoFile.finishWrite(fos);
} catch (java.io.IOException e1) {
Slog.w(TAG, "Error writing accounts", e1);
if (fos != null) {
mAccountInfoFile.failWrite(fos);
}
}
}
Aggregations