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

Commit 9455659b authored by Songchun Fan's avatar Songchun Fan Committed by Song Chun Fan
Browse files

[SettingsProvider] do not crash the system if config settings files are broken

Tolerate config flags' serialization/deserialization failures because they can be sync'd after boot.

BUG: 295555884
Test: manually push a broken config file onto device and reboot
Merged-In: I9851991b4a225f2941708d37d2ad9507d7c432f8
Change-Id: I9851991b4a225f2941708d37d2ad9507d7c432f8
(cherry picked from commit 2ba72c06)
parent fcc8bbe3
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1090,8 +1090,11 @@ final class SettingsState {
        } catch (FileNotFoundException fnfe) {
            final String message = "No fallback file found for: " + mStatePersistFile;
            Slog.wtf(LOG_TAG, message);
            if (!isConfigSettingsKey(mKey)) {
                // Allow partially deserialized config settings because they can be updated later
                throw new IllegalStateException(message);
            }
        }
        if (parseStateFromXmlStreamLocked(in)) {
            // Parsed state from fallback file. Restore original file with fallback file
            try {
@@ -1102,9 +1105,12 @@ final class SettingsState {
        } else {
            final String message = "Failed parsing settings file: " + mStatePersistFile;
            Slog.wtf(LOG_TAG, message);
            if (!isConfigSettingsKey(mKey)) {
                // Allow partially deserialized config settings because they can be updated later
                throw new IllegalStateException(message);
            }
        }
    }

    @GuardedBy("mLock")
    private boolean parseStateFromXmlStreamLocked(FileInputStream in) {