Bug 1061430 - Change SharedPreferences.Editor commit() to apply() where appropriate (DataReportingNotification.java) r=rnewman
authorMark Finkle <mfinkle@mozilla.com>
Wed, 03 Sep 2014 02:00:44 -0400
changeset 203231 886529efa472a06a663a9fbf025cd8fed29e6511
parent 203230 14f25bd4fc2b633cc38bf10a7d2e2ed482d377b1
child 203232 d73c600ddf5541e5e92bdadf97fa5daf8167738b
push id27424
push userryanvm@gmail.com
push dateWed, 03 Sep 2014 19:35:53 +0000
treeherdermozilla-central@bfef88becbba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1061430
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1061430 - Change SharedPreferences.Editor commit() to apply() where appropriate (DataReportingNotification.java) r=rnewman
mobile/android/base/DataReportingNotification.java
--- a/mobile/android/base/DataReportingNotification.java
+++ b/mobile/android/base/DataReportingNotification.java
@@ -39,30 +39,30 @@ public class DataReportingNotification {
         if (currentVersion < 1) {
             // This is a first run, so notify user about data policy.
             notifyDataPolicy(context, dataPrefs);
 
             // If healthreport is enabled, set default preference value.
             if (AppConstants.MOZ_SERVICES_HEALTHREPORT) {
                 SharedPreferences.Editor editor = dataPrefs.edit();
                 editor.putBoolean(GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true);
-                editor.commit();
+                editor.apply();
             }
             return;
         }
 
         if (currentVersion == 1) {
             // Redisplay notification only for Beta because version 2 updates Beta policy and update version.
             if (TextUtils.equals("beta", AppConstants.MOZ_UPDATE_CHANNEL)) {
                 notifyDataPolicy(context, dataPrefs);
             } else {
                 // Silently update the version.
                 SharedPreferences.Editor editor = dataPrefs.edit();
                 editor.putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION);
-                editor.commit();
+                editor.apply();
             }
             return;
         }
 
         if (currentVersion >= DATA_REPORTING_VERSION) {
             // Do nothing, we're at a current (or future) version.
             return;
         }
@@ -118,16 +118,16 @@ public class DataReportingNotification {
             int notificationID = ALERT_NAME_DATAREPORTING_NOTIFICATION.hashCode();
             notificationManager.notify(notificationID, notification);
 
             // Record version and notification time.
             SharedPreferences.Editor editor = sharedPrefs.edit();
             long now = System.currentTimeMillis();
             editor.putLong(PREFS_POLICY_NOTIFIED_TIME, now);
             editor.putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION);
-            editor.commit();
+            editor.apply();
             result = true;
         } finally {
             // We want to track any errors, so record notification outcome.
             Telemetry.sendUIEvent(TelemetryContract.Event.POLICY_NOTIFICATION_SUCCESS, result);
         }
     }
 }