зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1198009 - Add SwitchBoard.getActiveExperiments r=rnewman
This commit is contained in:
Родитель
a6e9d38aff
Коммит
02bbd52b12
|
@ -22,6 +22,9 @@ import java.io.InputStreamReader;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.UUID;
|
||||
|
@ -288,6 +291,37 @@ public class SwitchBoard {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns a list of all active experiments.
|
||||
*/
|
||||
public static List<String> getActiveExperiments(Context c) {
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
// lookup experiment in config
|
||||
String config = Preferences.getDynamicConfigJson(c);
|
||||
|
||||
// if it does not exist
|
||||
if (config == null) {
|
||||
return returnList;
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject experiments = new JSONObject(config);
|
||||
Iterator<?> iter = experiments.keys();
|
||||
while (iter.hasNext()) {
|
||||
String key = (String)iter.next();
|
||||
JSONObject experiment = experiments.getJSONObject(key);
|
||||
if (experiment.getBoolean(IS_EXPERIMENT_ACTIVE)) {
|
||||
returnList.add(key);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
// Something went wrong!
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a certain experiment exists.
|
||||
* @param c ApplicationContext
|
||||
|
|
Загрузка…
Ссылка в новой задаче