diff --git a/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java b/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java index 5706b23b4..169463397 100644 --- a/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java +++ b/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java @@ -12,6 +12,7 @@ import android.text.TextUtils; import android.util.Log; import com.google.android.gcm.GCMBaseIntentService; +import com.google.android.gcm.GCMConstants; import com.google.android.gcm.GCMRegistrar; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.Autowired; @@ -55,6 +56,7 @@ public class GCMIntentService extends GCMBaseIntentService { public static final String SENDER_ID = "1003855277730"; //$NON-NLS-1$ public static final String PREF_REGISTRATION = "gcm_id"; public static final String PREF_NEEDS_REGISTRATION = "gcm_needs_reg"; + public static final String PREF_NEEDS_RETRY = "gcm_needs_retry"; private static final String PREF_LAST_GCM = "c2dm_last"; public static final String PREF_C2DM_REGISTRATION = "c2dm_key"; @@ -407,7 +409,10 @@ public class GCMIntentService extends GCMBaseIntentService { @Override protected void onError(Context context, String intent) { - // Unrecoverable + if ((GCMConstants.ERROR_AUTHENTICATION_FAILED.equals(intent) || GCMConstants.ERROR_ACCOUNT_MISSING.equals(intent)) + && !Preferences.getBoolean(PREF_NEEDS_RETRY, false)) { + Preferences.setBoolean(PREF_NEEDS_RETRY, true); + } } // =========== Migration ============= // diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java index 018a88644..3280e0097 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java @@ -138,6 +138,7 @@ public final class ActFmSyncService { Preferences.setString(GCMIntentService.PREF_REGISTRATION, regId); Preferences.setString(GCMIntentService.PREF_C2DM_REGISTRATION, null); Preferences.setString(GCMIntentService.PREF_NEEDS_REGISTRATION, null); + Preferences.setBoolean(GCMIntentService.PREF_NEEDS_RETRY, false); } catch (IOException e) { Preferences.setString(GCMIntentService.PREF_NEEDS_REGISTRATION, regId); Log.e("gcm", "error-gcm-register", e); diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java index 4dfac69d3..ca3843fbb 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java @@ -106,6 +106,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider { public void updateUserStatus() { if (Preferences.getStringValue(GCMIntentService.PREF_NEEDS_REGISTRATION) != null) { actFmSyncService.setGCMRegistration(Preferences.getStringValue(GCMIntentService.PREF_NEEDS_REGISTRATION)); + } else if (Preferences.getBoolean(GCMIntentService.PREF_NEEDS_RETRY, false)) { + GCMIntentService.register(ContextManager.getContext()); } if (Preferences.getBoolean(BillingConstants.PREF_NEEDS_SERVER_UPDATE, false)) {