Bug 1199859 - Use local switchboard. r=mfinkle
authorChenxia Liu <liuche@mozilla.com>
Wed, 16 Sep 2015 09:43:38 -0700
changeset 295955 4eabe281eb8810f8e27ea986d7322d1918409995
parent 295954 8349bbfd8910c0c2143d635381988675314db074
child 295956 ab8c0ada6aa1bd1e9aea86b304a459f3279d7022
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1199859
milestone43.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 1199859 - Use local switchboard. r=mfinkle
mobile/android/base/BrowserApp.java
mobile/android/base/firstrun/FirstrunPagerConfig.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -736,27 +736,22 @@ public class BrowserApp extends GeckoApp
 
         if (AppConstants.MOZ_SWITCHBOARD) {
             // Initializes the default URLs the first time.
             Log.d(LOGTAG, "init Server Urls");
             SwitchBoard.initDefaultServerUrls("https://mozilla-switchboard.herokuapp.com/SwitchboardURLs.php", "https://mozilla-switchboard.herokuapp.com/SwitchboardDriver.php", true);
 
             // Looks at the server if there are changes in the server URL that should be used in the future
             Log.d(LOGTAG, "update server urls from remote");
-            SwitchBoard.updateConfigServerUrl(this);
             new AsyncConfigLoader(this, AsyncConfigLoader.UPDATE_SERVER).execute();
 
             // Loads the actual config. This can be done on app start or on app onResume() depending
             // how often you want to update the config.
             Log.d(LOGTAG, "update app config");
-            // TODO: Make this NON-SYNCHRONOUS
-            SwitchBoard.loadConfig(this);
-            final AsyncConfigLoader loader = new AsyncConfigLoader(this, AsyncConfigLoader.CONFIG_SERVER);
-            loader.execute();
-
+            new AsyncConfigLoader(this, AsyncConfigLoader.CONFIG_SERVER).execute();
         }
 
         mBrowserChrome = (ViewGroup) findViewById(R.id.browser_chrome);
         mActionBarFlipper = (ViewFlipper) findViewById(R.id.browser_actionbar);
         mActionBar = (ActionModeCompatView) findViewById(R.id.actionbar);
 
         mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
         mProgressView = (ToolbarProgressView) findViewById(R.id.progress);
--- a/mobile/android/base/firstrun/FirstrunPagerConfig.java
+++ b/mobile/android/base/firstrun/FirstrunPagerConfig.java
@@ -15,39 +15,40 @@ import java.util.List;
 
 public class FirstrunPagerConfig {
     public static final String LOGTAG = "FirstrunPagerConfig";
     private static final String ONBOARDING_A = "onboarding-a";
     private static final String ONBOARDING_B = "onboarding-b";
 
     public static List<FirstrunPanelConfig> getDefault(Context context) {
         final List<FirstrunPanelConfig> panels = new LinkedList<>();
-        if (isBucket(ONBOARDING_A, context)) {
+        if (isInExperimentLocal(context, ONBOARDING_A)) {
             panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
-        } else if (isBucket(ONBOARDING_B, context)) {
+        } else if (isInExperimentLocal(context, ONBOARDING_B)) {
             // Strings used for first run, pulled from existing strings.
             panels.add(new FirstrunPanelConfig(ImportPanel.class.getName(), ImportPanel.TITLE_RES));
             panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
         } else {
             Log.d(LOGTAG, "Not in an experiment!");
             panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
         }
 
         return panels;
     }
 
     /*
-     * Wrapper method for determining what Firstrun version to use.
+     * Wrapper method for using local bucketing rather than server-side.
+     * This needs to match the server-side bucketing used on mozilla-switchboard.herokuapp.com.
      */
-    private static boolean isBucket(String name, Context context) {
+    private static boolean isInExperimentLocal(Context context, String name) {
         if (AppConstants.MOZ_SWITCHBOARD) {
-            if (ONBOARDING_A.equals(name)) {
-                return SwitchBoard.isInExperiment(context, name);
-            } else if (ONBOARDING_B.equals(name)) {
-                return SwitchBoard.isInExperiment(context, name);
+            if (SwitchBoard.isInBucket(context, 0, 50)) {
+                return ONBOARDING_A.equals(name);
+            } else if (SwitchBoard.isInBucket(context, 50, 100)) {
+                return ONBOARDING_B.equals(name);
             }
         }
         return false;
     }
 
     public static List<FirstrunPanelConfig> getRestricted() {
         final List<FirstrunPanelConfig> panels = new LinkedList<>();
         panels.add(new FirstrunPanelConfig(RestrictedWelcomePanel.class.getName(), RestrictedWelcomePanel.TITLE_RES));