Bug 1277071 - Move PREF_SEQ_COUNT to CorePingBuilder. r=jonalmeida
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 31 May 2016 16:33:08 -0700
changeset 338674 933c4c92752c3a9f51421d75ec9946642cc49dc2
parent 338673 4b66897490ab2ab196c44ad9485dd529fe96441c
child 338675 6833ddd73063182bc4569b73cb56787dc1a5863e
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonalmeida
bugs1277071
milestone49.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 1277071 - Move PREF_SEQ_COUNT to CorePingBuilder. r=jonalmeida MozReview-Commit-ID: 44R0ahE094N
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryConstants.java
mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCorePingBuilder.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryConstants.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryConstants.java
@@ -11,10 +11,9 @@ public class TelemetryConstants {
     // Change these two values to enable upload in developer builds.
     public static final boolean UPLOAD_ENABLED = AppConstants.MOZILLA_OFFICIAL; // Disabled for developer builds.
     public static final String DEFAULT_SERVER_URL = "https://incoming.telemetry.mozilla.org";
 
     public static final String USER_AGENT =
             "Firefox-Android-Telemetry/" + AppConstants.MOZ_APP_VERSION + " (" + AppConstants.MOZ_APP_UA_NAME + ")";
 
     public static final String PREF_SERVER_URL = "telemetry-serverUrl";
-    public static final String PREF_SEQ_COUNT = "telemetry-seqCount";
 }
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCorePingBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCorePingBuilder.java
@@ -15,17 +15,16 @@ import android.support.annotation.Worker
 import android.text.TextUtils;
 
 import android.util.Log;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.Locales;
 import org.mozilla.gecko.search.SearchEngine;
 import org.mozilla.gecko.sync.ExtendedJSONObject;
-import org.mozilla.gecko.telemetry.TelemetryConstants;
 import org.mozilla.gecko.telemetry.TelemetryPing;
 import org.mozilla.gecko.util.DateUtil;
 import org.mozilla.gecko.util.Experiments;
 import org.mozilla.gecko.util.StringUtils;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -36,16 +35,19 @@ import java.util.concurrent.TimeUnit;
  * Builds a {@link TelemetryPing} representing a core ping.
  *
  * See https://gecko.readthedocs.org/en/latest/toolkit/components/telemetry/telemetry/core-ping.html
  * for details on the core ping.
  */
 public class TelemetryCorePingBuilder extends TelemetryPingBuilder {
     private static final String LOGTAG = StringUtils.safeSubstring(TelemetryCorePingBuilder.class.getSimpleName(), 0, 23);
 
+    // For legacy reasons, this preference key is not namespaced with "core".
+    private static final String PREF_SEQ_COUNT = "telemetry-seqCount";
+
     private static final String NAME = "core";
     private static final int VERSION_VALUE = 7; // For version history, see toolkit/components/telemetry/docs/core-ping.rst
     private static final String OS_VALUE = "Android";
 
     private static final String ARCHITECTURE = "arch";
     private static final String CLIENT_ID = "clientId";
     private static final String DEFAULT_SEARCH_ENGINE = "defaultSearch";
     private static final String DEVICE = "device";
@@ -198,19 +200,19 @@ public class TelemetryCorePingBuilder ex
     }
 
     /**
      * Gets the sequence number from shared preferences and increments it in the prefs. This method
      * is not thread safe.
      */
     @WorkerThread // synchronous shared prefs write.
     public static int getAndIncrementSequenceNumber(final SharedPreferences sharedPrefsForProfile) {
-        final int seq = sharedPrefsForProfile.getInt(TelemetryConstants.PREF_SEQ_COUNT, 1);
+        final int seq = sharedPrefsForProfile.getInt(PREF_SEQ_COUNT, 1);
 
-        sharedPrefsForProfile.edit().putInt(TelemetryConstants.PREF_SEQ_COUNT, seq + 1).apply();
+        sharedPrefsForProfile.edit().putInt(PREF_SEQ_COUNT, seq + 1).apply();
         return seq;
     }
 
     /**
      * @return the profile creation date in the format expected by
      *         {@link TelemetryCorePingBuilder#setProfileCreationDate(Long)}.
      */
     @WorkerThread