Bug 1036459. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Wed, 09 Jul 2014 13:41:58 -0700
changeset 193278 81ba79c9c36e3bc49eee5a5ce3ba297b52bf78b6
parent 193277 a19387ced68e283a62090a0fa3e7bfcd13c647e8
child 193279 91ce45738633f9b301124300a1bd8d94f27abec8
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersnalexander
bugs1036459
milestone33.0a1
Bug 1036459. r=nalexander
mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java
--- a/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java
+++ b/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java
@@ -11,17 +11,17 @@ import android.content.Intent;
 import android.os.IBinder;
 
 public class FxAccountAuthenticatorService extends Service {
   public static final String LOG_TAG = FxAccountAuthenticatorService.class.getSimpleName();
 
   // Lazily initialized by <code>getAuthenticator</code>.
   protected FxAccountAuthenticator accountAuthenticator = null;
 
-  protected FxAccountAuthenticator getAuthenticator() {
+  protected synchronized FxAccountAuthenticator getAuthenticator() {
     if (accountAuthenticator == null) {
       accountAuthenticator = new FxAccountAuthenticator(this);
     }
 
     return accountAuthenticator;
   }
 
   @Override
@@ -30,15 +30,26 @@ public class FxAccountAuthenticatorServi
 
     accountAuthenticator = getAuthenticator();
   }
 
   @Override
   public IBinder onBind(Intent intent) {
     Logger.debug(LOG_TAG, "onBind");
 
-    if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) {
-      return getAuthenticator().getIBinder();
+    if (intent == null) {
+      // Should never happen, but can -- Bug 1025937.
+      return null;
+    }
+
+    if (!android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) {
+      return null;
     }
 
-    return null;
+    final FxAccountAuthenticator authenticator = getAuthenticator();
+    if (authenticator == null) {
+      // Should never happen.
+      return null;
+    }
+
+    return authenticator.getIBinder();
   }
 }