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

Commit d2bbaaf2 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick
Browse files

[don't auto-merge] Don't re-read SharedPreferences unnecessarily.

Bug: 3211034
Bug: 3216290
Change-Id: Idd5cc25965d400f20122372ca1cf47d4703dd87c
parent 688f4c58
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -367,7 +367,8 @@ class ContextImpl extends Context {
            }

            Map map = null;
            if (prefsFile.exists() && prefsFile.canRead()) {
            FileStatus stat = new FileStatus();
            if (FileUtils.getFileStatus(prefsFile.getPath(), stat) && prefsFile.canRead()) {
                try {
                    FileInputStream str = new FileInputStream(prefsFile);
                    map = XmlUtils.readMapXml(str);
@@ -380,7 +381,7 @@ class ContextImpl extends Context {
                    Log.w(TAG, "getSharedPreferences", e);
                }
            }
            sp.replace(map);
            sp.replace(map, stat);
        }
        return sp;
    }
@@ -2768,12 +2769,16 @@ class ContextImpl extends Context {
            }
        }

        public void replace(Map newContents) {
        /* package */ void replace(Map newContents, FileStatus stat) {
            synchronized (this) {
                mLoaded = true;
                if (newContents != null) {
                    mMap = newContents;
                }
                if (stat != null) {
                    mStatTimestamp = stat.mtime;
                    mStatSize = stat.size;
                }
            }
        }