Killed the feature flipper, not needed anymore

pull/14/head
Sam Bosley 12 years ago
parent bdec8356ca
commit 0b750e909e

@ -29,7 +29,6 @@ import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.ABTestEventReportingService;
import com.todoroo.astrid.service.abtesting.ABTestInvoker;
import com.todoroo.astrid.service.abtesting.ABTests;
import com.todoroo.astrid.service.abtesting.FeatureFlipper;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Constants;
@ -106,7 +105,6 @@ public class AstridDependencyInjector extends AbstractDependencyInjector {
injectables.put("abTestEventDao", ABTestEventDao.class);
injectables.put("abTestEventReportingService", ABTestEventReportingService.class);
injectables.put("abTestInvoker", ABTestInvoker.class);
injectables.put("featureFlipper", FeatureFlipper.class);
// com.todoroo.astrid.tags
injectables.put("tagService", TagService.class);

@ -42,7 +42,6 @@ import com.todoroo.astrid.opencrx.OpencrxCoreUtils;
import com.todoroo.astrid.producteev.ProducteevUtilities;
import com.todoroo.astrid.reminders.ReminderStartupReceiver;
import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.FeatureFlipper;
import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.widget.TasksWidget.WidgetUpdateService;
@ -84,8 +83,6 @@ public class StartupService {
@Autowired GtasksSyncService gtasksSyncService;
@Autowired FeatureFlipper featureFlipper;
@Autowired ABChooser abChooser;
/**
@ -210,9 +207,6 @@ public class StartupService {
// get and display update messages
if (finalLatestVersion != 0)
new UpdateMessageService().processUpdates(context);
// Check for feature flips
featureFlipper.updateFeatures();
}
}).start();

@ -1,82 +0,0 @@
package com.todoroo.astrid.service.abtesting;
import java.io.IOException;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.RestClient;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls")
public class FeatureFlipper {
private static final String URL = "http://weloveastrid.com/settings.php";
private static final String KEY_SETTING_KEY = "key";
private static final String KEY_SET_OPTION = "setOption";
private static final String KEY_PROBABILITIES = "probabilities";
@Autowired private RestClient restClient;
@Autowired private ABChooser abChooser;
@Autowired private ABTests abTests;
public FeatureFlipper() {
DependencyInjectionService.getInstance().inject(this);
}
/**
* Requests a JSON array containing feature settings override data,
* parses the result, and updates the AB settings for the corresponding features
* @throws JSONException
*/
public synchronized void updateFeatures() {
JSONArray settingsBundle = requestOverrideSettings();
if (settingsBundle == null || settingsBundle.length() == 0)
return;
for (int i = 0; i < settingsBundle.length(); i++) {
try {
JSONObject settings = settingsBundle.getJSONObject(i);
String key = settings.getString(KEY_SETTING_KEY);
if (settings.has(KEY_SET_OPTION)) {
int option = settings.getInt(KEY_SET_OPTION);
abChooser.setChoiceForTest(key, option);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private JSONArray requestOverrideSettings() {
PackageManager pm = ContextManager.getContext().getPackageManager();
try {
PackageInfo pi = pm.getPackageInfo(Constants.PACKAGE, PackageManager.GET_META_DATA);
int versionCode = pi.versionCode;
String result = restClient.get(URL + "?version=" + versionCode + "&" +
"language=" + Locale.getDefault().getISO3Language());
if(TextUtils.isEmpty(result))
return null;
return new JSONArray(result);
} catch (IOException e) {
return null;
} catch (NameNotFoundException e) {
return null;
} catch (JSONException e) {
return null;
}
}
}
Loading…
Cancel
Save