Backed out changeset 5799b3ef8745 (bug 802749) at flod's request a=backout

MozReview-Commit-ID: INjvhFgmO9m
This commit is contained in:
Wes Kocher 2017-09-25 23:08:20 -07:00
parent 18a2426a5d
commit a8bbad92b3
6 changed files with 7 additions and 77 deletions

View File

@ -68,10 +68,6 @@
<!ENTITY fxaccount_status_passwords2 'Logins'>
<!ENTITY fxaccount_status_tabs 'Open tabs'>
<!ENTITY fxaccount_status_additional_settings 'Additional Settings'>
<!ENTITY fxaccount_pref_sync_use_metered 'Sync over metered connections'>
<!-- Localization note: Only affects background syncing, user initiated
syncs will still be done regardless of the connection -->
<!ENTITY fxaccount_pref_sync_use_metered_summary 'Allow usage of cellular data and metered wi-fi to sync in the background'>
<!ENTITY fxaccount_status_legal 'Legal' >
<!-- Localization note: when tapped, the following two strings link to
external web pages. Compare fxaccount_policy_{linktos,linkprivacy}:

View File

@ -13,9 +13,13 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.*;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
@ -33,7 +37,6 @@ import org.mozilla.gecko.fxa.SyncStatusListener;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.fxa.login.Married;
import org.mozilla.gecko.fxa.login.State;
import org.mozilla.gecko.fxa.sync.FxAccountSyncAdapter;
import org.mozilla.gecko.fxa.sync.FxAccountSyncStatusHelper;
import org.mozilla.gecko.sync.ExtendedJSONObject;
import org.mozilla.gecko.sync.SharedPreferencesClientsDataDelegate;
@ -102,7 +105,6 @@ public class FxAccountStatusFragment
protected CheckBoxPreference passwordsPreference;
protected EditTextPreference deviceNamePreference;
protected SwitchPreference syncOverMeteredPreference;
protected Preference syncServerPreference;
protected Preference syncNowPreference;
@ -182,9 +184,6 @@ public class FxAccountStatusFragment
tabsPreference.setOnPreferenceClickListener(this);
passwordsPreference.setOnPreferenceClickListener(this);
syncOverMeteredPreference = (SwitchPreference) ensureFindPreference(FxAccountSyncAdapter.PREFS_SYNC_METERED);
syncOverMeteredPreference.setOnPreferenceChangeListener(this);
deviceNamePreference = (EditTextPreference) ensureFindPreference("device_name");
deviceNamePreference.setOnPreferenceChangeListener(this);
@ -949,14 +948,6 @@ public class FxAccountStatusFragment
return true;
}
if (preference == syncOverMeteredPreference) {
try {
fxAccount.getSyncPrefs().edit().putBoolean(FxAccountSyncAdapter.PREFS_SYNC_METERED, (Boolean) newValue).apply();
} catch (Exception e) {
Logger.error(LOG_TAG, "Failed to save the new for syncMeteredPreference");
}
}
// For everything else, accept the change.
return true;
}

View File

@ -147,7 +147,6 @@ public class AndroidFxAccount {
protected final Context context;
private final AccountManager accountManager;
private final long neverSynced = -1;
// This is really, really meant to be final. Only changed when account name changes.
// See Bug 1368147.
@ -648,7 +647,7 @@ public class AndroidFxAccount {
*
* @param stagesToSync stage names to sync; can be null to sync <b>all</b> known stages.
* @param stagesToSkip stage names to skip; can be null to skip <b>no</b> known stages.
* @param ignoreSettings whether we should check if syncing is allowed via in-app or system settings.
* @param ignoreSettings whether we should check preferences for syncing over metered connections.
*/
public void requestImmediateSync(String[] stagesToSync, String[] stagesToSkip, boolean ignoreSettings) {
FirefoxAccounts.requestImmediateSync(getAndroidAccount(), stagesToSync, stagesToSkip, ignoreSettings);
@ -800,6 +799,7 @@ public class AndroidFxAccount {
}
public long getLastSyncedTimestamp() {
final long neverSynced = -1L;
try {
return getSyncPrefs().getLong(PREF_KEY_LAST_SYNCED_TIMESTAMP, neverSynced);
} catch (Exception e) {
@ -808,15 +808,6 @@ public class AndroidFxAccount {
}
}
public boolean neverSynced() {
try {
return getSyncPrefs().getLong(PREF_KEY_LAST_SYNCED_TIMESTAMP, neverSynced) == -1;
} catch (Exception e) {
Logger.warn(LOG_TAG, "Got exception getting last synced time; ignoring.", e);
return false;
}
}
// Debug only! This is dangerous!
public void unsafeTransitionToDefaultEndpoints() {
unsafeTransitionToStageEndpoints(

View File

@ -12,7 +12,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SyncResult;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.content.LocalBroadcastManager;
@ -74,8 +73,6 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
// Tracks the last seen storage hostname for backoff purposes.
private static final String PREF_BACKOFF_STORAGE_HOST = "backoffStorageHost";
// Preference key for allowing sync over metered connections.
public static final String PREFS_SYNC_METERED = "sync.allow_metered";
// Used to do cheap in-memory rate limiting. Don't sync again if we
// successfully synced within this duration.
@ -505,27 +502,6 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
final Context context = getContext();
final AndroidFxAccount fxAccount = new AndroidFxAccount(context, account);
// This flag is used to conclude whether we should ignore syncing
// based on user preference for syncing over metered connections.
boolean shouldRejectSyncViaSettings = false;
// Check whether we should ignore settings or not.
if (!extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, false)) {
// If it's not user-initiated, we should check if we are allowed to sync on metered connections.
boolean isMeteredAllowed = true;
try {
isMeteredAllowed = fxAccount.getSyncPrefs().getBoolean(PREFS_SYNC_METERED, true);
} catch (Exception e) {
Logger.error(LOG_TAG, "Failed to read sync preferences. Allowing metered connections by default.");
}
// Check if the device is on a metered connection or not.
final ConnectivityManager manager = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
final boolean isMetered = manager.isActiveNetworkMetered();
// If the connection is metered and syncing over metered connections is
// not permitted, we should bail.
shouldRejectSyncViaSettings = !isMeteredAllowed && isMetered;
}
// NB: we use elapsedRealtime which is time since boot, to ensure our clock is monotonic and isn't
// paused while CPU is in the power-saving mode.
final long syncDeadline = SystemClock.elapsedRealtime() + SYNC_DEADLINE_DELTA_MILLIS;
@ -569,26 +545,9 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
Collection<String> knownStageNames = SyncConfiguration.validEngineNames();
Collection<String> stageNamesToSync = Utils.getStagesToSyncFromBundle(knownStageNames, extras);
// If syncing should be rejected due to metered connection preferences
// and we are doing the first sync ever, we should at least sync the
// 'clients' collection to ensure we upload our local client record.
// see {@link <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=802749">Bug 802749</a>}
// for more information.
if (shouldRejectSyncViaSettings && fxAccount.neverSynced()) {
stageNamesToSync.clear();
stageNamesToSync.add("clients");
}
final SyncDelegate syncDelegate = new SyncDelegate(latch, syncResult, fxAccount, stageNamesToSync);
Result offeredResult = null;
if (shouldRejectSyncViaSettings && !fxAccount.neverSynced()) {
// The user is on a metered connection and has disabled syncing over metered connections,
// we should reject the sync.
syncDelegate.rejectSync();
return;
}
try {
// This will be the same chunk of SharedPreferences that we pass through to GlobalSession/SyncConfiguration.
final SharedPreferences sharedPrefs = fxAccount.getSyncPrefs();

View File

@ -84,11 +84,6 @@
android:key="device_name"
android:persistent="false"
android:title="@string/fxaccount_status_device_name" />
<SwitchPreference
android:key="sync.allow_metered"
android:defaultValue="true"
android:title="@string/fxaccount_pref_sync_use_metered"
android:summary="@string/fxaccount_pref_sync_use_metered_summary"/>
<org.mozilla.gecko.fxa.activities.CustomColorPreference
android:editable="false"

View File

@ -47,8 +47,6 @@
<string name="fxaccount_status_history">&fxaccount_status_history;</string>
<string name="fxaccount_status_passwords">&fxaccount_status_passwords2;</string>
<string name="fxaccount_status_tabs">&fxaccount_status_tabs;</string>
<string name="fxaccount_pref_sync_use_metered">&fxaccount_pref_sync_use_metered;</string>
<string name="fxaccount_pref_sync_use_metered_summary">&fxaccount_pref_sync_use_metered_summary;</string>
<string name="fxaccount_status_additional_settings">&fxaccount_status_additional_settings;</string>
<string name="fxaccount_status_legal">&fxaccount_status_legal;</string>
<string name="fxaccount_status_linktos">&fxaccount_status_linktos2;</string>