Bug 812809 - Replace 'static final' with 'static' for easier testing of Announcements. r=nalexander, a=akeybl
authorRichard Newman <rnewman@mozilla.com>
Mon, 19 Nov 2012 11:12:05 -0800
changeset 118327 15d4ae634345d531b0a73ef41249338629349904
parent 118326 d9e2cd41c6499f055a7d754f830c36dac6747a32
child 118328 2f801d18884d51008b7fcf72fa1f281004fd1ca0
push id2746
push userrnewman@mozilla.com
push dateWed, 21 Nov 2012 03:09:25 +0000
treeherdermozilla-aurora@15d4ae634345 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, akeybl
bugs812809
milestone19.0a2
Bug 812809 - Replace 'static final' with 'static' for easier testing of Announcements. r=nalexander, a=akeybl
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.