Fix crashes during skip SMS flow.
This commit is contained in:
parent
01351125f1
commit
1cffd88af2
5 changed files with 15 additions and 1 deletions
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.registration
|
|||
import org.thoughtcrime.securesms.pin.KeyBackupSystemWrongPinException
|
||||
import org.thoughtcrime.securesms.pin.TokenData
|
||||
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.IncorrectRegistrationRecoveryPasswordException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NoSuchSessionException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse
|
||||
|
@ -45,6 +46,10 @@ sealed class VerifyResponseProcessor(response: ServiceResponse<VerifyResponse>)
|
|||
return error is NonSuccessfulResponseCodeException
|
||||
}
|
||||
|
||||
fun isIncorrectRegistrationRecoveryPassword(): Boolean {
|
||||
return error is IncorrectRegistrationRecoveryPasswordException
|
||||
}
|
||||
|
||||
abstract fun isKbsLocked(): Boolean
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,9 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.pin_restore_entry_fra
|
|||
} else if (processor.isKbsLocked()) {
|
||||
Log.w(TAG, "Unable to continue skip flow, KBS is locked")
|
||||
onAccountLocked()
|
||||
} else if (processor.isIncorrectRegistrationRecoveryPassword()) {
|
||||
Log.w(TAG, "Registration recovery password was incorrect. Moving to SMS verification.")
|
||||
onSkipPinEntry()
|
||||
} else if (processor.isServerSentError()) {
|
||||
Log.i(TAG, "Error from server, not likely recoverable", processor.error)
|
||||
Toast.makeText(requireContext(), R.string.RegistrationActivity_error_connecting_to_service, Toast.LENGTH_LONG).show()
|
||||
|
|
|
@ -225,7 +225,7 @@ public final class RegistrationViewModel extends BaseRegistrationViewModel {
|
|||
registrationRepository.getProfileKey(getNumber().getE164Number()),
|
||||
getFcmToken(),
|
||||
registrationRepository.getPniRegistrationId(),
|
||||
getRecoveryPassword());
|
||||
getSessionId() != null ? null : getRecoveryPassword());
|
||||
}
|
||||
|
||||
public @NonNull Single<VerifyResponseProcessor> verifyReRegisterWithPin(@NonNull String pin) {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package org.whispersystems.signalservice.api.push.exceptions
|
||||
|
||||
class IncorrectRegistrationRecoveryPasswordException : NonSuccessfulResponseCodeException(403)
|
|
@ -68,6 +68,7 @@ import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionExc
|
|||
import org.whispersystems.signalservice.api.push.exceptions.ExpectationFailedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ExternalServiceFailureException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.HttpConflictException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.IncorrectRegistrationRecoveryPasswordException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.InvalidTransportModeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException;
|
||||
|
@ -2519,6 +2520,8 @@ public class PushServiceSocket {
|
|||
@Override
|
||||
public void handle(int responseCode, ResponseBody body) throws NonSuccessfulResponseCodeException, PushNetworkException {
|
||||
switch (responseCode) {
|
||||
case 403:
|
||||
throw new IncorrectRegistrationRecoveryPasswordException();
|
||||
case 404:
|
||||
throw new NoSuchSessionException();
|
||||
case 409:
|
||||
|
|
Loading…
Add table
Reference in a new issue