Merge changes from topic 'backportSharedpreferencesSpeedUp' into nyc-mr2-dev

* changes:
  Do not write if apply() did not change the file.
  Only persist last Shared Preferences state