[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-68.1.0esr-9.0-1] Bug 25741 - TBA: Remove sync option from preferences



commit da563f691147389df259b61f4f47c490257e8bf2
Author: Amogh Pradeep <amoghbl1@xxxxxxxxx>
Date:   Fri Jul 17 13:27:07 2015 -0400

    Bug 25741 - TBA: Remove sync option from preferences
    
    We don't want this while the Sync subsystem is a proxy-bypass risk. We
    can drop this when the feature is patched (Bug 1314778).
    
    Signed-off-by: Amogh Pradeep <amoghbl1@xxxxxxxxx>
    
    Also:
    Bug 28507 - Don't call Push and Sync services during Sanitize
    Bug 30086 - Prevent Sync-related crashes on Android
    Bug 25741 - TBA: Only include Firefox Account permissions if we want them (using MOZ_ACCOUNT)
    Bug 25741 - TBA: Neuter Firefox Accounts
---
 .../android/app/src/main/res/xml/preferences.xml   |  6 --
 mobile/android/base/AndroidManifest.xml.in         |  4 ++
 .../android/base/FennecManifest_permissions.xml.in |  2 +
 .../base/java/org/mozilla/gecko/BrowserApp.java    |  8 ---
 .../mozilla/gecko/home/CombinedHistoryPanel.java   | 14 +++--
 .../overlays/service/sharemethods/SendTab.java     |  6 +-
 .../base/locales/en-US/torbrowser_strings.dtd      |  2 +
 mobile/android/base/strings.xml.in                 |  2 +
 mobile/android/modules/Sanitizer.jsm               | 47 ++++++++------
 .../org/mozilla/gecko/fxa/FirefoxAccounts.java     | 73 +++++++++++++---------
 .../gecko/fxa/authenticator/AndroidFxAccount.java  | 13 +++-
 11 files changed, 107 insertions(+), 70 deletions(-)

diff --git a/mobile/android/app/src/main/res/xml/preferences.xml b/mobile/android/app/src/main/res/xml/preferences.xml
index a9cec32ca3ef..f9c5c9e1ac53 100644
--- a/mobile/android/app/src/main/res/xml/preferences.xml
+++ b/mobile/android/app/src/main/res/xml/preferences.xml
@@ -9,12 +9,6 @@
                   xmlns:gecko="http://schemas.android.com/apk/res-auto";
                   android:enabled="false">
 
-    <org.mozilla.gecko.preferences.SyncPreference android:key="android.not_a_preference.sync"
-                                                  android:title="@string/pref_sync"
-                                                  android:icon="@drawable/sync_avatar_default"
-                                                  android:summary="@string/pref_sync_summary"
-                                                  android:persistent="false" />
-
     <org.mozilla.gecko.preferences.DefaultBrowserPreference
             android:key="android.not_a_preference.default_browser.link"
             android:persistent="false"
diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in
index 17a34703e6e7..e61a3411b2e0 100644
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -291,7 +291,9 @@
             </intent-filter>
         </receiver>
 
+#ifdef MOZ_ACCOUNT
 #include ../services/manifests/FxAccountAndroidManifest_activities.xml.in
+#endif
 
 #ifdef MOZ_CRASHREPORTER
         <activity android:name="org.mozilla.gecko.CrashReporterActivity"
@@ -504,7 +506,9 @@
             </intent-filter>
         </service>
 
+#ifdef MOZ_ACCOUNT
 #include ../services/manifests/FxAccountAndroidManifest_services.xml.in
+#endif
 
         <service
             android:name="org.mozilla.gecko.tabqueue.TabReceivedService"
diff --git a/mobile/android/base/FennecManifest_permissions.xml.in b/mobile/android/base/FennecManifest_permissions.xml.in
index ffa6d27a8b0d..f3e43bb4e3ca 100644
--- a/mobile/android/base/FennecManifest_permissions.xml.in
+++ b/mobile/android/base/FennecManifest_permissions.xml.in
@@ -1,5 +1,7 @@
 
+#ifdef MOZ_ACCOUNT
 #include ../services/manifests/FxAccountAndroidManifest_permissions.xml.in
+#endif
 
 <!-- Bug 1261302: we have two new permissions to request,
      RECEIVE_BOOT_COMPLETED and the permission for push.  We want to ask for
diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
index 7d4c03f7e5d2..80981eb87136 100644
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -303,8 +303,6 @@ public class BrowserApp extends GeckoApp
 
     private ReadingListHelper mReadingListHelper;
 
-    private AccountsHelper mAccountsHelper;
-
     private ExtensionPermissionsHelper mExtensionPermissionsHelper;
 
     // The tab to be selected on editing mode exit.
@@ -839,7 +837,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) {
@@ -1575,11 +1572,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/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
index 4080317cd65a..39905dd950de 100644
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -244,10 +244,16 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
         syncSetupButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
-                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "history_syncsetup");
-                // This Activity will redirect to the correct Activity as needed.
-                final Intent intent = new Intent(FxAccountConstants.ACTION_FXA_GET_STARTED);
-                startActivity(intent);
+                // Tell the user this action is not supported
+                final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
+                dialogBuilder.setMessage(R.string.sync_not_supported);
+                dialogBuilder.setNegativeButton(R.string.button_cancel, new AlertDialog.OnClickListener() {
+                    @Override
+                    public void onClick(final DialogInterface dialog, final int which) {
+                        dialog.dismiss();
+                    }
+                });
+                dialogBuilder.show();
             }
         });
 
diff --git a/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java b/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java
index 9382c2ec15f9..5babb74c4f88 100644
--- a/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java
@@ -165,7 +165,8 @@ public class SendTab extends ShareMethod {
         }
 
         // Have registered UIs offer to set up a Firefox Account.
-        setOverrideIntentAction(FxAccountConstants.ACTION_FXA_GET_STARTED);
+        // Comment for Tor Browser
+        //setOverrideIntentAction(FxAccountConstants.ACTION_FXA_GET_STARTED);
     }
 
     /**
@@ -187,7 +188,8 @@ public class SendTab extends ShareMethod {
         if (validGUIDs.isEmpty()) {
             // Guess we'd better override. We have no clients.
             // This does the broadcast for us.
-            setOverrideIntentAction(FxAccountConstants.ACTION_FXA_GET_STARTED);
+            // Comment for Tor Browser
+            //setOverrideIntentAction(FxAccountConstants.ACTION_FXA_GET_STARTED);
             return;
         }
 
diff --git a/mobile/android/base/locales/en-US/torbrowser_strings.dtd b/mobile/android/base/locales/en-US/torbrowser_strings.dtd
index d23acc8a033a..b43134a0260b 100644
--- a/mobile/android/base/locales/en-US/torbrowser_strings.dtd
+++ b/mobile/android/base/locales/en-US/torbrowser_strings.dtd
@@ -3,3 +3,5 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <!ENTITY firstrun_urlbar_subtext2 "A modern mobile browser from The Tor Project, the non-profit committed to a free and open web.">
+
+<!ENTITY sync_not_supported "Sync is not currently supported in Tor Browser on Android">
diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in
index c328bd6b512a..5453bed65e71 100644
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -54,6 +54,8 @@
 
   <string name="firstrun_welcome_restricted">&onboard_start_restricted1;</string>
 
+  <string name="sync_not_supported">&sync_not_supported;</string>
+
   <string name="bookmarks_title">&bookmarks_title;</string>
   <string name="history_title">&history_title;</string>
 
diff --git a/mobile/android/modules/Sanitizer.jsm b/mobile/android/modules/Sanitizer.jsm
index f244e4a2008b..d3538d49e07f 100644
--- a/mobile/android/modules/Sanitizer.jsm
+++ b/mobile/android/modules/Sanitizer.jsm
@@ -183,18 +183,22 @@ Sanitizer.prototype = {
         sss.clearAll();
 
         // Clear push subscriptions
-        await new Promise((resolve, reject) => {
-          let push = Cc["@mozilla.org/push/Service;1"].getService(
-            Ci.nsIPushService
-          );
-          push.clearForDomain("*", status => {
-            if (Components.isSuccessCode(status)) {
-              resolve();
-            } else {
-              reject(new Error("Error clearing push subscriptions: " + status));
-            }
-          });
-        });
+        //await new Promise((resolve, reject) => {
+        //  let push = Cc["@mozilla.org/push/Service;1"].getService(
+        //    Ci.nsIPushService
+        //  );
+        //  push.clearForDomain("*", status => {
+        //    if (Components.isSuccessCode(status)) {
+        //      resolve();
+        //    } else {
+        //      reject(new Error("Error clearing push subscriptions: " + status));
+        //    }
+        //  });
+        //});
+
+        // Avoid throwing an error because Ci.nsIPushService isn't implemented
+        // All other clearing actions should succeed if we arrive here.
+        Promise.resolve();
         TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS", refObj);
       },
 
@@ -491,14 +495,17 @@ Sanitizer.prototype = {
       },
 
       canClear: function(aCallback) {
-        Accounts.anySyncAccountsExist()
-          .then(aCallback)
-          .catch(function(err) {
-            Cu.reportError("Java-side synced tabs clearing failed: " + err);
-            aCallback(false);
-          });
-      },
-    },
+        //Accounts.anySyncAccountsExist()
+        //  .then(aCallback)
+        //  .catch(function(err) {
+        //    Cu.reportError("Java-side synced tabs clearing failed: " + err);
+        //    aCallback(false);
+        //  });
+
+        // We can't clear syncedTabs because Sync is non-functional
+        aCallback(false);
+      }
+    }
   },
 };
 
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 4562559afc44..8d2b8bd2cd4a 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;
@@ -708,7 +709,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);
+    }
   }
 
   /**
@@ -719,7 +724,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) {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits