Bug 793053 - Part 4: pref off product announcements by short-circuiting both broadcast receivers. r=trivial
authorRichard Newman <rnewman@mozilla.com>
Fri, 26 Oct 2012 17:38:01 -0700
changeset 111723 1330fdc14cb0bd2add8fbbb8116cdbe354b9331f
parent 111722 717cd6ee20fc14c257ef8059889a9181ca1792a2
child 111724 647d6f4cd15d961dbf3d4aa4183704e7d470e6fd
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerstrivial
bugs793053
milestone19.0a1
Bug 793053 - Part 4: pref off product announcements by short-circuiting both broadcast receivers. r=trivial
mobile/android/base/background/announcements/AnnouncementsBroadcastReceiver.java
mobile/android/base/background/announcements/AnnouncementsConstants.java
mobile/android/base/background/announcements/AnnouncementsStartReceiver.java
--- a/mobile/android/base/background/announcements/AnnouncementsBroadcastReceiver.java
+++ b/mobile/android/base/background/announcements/AnnouncementsBroadcastReceiver.java
@@ -19,14 +19,18 @@ import android.content.Intent;
  */
 public class AnnouncementsBroadcastReceiver extends BroadcastReceiver {
 
   /**
    * Forward the intent to an IntentService to do background processing.
    */
   @Override
   public void onReceive(Context context, Intent intent) {
+    if (AnnouncementsConstants.DISABLED) {
+      return;
+    }
+
     Intent service = new Intent(context, AnnouncementsBroadcastService.class);
     service.putExtras(intent);
     service.setAction(intent.getAction());
     context.startService(service);
   }
-}
\ No newline at end of file
+}
--- a/mobile/android/base/background/announcements/AnnouncementsConstants.java
+++ b/mobile/android/base/background/announcements/AnnouncementsConstants.java
@@ -4,16 +4,19 @@
 
 package org.mozilla.gecko.background.announcements;
 
 import org.mozilla.gecko.sync.GlobalConstants;
 
 import android.app.AlarmManager;
 
 public class AnnouncementsConstants {
+  // Not `final` so we have the option to turn this on at runtime with a magic addon.
+  public static boolean DISABLED = true;
+
   public static final String GLOBAL_LOG_TAG = "GeckoAnnounce";
   public static final String ACTION_ANNOUNCEMENTS_PREF = "org.mozilla.gecko.ANNOUNCEMENTS_PREF";
 
   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";
--- a/mobile/android/base/background/announcements/AnnouncementsStartReceiver.java
+++ b/mobile/android/base/background/announcements/AnnouncementsStartReceiver.java
@@ -15,13 +15,17 @@ import android.content.Intent;
  * Start the announcements service when instructed by the {@link AlarmManager}.
  */
 public class AnnouncementsStartReceiver extends BroadcastReceiver {
 
   private static final String LOG_TAG = "AnnounceStartRec";
 
   @Override
   public void onReceive(Context context, Intent intent) {
+    if (AnnouncementsConstants.DISABLED) {
+      return;
+    }
+
     Logger.debug(LOG_TAG, "AnnouncementsStartReceiver.onReceive().");
     Intent service = new Intent(context, AnnouncementsService.class);
     context.startService(service);
   }
 }