Backed out changeset a47d5f97fca8. r=bustage, CLOSED TREE

MozReview-Commit-ID: 6AoqIQWcOKd
This commit is contained in:
Chenxia Liu 2016-02-19 20:18:08 -08:00
Родитель 79ff021ecb
Коммит 0b2f76300a
3 изменённых файлов: 26 добавлений и 53 удалений

Просмотреть файл

@ -8,7 +8,8 @@ package org.mozilla.gecko.firstrun;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import org.mozilla.gecko.GeckoSharedPrefs;
import com.keepsafe.switchboard.SwitchBoard;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
@ -27,25 +28,22 @@ public class FirstrunPagerConfig {
public static List<FirstrunPanelConfig> getDefault(Context context) {
final List<FirstrunPanelConfig> panels = new LinkedList<>();
if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING2_A)) {
if (isInExperimentLocal(context, Experiments.ONBOARDING2_A)) {
panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING2_A);
GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING2_A).apply();
} else if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING2_B)) {
} else if (isInExperimentLocal(context, Experiments.ONBOARDING2_B)) {
panels.add(SimplePanelConfigs.urlbarPanelConfig);
panels.add(SimplePanelConfigs.bookmarksPanelConfig);
panels.add(SimplePanelConfigs.syncPanelConfig);
panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING2_B);
GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING2_B).apply();
} else if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING2_C)) {
} else if (isInExperimentLocal(context, Experiments.ONBOARDING2_C)) {
panels.add(SimplePanelConfigs.urlbarPanelConfig);
panels.add(SimplePanelConfigs.bookmarksPanelConfig);
panels.add(SimplePanelConfigs.dataPanelConfig);
panels.add(SimplePanelConfigs.syncPanelConfig);
panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING2_C);
GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING2_C).apply();
} else {
Log.d(LOGTAG, "Not in an experiment!");
panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
@ -54,6 +52,22 @@ public class FirstrunPagerConfig {
return panels;
}
/*
* 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 isInExperimentLocal(Context context, String name) {
if (AppConstants.MOZ_SWITCHBOARD) {
if (SwitchBoard.isInBucket(context, 0, 33)) {
return Experiments.ONBOARDING2_A.equals(name);
} else if (SwitchBoard.isInBucket(context, 33, 66)) {
return Experiments.ONBOARDING2_B.equals(name);
} else if (SwitchBoard.isInBucket(context, 66, 100)) {
return Experiments.ONBOARDING2_C.equals(name);
}
}
return false;
}
public static List<FirstrunPanelConfig> getRestricted() {
final List<FirstrunPanelConfig> panels = new LinkedList<>();

Просмотреть файл

@ -8,11 +8,12 @@ package org.mozilla.gecko.telemetry;
import android.content.Context;
import android.os.Build;
import com.keepsafe.switchboard.SwitchBoard;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.sync.ExtendedJSONObject;
import org.mozilla.gecko.telemetry.TelemetryConstants.CorePing;
import org.mozilla.gecko.util.Experiments;
import org.mozilla.gecko.util.StringUtils;
import java.io.IOException;
@ -86,7 +87,9 @@ public class TelemetryPingGenerator {
ping.put(CorePing.LOCALE, Locales.getLanguageTag(Locale.getDefault()));
ping.put(CorePing.OS_VERSION, Integer.toString(Build.VERSION.SDK_INT)); // A String for cross-platform reasons.
ping.put(CorePing.SEQ, seq);
ping.putArray(CorePing.EXPERIMENTS, Experiments.getActiveExperiments(context));
if (AppConstants.MOZ_SWITCHBOARD) {
ping.putArray(CorePing.EXPERIMENTS, SwitchBoard.getActiveExperiments(context));
}
// TODO (bug 1246816): Remove this "optional" parameter work-around when
// GeckoProfile.getAndPersistProfileCreationDateFromFilesystem is implemented. That method returns -1
// while it's not implemented so we don't include the parameter in the ping if that's the case.

Просмотреть файл

@ -4,16 +4,8 @@
package org.mozilla.gecko.util;
import android.content.Context;
import android.util.Log;
import org.mozilla.gecko.mozglue.ContextUtils.SafeIntent;
import android.text.TextUtils;
import com.keepsafe.switchboard.SwitchBoard;
import org.mozilla.gecko.GeckoSharedPrefs;
import java.util.LinkedList;
import java.util.List;
/**
* This class should reflect the experiment names found in the Switchboard experiments config here:
@ -30,8 +22,6 @@ public class Experiments {
public static final String ONBOARDING2_B = "onboarding2-b"; // 4 static Feature slides
public static final String ONBOARDING2_C = "onboarding2-c"; // 4 static + 1 clickable (Data saving) Feature slides
public static final String PREF_ONBOARDING_VERSION = "onboarding_version";
// Show search mode (instead of home panels) when tapping on urlbar if there is a search term in the urlbar.
public static final String SEARCH_TERM = "search-term";
@ -65,38 +55,4 @@ public class Experiments {
disabled = false;
return disabled;
}
/**
* Returns if a user is in certain local experiment.
* @param experiment Name of experiment to look up
* @return returns value for experiment or false if experiment does not exist.
*/
public static boolean isInExperimentLocal(Context context, String experiment) {
if (SwitchBoard.isInBucket(context, 0, 33)) {
return ONBOARDING2_A.equals(experiment);
} else if (SwitchBoard.isInBucket(context, 33, 66)) {
return ONBOARDING2_B.equals(experiment);
} else if (SwitchBoard.isInBucket(context, 66, 100)) {
return ONBOARDING2_C.equals(experiment);
} else {
return false;
}
}
/**
* Returns list of all active experiments, remote and local.
* @return List of experiment names Strings
*/
public static List<String> getActiveExperiments(Context c) {
final List<String> experiments = new LinkedList<>();
experiments.addAll(SwitchBoard.getActiveExperiments(c));
// Add onboarding version.
final String onboardingExperiment = GeckoSharedPrefs.forProfile(c).getString(PREF_ONBOARDING_VERSION, null);
if (!TextUtils.isEmpty(onboardingExperiment)) {
experiments.add(onboardingExperiment);
}
return experiments;
}
}