diff options
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 2 | ||||
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java | 92 |
2 files changed, 32 insertions, 62 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index a6f2875..126b4aa 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -1806,7 +1806,7 @@ public class SettingsProvider extends ContentProvider { final int oldVersion = secureSettings.getVersionLocked(); final int newVersion = SETTINGS_VERSION; - // If up do data - done. + // If up do date - done. if (oldVersion == newVersion) { return; } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java index 3bf6828..c7092b3 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java @@ -416,78 +416,48 @@ final class SettingsState { private void parseStateLocked(XmlPullParser parser) throws IOException, XmlPullParserException { - parser.next(); - skipEmptyTextTags(parser); - expect(parser, XmlPullParser.START_TAG, TAG_SETTINGS); - - mVersion = Integer.parseInt(parser.getAttributeValue(null, ATTR_VERSION)); - - parser.next(); + final int outerDepth = parser.getDepth(); + int type; + while ((type = parser.next()) != XmlPullParser.END_DOCUMENT + && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { + if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { + continue; + } - while (parseSettingLocked(parser)) { - parser.next(); + String tagName = parser.getName(); + if (tagName.equals(TAG_SETTINGS)) { + parseSettingsLocked(parser); + } } - - skipEmptyTextTags(parser); - expect(parser, XmlPullParser.END_TAG, TAG_SETTINGS); } - private boolean parseSettingLocked(XmlPullParser parser) + private void parseSettingsLocked(XmlPullParser parser) throws IOException, XmlPullParserException { - skipEmptyTextTags(parser); - if (!accept(parser, XmlPullParser.START_TAG, TAG_SETTING)) { - return false; - } - String id = parser.getAttributeValue(null, ATTR_ID); - String name = parser.getAttributeValue(null, ATTR_NAME); - String value = parser.getAttributeValue(null, ATTR_VALUE); - String packageName = parser.getAttributeValue(null, ATTR_PACKAGE); - mSettings.put(name, new Setting(name, unpackValue(value), - unpackValue(packageName), id)); - - if (DEBUG_PERSISTENCE) { - Slog.i(LOG_TAG, "[RESTORED] " + name + "=" + value); - } - - parser.next(); - - skipEmptyTextTags(parser); - expect(parser, XmlPullParser.END_TAG, TAG_SETTING); - - return true; - } + mVersion = Integer.parseInt(parser.getAttributeValue(null, ATTR_VERSION)); - private void expect(XmlPullParser parser, int type, String tag) - throws IOException, XmlPullParserException { - if (!accept(parser, type, tag)) { - throw new XmlPullParserException("Expected event: " + type - + " and tag: " + tag + " but got event: " + parser.getEventType() - + " and tag:" + parser.getName()); - } - } + final int outerDepth = parser.getDepth(); + int type; + while ((type = parser.next()) != XmlPullParser.END_DOCUMENT + && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { + if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { + continue; + } - private void skipEmptyTextTags(XmlPullParser parser) - throws IOException, XmlPullParserException { - while (accept(parser, XmlPullParser.TEXT, null) - && parser.isWhitespace()) { - parser.next(); - } - } + String tagName = parser.getName(); + if (tagName.equals(TAG_SETTING)) { + String id = parser.getAttributeValue(null, ATTR_ID); + String name = parser.getAttributeValue(null, ATTR_NAME); + String value = parser.getAttributeValue(null, ATTR_VALUE); + String packageName = parser.getAttributeValue(null, ATTR_PACKAGE); + mSettings.put(name, new Setting(name, unpackValue(value), + unpackValue(packageName), id)); - private boolean accept(XmlPullParser parser, int type, String tag) - throws IOException, XmlPullParserException { - if (parser.getEventType() != type) { - return false; - } - if (tag != null) { - if (!tag.equals(parser.getName())) { - return false; + if (DEBUG_PERSISTENCE) { + Slog.i(LOG_TAG, "[RESTORED] " + name + "=" + value); + } } - } else if (parser.getName() != null) { - return false; } - return true; } private final class MyHandler extends Handler { |