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

Commit d68bad1c authored by Danny Baumann's avatar Danny Baumann Committed by Steve Kondik
Browse files

Factor out preference-in-storage check to overridable method.

Change-Id: I2fff3192802f8a180330fda66388eda394334a5a
parent b8f3ad87
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1377,10 +1377,18 @@ public class Preference implements Comparable<Preference> {
        mDefaultValue = defaultValue;
    }
    
    /**
     * Returns whether the preference can be found in persistent storage
     * @hide
     */
    protected boolean isPersisted() {
        return getSharedPreferences().contains(mKey);
    }

    private void dispatchSetInitialValue() {
        // By now, we know if we are persistent.
        final boolean shouldPersist = shouldPersist();
        if (!shouldPersist || !getSharedPreferences().contains(mKey)) {
        if (!shouldPersist || !isPersisted()) {
            if (mDefaultValue != null) {
                onSetInitialValue(false, mDefaultValue);
            }