Bug 1220906 - Part 2: Deprecate Accounts.syncAccountsExist. r?rnewman draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 18 Jan 2016 15:35:45 -0800
changeset 323261 5aa68f961f9c90dde497b3e3cdfbf8459e8e1edc
parent 323260 7d0b28eb59c5de6e0177191c2b5879ef969d95af
child 323262 0fe55dc6012b5895fc465b45ec5bd35bed5d64ec
push id9692
push usernalexander@mozilla.com
push dateTue, 19 Jan 2016 22:55:33 +0000
reviewersrnewman
bugs1220906
milestone46.0a1
Bug 1220906 - Part 2: Deprecate Accounts.syncAccountsExist. r?rnewman
mobile/android/base/java/org/mozilla/gecko/AccountsHelper.java
mobile/android/modules/Accounts.jsm
--- a/mobile/android/base/java/org/mozilla/gecko/AccountsHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/AccountsHelper.java
@@ -9,28 +9,28 @@ import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AccountManagerCallback;
 import android.accounts.AccountManagerFuture;
 import android.accounts.AuthenticatorException;
 import android.accounts.OperationCanceledException;
 import android.content.Context;
 import android.content.Intent;
 import android.util.Log;
+
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.background.fxa.FxAccountUtils;
 import org.mozilla.gecko.fxa.FirefoxAccounts;
 import org.mozilla.gecko.fxa.FxAccountConstants;
 import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
 import org.mozilla.gecko.fxa.login.Engaged;
 import org.mozilla.gecko.fxa.login.State;
 import org.mozilla.gecko.restrictions.Restrictable;
 import org.mozilla.gecko.sync.SyncConfiguration;
 import org.mozilla.gecko.sync.Utils;
-import org.mozilla.gecko.sync.setup.SyncAccounts;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
 import java.security.GeneralSecurityException;
@@ -247,18 +247,17 @@ public class AccountsHelper implements N
                 return;
             }
 
             final String kind = message.optString("kind", null);
             final JSONObject response = new JSONObject();
 
             try {
                 if ("any".equals(kind)) {
-                    response.put("exists", SyncAccounts.syncAccountsExist(mContext) ||
-                            FirefoxAccounts.firefoxAccountsExist(mContext));
+                    response.put("exists", FirefoxAccounts.firefoxAccountsExist(mContext));
                     callback.sendSuccess(response);
                 } else if ("fxa".equals(kind)) {
                     final Account account = FirefoxAccounts.getFirefoxAccount(mContext);
                     response.put("exists", account != null);
                     if (account != null) {
                         response.put("email", account.name);
                         // We should always be able to extract the server endpoints.
                         final AndroidFxAccount fxAccount = new AndroidFxAccount(mContext, account);
@@ -272,19 +271,16 @@ public class AccountsHelper implements N
                             final State state = fxAccount.getState();
                             response.put("uid", state.uid);
                         } catch (Exception e) {
                             Log.w(LOGTAG, "Got exception extracting account UID; ignoring.", e);
                         }
                     }
 
                     callback.sendSuccess(response);
-                } else if ("sync11".equals(kind)) {
-                    response.put("exists", SyncAccounts.syncAccountsExist(mContext));
-                    callback.sendSuccess(response);
                 } else {
                     callback.sendError("Could not query account existence: unknown kind.");
                 }
             } catch (JSONException e) {
                 Log.w(LOGTAG, "Got exception querying account existence; ignoring.", e);
                 callback.sendError("Could not query account existence: " + e.toString());
                 return;
             }
--- a/mobile/android/modules/Accounts.jsm
+++ b/mobile/android/modules/Accounts.jsm
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["Accounts"];
 
 const { utils: Cu } = Components;
 
+Cu.import("resource://gre/modules/Deprecated.jsm"); /*global Deprecated */
 Cu.import("resource://gre/modules/Messaging.jsm"); /*global Messaging */
 Cu.import("resource://gre/modules/Promise.jsm"); /*global Promise */
 Cu.import("resource://gre/modules/Services.jsm"); /*global Services */
 
 /**
  * A promise-based API for querying the existence of Sync accounts,
  * and accessing the Sync setup wizard.
  *
@@ -39,17 +40,20 @@ var Accounts = Object.freeze({
     }).then(data => data.exists);
   },
 
   firefoxAccountsExist: function () {
     return this._accountsExist("fxa");
   },
 
   syncAccountsExist: function () {
-    return this._accountsExist("sync11");
+    Deprecated.warning("The legacy Sync account type has been removed from Firefox for Android. " +
+                       "Please use `firefoxAccountsExist` instead.",
+                       "https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/Accounts.jsm");
+    return Promise.resolve(false);
   },
 
   anySyncAccountsExist: function () {
     return this._accountsExist("any");
   },
 
   /**
    * Fire-and-forget: open the Firefox accounts activity, which