mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1201653 - Provide a way to self-select into a specific experiment [Switchboard]. r=margaret
This commit is contained in:
parent
d696057c62
commit
c725450dd2
@ -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);
|
||||
|
@ -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;
|
||||
@ -78,6 +77,8 @@ public class SwitchBoard {
|
||||
private static final String IS_EXPERIMENT_ACTIVE = "isActive";
|
||||
private static final String EXPERIMENT_VALUES = "values";
|
||||
|
||||
private static String uuidExtra = null;
|
||||
|
||||
|
||||
/**
|
||||
* Basic initialization with one server.
|
||||
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user