Bug 1277071 - Move PREF_SEQ_COUNT to CorePingBuilder. r=jonalmeida draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 31 May 2016 16:33:08 -0700
changeset 373632 a7283f8da674ea315f9fa0ac0dd59dead66f3e80
parent 373498 7f6135916882e9dff30c5549e278f49f2fca2c17
child 522433 b4664c268db2ab2497a5f66ac5212fedf8f917d3
push id19796
push usermichael.l.comella@gmail.com
push dateTue, 31 May 2016 23:36:07 +0000
reviewersjonalmeida
bugs1277071
milestone49.0a1
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