Backed out 3 changesets (bug 1348820) for testANRReporter failures on Android rc1 a=backout

Backed out changeset 2fffcd4ce3e4 (bug 1348820)
Backed out changeset 387d0326e3a0 (bug 1348820)
Backed out changeset 4775bb6e6b61 (bug 1348820)

MozReview-Commit-ID: 7e1oQSPE7kX

--HG--
extra : source : 377c33c931fe4e5abd8f37d8a0cdccecc7956ccc
This commit is contained in:
Wes Kocher 2017-03-23 14:45:57 -07:00
parent 1087616d0e
commit e7b38b53a1
11 changed files with 59 additions and 169 deletions

View file

@ -318,4 +318,11 @@ public class AppConstants {
// (bug 1266820) Temporarily disabled since no one is working on it.
public static final boolean SCREENSHOTS_IN_BOOKMARKS_ENABLED = false;
public static final boolean MOZ_ANDROID_ACTIVITY_STREAM =
//#ifdef MOZ_ANDROID_ACTIVITY_STREAM
true;
//#else
false;
//#endif
}

View file

@ -37,7 +37,8 @@ def main(output_file, input_filename):
CONFIG.update(buildconfig.substs)
DEFINES = {}
for var in ('MOZ_ANDROID_ANR_REPORTER',
for var in ('MOZ_ANDROID_ACTIVITY_STREAM'
'MOZ_ANDROID_ANR_REPORTER',
'MOZ_ANDROID_BEAM',
'MOZ_ANDROID_CUSTOM_TABS',
'MOZ_ANDROID_DOWNLOADS_INTEGRATION',

View file

@ -59,12 +59,6 @@ public class Experiments {
// Make new activity stream panel available (to replace top sites) (Bug 1313316)
public static final String ACTIVITY_STREAM = "activity-stream";
// Show a setting in "experimental features" for enabling/disabling activity stream.
public static final String ACTIVITY_STREAM_SETTING = "activity-stream-setting";
// Enable Activity stream by default for users in the "opt out" group.
public static final String ACTIVITY_STREAM_OPT_OUT = "activity-stream-opt-out";
// Tabs tray: Arrange tabs in two columns in portrait mode
public static final String COMPACT_TABS = "compact-tabs";

View file

@ -6,7 +6,6 @@
package org.mozilla.gecko.activitystream;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.TextUtils;
@ -49,98 +48,35 @@ public class ActivityStream {
"edit"
);
/**
* Returns true if the user has made an active decision: Enabling or disabling Activity Stream.
*/
public static boolean hasUserEnabledOrDisabled(Context context) {
final SharedPreferences preferences = GeckoSharedPrefs.forApp(context);
return preferences.contains(GeckoPreferences.PREFS_ACTIVITY_STREAM);
}
/**
* Set the user's decision: Enable or disable Activity Stream.
*/
public static void setUserEnabled(Context context, boolean value) {
GeckoSharedPrefs.forApp(context).edit()
.putBoolean(GeckoPreferences.PREFS_ACTIVITY_STREAM, value)
.apply();
}
/**
* Returns true if Activity Stream has been enabled by the user. Before calling this method
* hasUserEnabledOrDisabled() should be used to determine whether the user actually has made
* a decision.
*/
public static boolean isEnabledByUser(Context context) {
final SharedPreferences preferences = GeckoSharedPrefs.forApp(context);
if (!preferences.contains(GeckoPreferences.PREFS_ACTIVITY_STREAM)) {
throw new IllegalStateException("User hasn't made a decision. Call hasUserEnabledOrDisabled() before calling this method");
}
return preferences.getBoolean(GeckoPreferences.PREFS_ACTIVITY_STREAM, /* should not be used */ false);
}
/**
* Is Activity Stream enabled by an A/B experiment?
*/
public static boolean isEnabledByExperiment(Context context) {
// For users in the "opt out" group Activity Stream is enabled by default.
return SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM_OPT_OUT);
}
/**
* Is Activity Stream enabled? Either actively by the user or by an experiment?
*/
public static boolean isEnabled(Context context) {
// (1) Can Activity Steam be enabled on this device?
if (!canBeEnabled(context)) {
if (!isUserEligible(context)) {
// If the user is not eligible then disable activity stream. Even if it has been
// enabled before.
return false;
}
// (2) Has Activity Stream be enabled/disabled by the user?
if (hasUserEnabledOrDisabled(context)) {
return isEnabledByUser(context);
}
// (3) Is Activity Stream enabled by an experiment?
return isEnabledByExperiment(context);
return GeckoSharedPrefs.forApp(context)
.getBoolean(GeckoPreferences.PREFS_ACTIVITY_STREAM, false);
}
/**
* Can the user enable/disable Activity Stream (Returns true) or is this completely controlled by us?
* Is the user eligible to use activity stream or should we hide it from settings etc.?
*/
public static boolean isUserSwitchable(Context context) {
// (1) Can Activity Steam be enabled on this device?
if (!canBeEnabled(context)) {
return false;
public static boolean isUserEligible(Context context) {
if (AppConstants.MOZ_ANDROID_ACTIVITY_STREAM) {
// If the build flag is enabled then just show the option to the user.
return true;
}
// (2) Is the user part of the experiment for showing the settings UI?
return SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM_SETTING);
}
/**
* This method returns true if Activity Stream can be enabled - by the user or an experiment.
* Whether a setting shows up or whether the user is in an experiment group is evaluated
* separately from this method. However if this methods returns false then Activity Stream
* should never be visible/enabled - no matter what build or what experiments are active.
*/
public static boolean canBeEnabled(Context context) {
if (!AppConstants.NIGHTLY_BUILD) {
// If this is not a Nightly build then hide Activity Stream completely. We can control
// this via the Switchboard experiment too but I want to make really sure that this
// isn't riding the trains accidentally.
return false;
if (AppConstants.NIGHTLY_BUILD && SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM)) {
// If this is a nightly build and the user is part of the activity stream experiment then
// the option should be visible too. The experiment is limited to Nightly too but I want
// to make really sure that this isn't riding the trains accidentally.
return true;
}
if (!SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM)) {
// This is our kill switch. If the user is not part of this experiment then show no
// Activity Stream UI.
return false;
}
// Activity stream can be enabled. Whether it is depends on other experiments and settings.
return true;
// For everyone else activity stream is not available yet.
return false;
}
/**

View file

@ -1,72 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.activitystream;
import android.content.Context;
import android.preference.SwitchPreference;
import android.util.AttributeSet;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.util.ThreadUtils;
/**
* A custom switch preference that is used while we allow users to opt-out from using Activity Stream.
*/
public class ActivityStreamPreference extends SwitchPreference {
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context) {
super(context);
init(context);
}
private void init(Context context) {
// The SwitchPreference shouldn't do any persistence itself. We want to avoid that a value
// is written that is not set by the user but set from an experiment.
setPersistent(false);
setChecked(ActivityStream.isEnabled(context));
}
@Override
public boolean isPersistent() {
// Just be absolutely sure that no one re-sets this value since calling init().
return false;
}
@Override
protected void onClick() {
super.onClick();
ActivityStream.setUserEnabled(getContext(), isChecked());
// We require a restart for this change to take effect. This is not nice, but this setting
// is not something we want to ship outside of Nightly anyways.
ThreadUtils.postDelayedToUiThread(new Runnable() {
@Override
public void run() {
GeckoAppShell.scheduleRestart();
}
}, 1000);
}
}

View file

@ -168,7 +168,7 @@ public class GeckoPreferences
public static final String PREFS_READ_PARTNER_CUSTOMIZATIONS_PROVIDER = NON_PREF_PREFIX + "distribution.read_partner_customizations_provider";
public static final String PREFS_READ_PARTNER_BOOKMARKS_PROVIDER = NON_PREF_PREFIX + "distribution.read_partner_bookmarks_provider";
public static final String PREFS_CUSTOM_TABS = NON_PREF_PREFIX + "customtabs";
public static final String PREFS_ACTIVITY_STREAM = NON_PREF_PREFIX + "experiments.activitystream";
public static final String PREFS_ACTIVITY_STREAM = NON_PREF_PREFIX + "activitystream";
public static final String PREFS_CATEGORY_EXPERIMENTAL_FEATURES = NON_PREF_PREFIX + "category_experimental";
public static final String PREFS_COMPACT_TABS = NON_PREF_PREFIX + "compact_tabs";
public static final String PREFS_SHOW_QUIT_MENU = NON_PREF_PREFIX + "distribution.show_quit_menu";
@ -714,6 +714,7 @@ public class GeckoPreferences
i--;
continue;
} else if (PREFS_CATEGORY_EXPERIMENTAL_FEATURES.equals(key)
&& !AppConstants.MOZ_ANDROID_ACTIVITY_STREAM
&& !AppConstants.MOZ_ANDROID_CUSTOM_TABS) {
preferences.removePreference(pref);
i--;
@ -914,8 +915,7 @@ public class GeckoPreferences
preferences.removePreference(pref);
i--;
continue;
} else if (PREFS_ACTIVITY_STREAM.equals(key)
&& !ActivityStream.isUserSwitchable(this)) {
} else if (PREFS_ACTIVITY_STREAM.equals(key) && !ActivityStream.isUserEligible(this)) {
preferences.removePreference(pref);
i--;
continue;
@ -1241,6 +1241,13 @@ public class GeckoPreferences
}
} else if (PREFS_NOTIFICATIONS_CONTENT.equals(prefName)) {
FeedService.setup(this);
} else if (PREFS_ACTIVITY_STREAM.equals(prefName)) {
ThreadUtils.postDelayedToUiThread(new Runnable() {
@Override
public void run() {
GeckoAppShell.scheduleRestart();
}
}, 1000);
} else if (HANDLERS.containsKey(prefName)) {
PrefHandler handler = HANDLERS.get(prefName);
handler.onChange(this, preference, newValue);

View file

@ -1123,7 +1123,8 @@ for var in ('MOZ_ANDROID_ANR_REPORTER', 'MOZ_DEBUG',
'MOZ_ANDROID_DOWNLOADS_INTEGRATION', 'MOZ_INSTALL_TRACKING',
'MOZ_ANDROID_GCM', 'MOZ_ANDROID_EXCLUDE_FONTS', 'MOZ_LOCALE_SWITCHER',
'MOZ_ANDROID_BEAM', 'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE',
'MOZ_SWITCHBOARD', 'MOZ_ANDROID_CUSTOM_TABS'):
'MOZ_SWITCHBOARD', 'MOZ_ANDROID_CUSTOM_TABS',
'MOZ_ANDROID_ACTIVITY_STREAM'):
if CONFIG[var]:
DEFINES[var] = 1

View file

@ -84,10 +84,10 @@
android:key="android.not_a_preference.category_experimental"
android:title="@string/pref_category_experimental">
<org.mozilla.gecko.activitystream.ActivityStreamPreference
android:key="android.not_a_preference.experiments.activitystream"
<SwitchPreference android:key="android.not_a_preference.activitystream"
android:title="@string/pref_activity_stream"
android:summary="@string/pref_activity_stream_summary" />
android:summary="@string/pref_activity_stream_summary"
android:defaultValue="false" />
<SwitchPreference android:key="android.not_a_preference.customtabs"

View file

@ -4080,8 +4080,10 @@ Tab.prototype = {
this.browser.addEventListener("pagehide", listener, true);
}
if (!docURI.startsWith("about:")) {
WebsiteMetadata.parseAsynchronously(this.browser.contentDocument);
if (AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_ANDROID_ACTIVITY_STREAM) {
if (!docURI.startsWith("about:")) {
WebsiteMetadata.parseAsynchronously(this.browser.contentDocument);
}
}
break;

View file

@ -48,6 +48,13 @@ project_flag('MOZ_SWITCHBOARD',
help='Include Switchboard A/B framework on Android',
default=True)
option(env='MOZ_ANDROID_ACTIVITY_STREAM',
help='Enable Activity Stream on Android (replacing the default HomePager)',
default=False)
set_config('MOZ_ANDROID_ACTIVITY_STREAM',
depends_if('MOZ_ANDROID_ACTIVITY_STREAM')(lambda _: True))
option(env='MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER',
help='Build and package the install bouncer APK',
default=True)

View file

@ -302,6 +302,13 @@ this.AppConstants = Object.freeze({
false,
#endif
MOZ_ANDROID_ACTIVITY_STREAM:
#ifdef MOZ_ANDROID_ACTIVITY_STREAM
true,
#else
false,
#endif
DLL_PREFIX: "@DLL_PREFIX@",
DLL_SUFFIX: "@DLL_SUFFIX@",