Merge "OMS: Remove old overlays.xml versions"

This commit is contained in:
TreeHugger Robot
2017-03-07 00:06:27 +00:00
committed by Android (Google) Code Review

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);