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

Commit 2ba72c06 authored by Songchun Fan's avatar Songchun Fan
Browse files

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

Short term fix to tolerate config flags' serialization/deserialization
failures.

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


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