Bug 1250250 - Store updated seq no. before sending upload Intent. r=mfinkle draft
authorMichael Comella <michael.l.comella@gmail.com>
Mon, 22 Feb 2016 11:20:37 -0800
changeset 333151 5eb5af82aab86e8836020228f87d908946890d1e
parent 332009 6008843fb7ba5de8a2c7e39bf6e2e4a2e7f1532b
child 514647 4c6fe13322f56f05fc24cf61118bf6954126aec8
push id11273
push usermichael.l.comella@gmail.com
push dateMon, 22 Feb 2016 19:20:45 +0000
reviewersmfinkle
bugs1250250
milestone47.0a1
Bug 1250250 - Store updated seq no. before sending upload Intent. r=mfinkle MozReview-Commit-ID: Ab2qycjDKOy
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -3973,27 +3973,26 @@ public class BrowserApp extends GeckoApp
 
     private void uploadTelemetry(final GeckoProfile profile) {
         if (!TelemetryUploadService.isUploadEnabledByProfileConfig(this, profile)) {
             return;
         }
 
         final SharedPreferences sharedPrefs = GeckoSharedPrefs.forProfileName(this, profile.getName());
         final int seq = sharedPrefs.getInt(TelemetryConstants.PREF_SEQ_COUNT, 1);
+        // We store synchronously before sending the Intent to ensure this sequence number will not be re-used.
+        sharedPrefs.edit().putInt(TelemetryConstants.PREF_SEQ_COUNT, seq + 1).commit();
 
         final Intent i = new Intent(TelemetryConstants.ACTION_UPLOAD_CORE);
         i.setClass(this, TelemetryUploadService.class);
         i.putExtra(TelemetryConstants.EXTRA_DOC_ID, UUID.randomUUID().toString());
         i.putExtra(TelemetryConstants.EXTRA_PROFILE_NAME, profile.getName());
         i.putExtra(TelemetryConstants.EXTRA_PROFILE_PATH, profile.getDir().toString());
         i.putExtra(TelemetryConstants.EXTRA_SEQ, seq);
         startService(i);
-
-        // Intent redelivery will ensure this value gets used - see TelemetryUploadService class comments for details.
-        sharedPrefs.edit().putInt(TelemetryConstants.PREF_SEQ_COUNT, seq + 1).apply();
     }
 
     public static interface TabStripInterface {
         public void refresh();
         void setOnTabChangedListener(OnTabAddedOrRemovedListener listener);
         interface OnTabAddedOrRemovedListener {
             void onTabChanged();
         }