commit 2bfa4ee4fd1c0c282fbc7c4960ffbd6320b61bd6
Author: Matthew Finkel <Matthew.Finkel(a)gmail.com>
Date: Thu Apr 19 20:39:55 2018 +0000
Bug 25741 - TBA: Neuter Firefox Accounts
We're not confident it is proxy-safe, so we disable it. We can revert this when
Bug 1314778 lands.
---
.../base/java/org/mozilla/gecko/BrowserApp.java | 8 ---
.../org/mozilla/gecko/fxa/FirefoxAccounts.java | 73 +++++++++++++---------
.../gecko/fxa/authenticator/AndroidFxAccount.java | 13 +++-
3 files changed, 56 insertions(+), 38 deletions(-)
diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
index ce2f1c5908b8..88c707cfa533 100644
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -398,8 +398,6 @@ public class BrowserApp extends GeckoApp
private ReadingListHelper mReadingListHelper;
- private AccountsHelper mAccountsHelper;
-
private ExtensionPermissionsHelper mExtensionPermissionsHelper;
// The tab to be selected on editing mode exit.
@@ -920,7 +918,6 @@ public class BrowserApp extends GeckoApp
mSharedPreferencesHelper = new SharedPreferencesHelper(appContext);
mReadingListHelper = new ReadingListHelper(appContext, profile);
- mAccountsHelper = new AccountsHelper(appContext, profile);
mExtensionPermissionsHelper = new ExtensionPermissionsHelper(this);
if (AppConstants.MOZ_ANDROID_BEAM) {
@@ -1677,11 +1674,6 @@ public class BrowserApp extends GeckoApp
mReadingListHelper = null;
}
- if (mAccountsHelper != null) {
- mAccountsHelper.uninit();
- mAccountsHelper = null;
- }
-
if (mExtensionPermissionsHelper != null) {
mExtensionPermissionsHelper.uninit();
mExtensionPermissionsHelper = null;
diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java
index 74b10c477237..a207f9b237ad 100644
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java
@@ -7,6 +7,7 @@ package org.mozilla.gecko.fxa;
import java.io.File;
import java.util.concurrent.CountDownLatch;
+import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.fxa.authenticator.AccountPickler;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
@@ -49,15 +50,22 @@ public class FirefoxAccounts {
* @return Firefox account objects.
*/
public static Account[] getFirefoxAccounts(final Context context) {
- final Account[] accounts =
- AccountManager.get(context).getAccountsByType(FxAccountConstants.ACCOUNT_TYPE);
- if (accounts.length > 0) {
- FirefoxAccountsUtils.optionallySeparateAccountsDuringFirstRun(context, accounts);
- return accounts;
- }
+ if (AppConstants.isTorBrowser()) {
+ return new Account[0];
+ } else {
+ // TBA: Conditionally disable this at run-time.
+ // XXX This will throw a java.lang.SecurityException because we don't declare
+ // the android.permission.GET_ACCOUNTS permission.
+ final Account[] accounts =
+ AccountManager.get(context).getAccountsByType(FxAccountConstants.ACCOUNT_TYPE);
+ if (accounts.length > 0) {
+ FirefoxAccountsUtils.optionallySeparateAccountsDuringFirstRun(context, accounts);
+ return accounts;
+ }
- final Account pickledAccount = getPickledAccount(context);
- return (pickledAccount != null) ? new Account[] {pickledAccount} : new Account[0];
+ final Account pickledAccount = getPickledAccount(context);
+ return (pickledAccount != null) ? new Account[] {pickledAccount} : new Account[0];
+ }
}
private static Account getPickledAccount(final Context context) {
@@ -111,9 +119,14 @@ public class FirefoxAccounts {
}
public static void logSyncOptions(Bundle syncOptions) {
- final boolean scheduleNow = syncOptions.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false);
+ if (AppConstants.isTorBrowser()) {
+ // Don't log an erroneous message, this'll only confuse someone looking at the logs.
+ return;
+ } else {
+ final boolean scheduleNow = syncOptions.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false);
- Logger.info(LOG_TAG, "Sync options -- scheduling now: " + scheduleNow);
+ Logger.info(LOG_TAG, "Sync options -- scheduling now: " + scheduleNow);
+ }
}
public static void requestImmediateSync(final Account account, String[] stagesToSync, String[] stagesToSkip, boolean ignoreSettings) {
@@ -145,28 +158,32 @@ public class FirefoxAccounts {
* @param stagesToSkip stage names to skip.
*/
protected static void requestSync(final Account account, final Bundle syncOptions, String[] stagesToSync, String[] stagesToSkip) {
- if (account == null) {
- throw new IllegalArgumentException("account must not be null");
- }
- if (syncOptions == null) {
- throw new IllegalArgumentException("syncOptions must not be null");
- }
+ if (AppConstants.isTorBrowser()) {
+ return;
+ } else {
+ if (account == null) {
+ throw new IllegalArgumentException("account must not be null");
+ }
+ if (syncOptions == null) {
+ throw new IllegalArgumentException("syncOptions must not be null");
+ }
- Utils.putStageNamesToSync(syncOptions, stagesToSync, stagesToSkip);
+ Utils.putStageNamesToSync(syncOptions, stagesToSync, stagesToSkip);
- Logger.info(LOG_TAG, "Requesting sync.");
- logSyncOptions(syncOptions);
+ Logger.info(LOG_TAG, "Requesting sync.");
+ logSyncOptions(syncOptions);
- // We get strict mode warnings on some devices, so make the request on a
- // background thread.
- ThreadPool.run(new Runnable() {
- @Override
- public void run() {
- for (String authority : AndroidFxAccount.DEFAULT_AUTHORITIES_TO_SYNC_AUTOMATICALLY_MAP.keySet()) {
- ContentResolver.requestSync(account, authority, syncOptions);
+ // We get strict mode warnings on some devices, so make the request on a
+ // background thread.
+ ThreadPool.run(new Runnable() {
+ @Override
+ public void run() {
+ for (String authority : AndroidFxAccount.DEFAULT_AUTHORITIES_TO_SYNC_AUTOMATICALLY_MAP.keySet()) {
+ ContentResolver.requestSync(account, authority, syncOptions);
+ }
}
- }
- });
+ });
+ }
}
/**
diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java
index 21af0694ceed..58422355b326 100644
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java
@@ -29,6 +29,7 @@ import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.util.Log;
+import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.background.common.GlobalConstants;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
@@ -711,7 +712,11 @@ public class AndroidFxAccount {
* @param ignoreSettings whether we should check if syncing is allowed via in-app or system settings.
*/
public void requestImmediateSync(String[] stagesToSync, String[] stagesToSkip, boolean ignoreSettings) {
- FirefoxAccounts.requestImmediateSync(getAndroidAccount(), stagesToSync, stagesToSkip, ignoreSettings);
+ if (AppConstants.isTorBrowser()) {
+ return;
+ } else {
+ FirefoxAccounts.requestImmediateSync(getAndroidAccount(), stagesToSync, stagesToSkip, ignoreSettings);
+ }
}
/**
@@ -722,7 +727,11 @@ public class AndroidFxAccount {
* @param stagesToSkip stage names to skip; can be null to skip <b>no</b> known stages.
*/
public void requestEventualSync(String[] stagesToSync, String[] stagesToSkip) {
- FirefoxAccounts.requestEventualSync(getAndroidAccount(), stagesToSync, stagesToSkip);
+ if (AppConstants.isTorBrowser()) {
+ return;
+ } else {
+ FirefoxAccounts.requestEventualSync(getAndroidAccount(), stagesToSync, stagesToSkip);
+ }
}
public synchronized void setState(State state) {