From 58406d6b37008af668d9e362daa652dad7ba025b Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Tue, 3 Nov 2015 14:45:49 -0800 Subject: [PATCH] Consider unregister successfull on 401 from RP server. Fixes #4362 // FREEBIE --- .../AdvancedPreferenceFragment.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index c16c711ae9..b0531d735b 100644 --- a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -21,6 +21,7 @@ import com.google.android.gms.gcm.GoogleCloudMessaging; import org.thoughtcrime.redphone.signaling.RedPhoneAccountManager; import org.thoughtcrime.redphone.signaling.RedPhoneTrustStore; +import org.thoughtcrime.redphone.signaling.UnauthorizedException; import org.thoughtcrime.securesms.ApplicationPreferencesActivity; import org.thoughtcrime.securesms.BuildConfig; import org.thoughtcrime.securesms.LogSubmitActivity; @@ -184,13 +185,20 @@ public class AdvancedPreferenceFragment extends PreferenceFragment { TextSecurePreferences.getLocalNumber(context), TextSecurePreferences.getPushServerPassword(context)); - accountManager.setGcmId(Optional.absent()); - redPhoneAccountManager.setGcmId(Optional.absent()); + try { + accountManager.setGcmId(Optional.absent()); + } catch (AuthorizationFailedException e) { + Log.w(TAG, e); + } + + try { + redPhoneAccountManager.setGcmId(Optional.absent()); + } catch (UnauthorizedException e) { + Log.w(TAG, e); + } + GoogleCloudMessaging.getInstance(context).unregister(); - return SUCCESS; - } catch (AuthorizationFailedException afe) { - Log.w(TAG, afe); return SUCCESS; } catch (IOException ioe) { Log.w(TAG, ioe);