Consider unregistered if authorization fails.

This should only occur if another device has registered with the
same number, effectively making the current device unregistered.
pull/1/head
Moxie Marlinspike 12 years ago
parent 03ff55db97
commit cfb7b8fcba

@ -0,0 +1,9 @@
package org.whispersystems.textsecure.push;
import java.io.IOException;
public class AuthorizationFailedException extends IOException {
public AuthorizationFailedException(String s) {
super(s);
}
}

@ -269,6 +269,10 @@ public class PushServiceSocket {
throw new RateLimitException("Rate limit exceeded: " + connection.getResponseCode());
}
if (connection.getResponseCode() == 403) {
throw new AuthorizationFailedException("Authorization failed!");
}
if (connection.getResponseCode() != 200) {
throw new IOException("Bad response: " + connection.getResponseCode() + " " + connection.getResponseMessage());
}

@ -56,6 +56,7 @@ import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Trimmer;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.textsecure.push.AuthorizationFailedException;
import org.whispersystems.textsecure.push.PushServiceSocket;
import java.io.IOException;
@ -358,8 +359,11 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
socket.unregisterGcmId();
GCMRegistrar.unregister(context);
return SUCCESS;
} catch (IOException e) {
Log.w("ApplicationPreferencesActivity", e);
} catch (AuthorizationFailedException afe) {
Log.w("ApplicationPreferencesActivity", afe);
return SUCCESS;
} catch (IOException ioe) {
Log.w("ApplicationPreferencesActivity", ioe);
return NETWORK_ERROR;
}
}

Loading…
Cancel
Save