Bug 812809 - Replace 'static final' with 'static' for easier testing of Announcements. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Mon, 19 Nov 2012 11:12:05 -0800
changeset 113695 a3ffc2519ccec534c4fba5a5dd117a4f9a7d9a44
parent 113694 b866a124dd4ee7b097e293399c1803ddbf60c741
child 113696 ed2bd8fe4193ba4336a283cbd47cc1c15a21b1b8
push id23887
push userphilringnalda@gmail.com
push dateTue, 20 Nov 2012 06:15:56 +0000
treeherdermozilla-central@bc69705c162d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs812809
milestone19.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 812809 - Replace 'static final' with 'static' for easier testing of Announcements. r=nalexander
mobile/android/base/background/announcements/AnnouncementsConstants.java.in
mobile/android/base/background/announcements/AnnouncementsService.java
--- a/mobile/android/base/background/announcements/AnnouncementsConstants.java.in
+++ b/mobile/android/base/background/announcements/AnnouncementsConstants.java.in
@@ -18,20 +18,22 @@ public class AnnouncementsConstants {
 
   static final String PREFS_BRANCH = "background";
   static final String PREF_LAST_FETCH  = "last_fetch";
   static final String PREF_LAST_LAUNCH = "last_firefox_launch";
   static final String PREF_ANNOUNCE_SERVER_BASE_URL  = "announce_server_base_url";
   static final String PREF_EARLIEST_NEXT_ANNOUNCE_FETCH = "earliest_next_announce_fetch";
   static final String PREF_ANNOUNCE_FETCH_INTERVAL_MSEC = "announce_fetch_interval_msec";
 
-  static final String DEFAULT_ANNOUNCE_SERVER_BASE_URL = "https://campaigns.services.mozilla.com/announce/";
+  public static String DEFAULT_ANNOUNCE_SERVER_BASE_URL = "https://campaigns.services.mozilla.com/announce/";
+
   public static final String ANNOUNCE_PROTOCOL_VERSION = "1";
   public static final String ANNOUNCE_APPLICATION = "android";
-  public static final String ANNOUNCE_PATH_SUFFIX = AnnouncementsConstants.ANNOUNCE_PROTOCOL_VERSION + "/" +
-                                                    AnnouncementsConstants.ANNOUNCE_APPLICATION + "/";
+  public static String ANNOUNCE_PATH_SUFFIX = AnnouncementsConstants.ANNOUNCE_PROTOCOL_VERSION + "/" +
+                                              AnnouncementsConstants.ANNOUNCE_APPLICATION + "/";
 
-  public static final long DEFAULT_ANNOUNCE_FETCH_INTERVAL_MSEC = AlarmManager.INTERVAL_HALF_DAY;
-  public static final long DEFAULT_BACKOFF_MSEC = 2 * 24 * 60 * 60 * 1000;   // Two days. Used if no Retry-After header.
+  public static long DEFAULT_ANNOUNCE_FETCH_INTERVAL_MSEC = AlarmManager.INTERVAL_HALF_DAY;
+  public static long DEFAULT_BACKOFF_MSEC = 2 * 24 * 60 * 60 * 1000;   // Two days. Used if no Retry-After header.
+  public static long MINIMUM_FETCH_INTERVAL_MSEC = 60 * 60 * 1000;     // 1 hour.
 
-  public static final String ANNOUNCE_USER_AGENT = "Firefox Announcements " + GlobalConstants.MOZ_APP_VERSION;
-  public static final String ANNOUNCE_CHANNEL = GlobalConstants.MOZ_UPDATE_CHANNEL.replace("default", GlobalConstants.MOZ_OFFICIAL_BRANDING ? "release" : "dev");
+  public static String ANNOUNCE_USER_AGENT = "Firefox Announcements " + GlobalConstants.MOZ_APP_VERSION;
+  public static String ANNOUNCE_CHANNEL = GlobalConstants.MOZ_UPDATE_CHANNEL.replace("default", GlobalConstants.MOZ_OFFICIAL_BRANDING ? "release" : "dev");
 }
--- a/mobile/android/base/background/announcements/AnnouncementsService.java
+++ b/mobile/android/base/background/announcements/AnnouncementsService.java
@@ -51,18 +51,16 @@ import android.os.IBinder;
  * Future:
  * * Persisting of multiple announcements.
  * * Prioritization.
  */
 public class AnnouncementsService extends IntentService implements AnnouncementsFetchDelegate {
   private static final String WORKER_THREAD_NAME = "AnnouncementsServiceWorker";
   private static final String LOG_TAG = "AnnounceService";
 
-  private static final long MINIMUM_FETCH_INTERVAL_MSEC = 60 * 60 * 1000;   // 1 hour.
-
   public AnnouncementsService() {
     super(WORKER_THREAD_NAME);
     Logger.setThreadLogTag(AnnouncementsConstants.GLOBAL_LOG_TAG);
     Logger.debug(LOG_TAG, "Creating AnnouncementsService.");
   }
 
   public boolean shouldFetchAnnouncements() {
     final long now = System.currentTimeMillis();
@@ -77,18 +75,18 @@ public class AnnouncementsService extend
       return false;
     }
 
     // Don't do anything if we haven't waited long enough.
     final long lastFetch = getLastFetch();
 
     // Just in case the alarm manager schedules us more frequently, or something
     // goes awry with relaunches.
-    if ((now - lastFetch) < MINIMUM_FETCH_INTERVAL_MSEC) {
-      Logger.debug(LOG_TAG, "Returning: minimum fetch interval of " + MINIMUM_FETCH_INTERVAL_MSEC + "ms not met.");
+    if ((now - lastFetch) < AnnouncementsConstants.MINIMUM_FETCH_INTERVAL_MSEC) {
+      Logger.debug(LOG_TAG, "Returning: minimum fetch interval of " + AnnouncementsConstants.MINIMUM_FETCH_INTERVAL_MSEC + "ms not met.");
       return false;
     }
 
     return true;
   }
 
   /**
    * Display the first valid announcement in the list.