Backed out changeset 74b5dba16c23 (bug 802749) for Android bustage. r=backout

This commit is contained in:
Sebastian Hengst 2017-09-25 00:54:47 +02:00
Родитель db3c651010
Коммит 9a17ff4441
6 изменённых файлов: 6 добавлений и 69 удалений

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

@ -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}:

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

@ -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;
@ -24,7 +28,6 @@ import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.GeckoSharedPrefs;
import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
@ -34,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;
@ -103,7 +105,6 @@ public class FxAccountStatusFragment
protected CheckBoxPreference passwordsPreference;
protected EditTextPreference deviceNamePreference;
protected SwitchPreference syncOverMeteredPreference;
protected Preference syncServerPreference;
protected Preference syncNowPreference;
@ -183,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);
@ -950,10 +948,6 @@ public class FxAccountStatusFragment
return true;
}
if (preference == syncOverMeteredPreference) {
GeckoSharedPrefs.forApp(getContext()).edit().putBoolean(FxAccountSyncAdapter.PREFS_SYNC_METERED, (Boolean) newValue).apply();
}
// For everything else, accept the change.
return true;
}

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

@ -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.
@ -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(

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

@ -12,12 +12,10 @@ 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;
import org.mozilla.gecko.GeckoSharedPrefs;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.background.fxa.SkewHandler;
@ -75,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.
@ -500,22 +496,6 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
*/
@Override
public void onPerformSync(final Account account, final Bundle extras, final String authority, ContentProviderClient provider, final SyncResult syncResult) {
// 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.
final boolean isMeteredAllowed = GeckoSharedPrefs.forApp(getContext()).getBoolean(PREFS_SYNC_METERED, true);
// 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;
}
Logger.setThreadLogTag(FxAccountConstants.GLOBAL_LOG_TAG);
Logger.resetLogging();
@ -565,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();

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

@ -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"

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

@ -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>