SharedPreferences$Editor.startCommit()
Adds a fire-and-forget save method (startCommit) to the
SharedPreferences.Editor, which is the way most people use it anyway.
This commit adds the implementation. The previous commit added the
interface and docs:
previous change: Idf9934b445da1fb72b79f0192218b47c0a7f5a34
git commit: edf32d0131
In addition, this change:
-- adds a generic "runPendingWorkFinishers" mechanism to
ActivityThread to wait on async operations that are still
in flight and use it for this.
-- ties runPendingWorkFinishers into Activity.onPause,
BroadcastReceiver, and Service.
-- makes sSharedPreferences keyed on name, not File, to avoid
unnnecessary allocations
-- documents and guarantees what thread
OnSharedPreferenceChangeListener callbacks run on
-- makes a few things in frameworks/base use startCommit(), notably
Preference.java (which was ignoring the return value anyway)
Change-Id: I1c8db60ad45643226fe6d246d3e513eeb7bd0ebd
This commit is contained in:
@@ -165,7 +165,9 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
if (prefs != null) {
|
||||
long lastTime = prefs.getLong(filename, 0);
|
||||
if (lastTime == fileTime) return; // Already logged this particular file
|
||||
prefs.edit().putLong(filename, fileTime).commit();
|
||||
// TODO: move all these SharedPreferences Editor commits
|
||||
// outside this function to the end of logBootEvents
|
||||
prefs.edit().putLong(filename, fileTime).startCommit();
|
||||
}
|
||||
|
||||
Slog.i(TAG, "Copying " + filename + " to DropBox (" + tag + ")");
|
||||
|
||||
Reference in New Issue
Block a user