diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java index 87364e97af4..3012c1b4b20 100644 --- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java @@ -6,7 +6,6 @@ package org.mozilla.gecko; import android.Manifest; -import android.os.AsyncTask; import android.support.annotation.NonNull; import org.json.JSONArray; import org.mozilla.gecko.adjust.AdjustHelperInterface; @@ -180,6 +179,7 @@ public class BrowserApp extends GeckoApp private static final String ADD_SHORTCUT_TOAST = "add_shortcut_toast"; public static final String GUEST_BROWSING_ARG = "--guest"; + public static final String INTENT_KEY_SWITCHBOARD_UUID = "switchboard-uuid"; private static final String STATE_ABOUT_HOME_TOP_PADDING = "abouthome_top_padding"; @@ -589,12 +589,15 @@ public class BrowserApp extends GeckoApp // Initializes the default URLs the first time. SwitchBoard.initDefaultServerUrls("https://switchboard.services.mozilla.com/urls", "https://switchboard.services.mozilla.com/v1", true); + final String switchboardUUID = ContextUtils.getStringExtra(intent, INTENT_KEY_SWITCHBOARD_UUID); + SwitchBoard.setUUIDFromExtra(switchboardUUID); + // Looks at the server if there are changes in the server URL that should be used in the future - new AsyncConfigLoader(this, AsyncConfigLoader.UPDATE_SERVER).execute(); + new AsyncConfigLoader(this, AsyncConfigLoader.UPDATE_SERVER, switchboardUUID).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. - new AsyncConfigLoader(this, AsyncConfigLoader.CONFIG_SERVER).execute(); + new AsyncConfigLoader(this, AsyncConfigLoader.CONFIG_SERVER, switchboardUUID).execute(); } mBrowserChrome = (ViewGroup) findViewById(R.id.browser_chrome); diff --git a/mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java b/mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java index 94cacb48b38..c8dfba865b6 100644 --- a/mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java +++ b/mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java @@ -27,7 +27,6 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.MissingResourceException; -import java.util.UUID; import java.util.zip.CRC32; import org.json.JSONException; @@ -77,6 +76,8 @@ public class SwitchBoard { private static final String IS_EXPERIMENT_ACTIVE = "isActive"; private static final String EXPERIMENT_VALUES = "values"; + + private static String uuidExtra = null; /** @@ -93,6 +94,9 @@ public class SwitchBoard { DEBUG = isDebug; } + public static void setUUIDFromExtra(String uuid) { + uuidExtra = uuid; + } /** * Advanced initialization that supports a production and staging environment without changing the server URLs manually. * SwitchBoard will connect to the staging environment in debug mode. This makes it very simple to test new experiements @@ -435,8 +439,11 @@ public class SwitchBoard { */ private static int getUserBucket(Context c) { //get uuid - DeviceUuidFactory df = new DeviceUuidFactory(c); - String uuid = df.getDeviceUuid().toString(); + String uuid = uuidExtra; + if (uuid == null) { + DeviceUuidFactory df = new DeviceUuidFactory(c); + uuid = df.getDeviceUuid().toString(); + } CRC32 crc = new CRC32(); crc.update(uuid.getBytes());