OMS: Remove old overlays.xml versions

In order to allow the default theme to take effect, older
versions of overlays.xml need to be purged.

Bug: 35757608
Test: manual
Change-Id: Ib8719567455038e8d61bf75968a1842edc34edee
This commit is contained in:
Adam Lesinski
2017-03-06 12:52:58 -08:00
parent df2870df9a
commit d68e9187cc

View File

@@ -360,7 +360,7 @@ final class OverlayManagerSettings {
private static final String ATTR_USER_ID = "userId";
private static final String ATTR_VERSION = "version";
private static final int CURRENT_VERSION = 1;
private static final int CURRENT_VERSION = 2;
public static void restore(@NonNull final ArrayList<SettingsItem> table,
@NonNull final InputStream is) throws IOException, XmlPullParserException {
@@ -372,7 +372,7 @@ final class OverlayManagerSettings {
XmlUtils.beginDocument(parser, TAG_OVERLAYS);
int version = XmlUtils.readIntAttribute(parser, ATTR_VERSION);
if (version != CURRENT_VERSION) {
throw new XmlPullParserException("unrecognized version " + version);
upgrade(version);
}
int depth = parser.getDepth();
@@ -387,6 +387,18 @@ final class OverlayManagerSettings {
}
}
private static void upgrade(int oldVersion) throws XmlPullParserException {
switch (oldVersion) {
case 0:
case 1:
// Throw an exception which will cause the overlay file to be ignored
// and overwritten.
throw new XmlPullParserException("old version " + oldVersion + "; ignoring");
default:
throw new XmlPullParserException("unrecognized version " + oldVersion);
}
}
private static SettingsItem restoreRow(@NonNull final XmlPullParser parser, final int depth)
throws IOException {
final String packageName = XmlUtils.readStringAttribute(parser, ATTR_PACKAGE_NAME);