Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d68e9187 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

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
parent df2870df
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -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);