Bug 1231549 - Set default profile endpoint server URI for Firefox Accounts not created via the web flow. r=nalexander
authordlim <daniel9618@gmail.com>
Tue, 23 Feb 2016 13:03:33 -0800
changeset 285516 0ed2152fd50bd4655adf35c77e26ab64c15181a1
parent 285515 e38a16b7d37e848ace544aa45c8ccebb3d0411c5
child 285517 418bf315261c3a3bd1e6a53cb653195439dc9091
push id72403
push usercbook@mozilla.com
push dateThu, 25 Feb 2016 10:59:17 +0000
treeherdermozilla-inbound@3b913f81cb98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1231549
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1231549 - Set default profile endpoint server URI for Firefox Accounts not created via the web flow. r=nalexander
mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java
--- 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
@@ -288,28 +288,39 @@ public class AndroidFxAccount {
     return accountManager.getUserData(account, ACCOUNT_KEY_IDP_SERVER);
   }
 
   public String getTokenServerURI() {
     return accountManager.getUserData(account, ACCOUNT_KEY_TOKEN_SERVER);
   }
 
   public String getProfileServerURI() {
-    return accountManager.getUserData(account, ACCOUNT_KEY_PROFILE_SERVER);
+    String profileURI = accountManager.getUserData(account, ACCOUNT_KEY_PROFILE_SERVER);
+    if (profileURI == null) {
+      if (isStaging()) {
+        return FxAccountConstants.STAGE_PROFILE_SERVER_ENDPOINT;
+      }
+      return FxAccountConstants.DEFAULT_PROFILE_SERVER_ENDPOINT;
+    }
+    return profileURI;
   }
 
   public String getOAuthServerURI() {
     // Allow testing against stage.
-    if (FxAccountConstants.STAGE_AUTH_SERVER_ENDPOINT.equals(getAccountServerURI())) {
+    if (isStaging()) {
       return FxAccountConstants.STAGE_OAUTH_SERVER_ENDPOINT;
     } else {
       return FxAccountConstants.DEFAULT_OAUTH_SERVER_ENDPOINT;
     }
   }
 
+  private boolean isStaging() {
+    return FxAccountConstants.STAGE_AUTH_SERVER_ENDPOINT.equals(getAccountServerURI());
+  }
+
   private String constructPrefsPath(String product, long version, String extra) throws GeneralSecurityException, UnsupportedEncodingException {
     String profile = getProfile();
     String username = account.name;
 
     if (profile == null) {
       throw new IllegalStateException("Missing profile. Cannot fetch prefs.");
     }