Bug 945341 - Don't fail to open Sync settings on Kindle. r=nalexander, a=lmandel
authorRichard Newman <rnewman@mozilla.com>
Tue, 08 Jul 2014 20:39:53 -0700
changeset 207943 10b0cd0433a6b1efaeb2f8a03719017f22a4e564
parent 207942 c66e5fd06de37b45bd36f8115d86c15c716ed8f6
child 207944 2a218b374b37ee265925a258e1559c35ef6a073f
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, lmandel
bugs945341
milestone32.0a2
Bug 945341 - Don't fail to open Sync settings on Kindle. r=nalexander, a=lmandel
mobile/android/base/preferences/SyncPreference.java
mobile/android/base/sync/setup/SyncAccounts.java
--- a/mobile/android/base/preferences/SyncPreference.java
+++ b/mobile/android/base/preferences/SyncPreference.java
@@ -22,16 +22,18 @@ class SyncPreference extends Preference 
     public SyncPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
         mContext = context;
     }
 
     private void openSync11Settings() {
         // Show Sync setup if no accounts exist; otherwise, show account settings.
         if (SyncAccounts.syncAccountsExist(mContext)) {
+            // We don't check for failure here. If you already have Sync set up,
+            // then there's nothing we can do.
             SyncAccounts.openSyncSettings(mContext);
             return;
         }
         Intent intent = new Intent(mContext, SetupSyncActivity.class);
         mContext.startActivity(intent);
     }
 
     private void launchFxASetup() {
@@ -46,17 +48,18 @@ class SyncPreference extends Preference 
         if (!DEFAULT_TO_FXA) {
             openSync11Settings();
             return;
         }
 
         // If there's a legacy Sync account (or a pickled one on disk),
         // open the settings page.
         if (SyncAccounts.syncAccountsExist(mContext)) {
-            SyncAccounts.openSyncSettings(mContext);
-            return;
+            if (SyncAccounts.openSyncSettings(mContext) != null) {
+                return;
+            }
         }
 
         // Otherwise, launch the FxA "Get started" activity, which will
         // dispatch to the right location.
         launchFxASetup();
     }
 }
--- a/mobile/android/base/sync/setup/SyncAccounts.java
+++ b/mobile/android/base/sync/setup/SyncAccounts.java
@@ -387,31 +387,38 @@ public class SyncAccounts {
     return null;
   }
 
   /**
    * Start Sync settings activity.
    *
    * @param context
    *          current Android context.
-   * @return the <code>Intent</code> started.
+   * @return the <code>Intent</code> started, or null if we couldn't start settings.
    */
   public static Intent openSyncSettings(Context context) {
     // Bug 721760 - opening Sync settings takes user to Battery & Data Manager
     // on a variety of Motorola devices. This work around tries to load the
     // correct Intent by hand. Oh, Android.
     Intent intent = openVendorSyncSettings(context, MOTO_BLUR_PACKAGE, MOTO_BLUR_SETTINGS_ACTIVITY);
     if (intent != null) {
       return intent;
     }
 
     // Open default Sync settings activity.
     intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
     // Bug 774233: do not start activity as a new task (second run fails on some HTC devices).
-    context.startActivity(intent); // We should always find this Activity.
+    try {
+      context.startActivity(intent); // We should always find this Activity.
+    } catch (ActivityNotFoundException ex) {
+      // We're probably on a Kindle, and the user hasn't installed the Android
+      // settings app. See Bug 945341.
+      // We simply mute the error.
+      return null;
+    }
     return intent;
   }
 
   /**
    * Synchronously extract Sync account parameters from Android account version
    * 0, using plain auth token type.
    * <p>
    * Safe to call from main thread.