Fix crashes during skip SMS flow.

main
Cody Henthorne 2023-02-23 08:18:08 -05:00
rodzic 01351125f1
commit 1cffd88af2
5 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.registration
import org.thoughtcrime.securesms.pin.KeyBackupSystemWrongPinException import org.thoughtcrime.securesms.pin.KeyBackupSystemWrongPinException
import org.thoughtcrime.securesms.pin.TokenData import org.thoughtcrime.securesms.pin.TokenData
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException 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.NoSuchSessionException
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException
import org.whispersystems.signalservice.internal.ServiceResponse import org.whispersystems.signalservice.internal.ServiceResponse
@ -45,6 +46,10 @@ sealed class VerifyResponseProcessor(response: ServiceResponse<VerifyResponse>)
return error is NonSuccessfulResponseCodeException return error is NonSuccessfulResponseCodeException
} }
fun isIncorrectRegistrationRecoveryPassword(): Boolean {
return error is IncorrectRegistrationRecoveryPasswordException
}
abstract fun isKbsLocked(): Boolean abstract fun isKbsLocked(): Boolean
} }

Wyświetl plik

@ -137,6 +137,9 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.pin_restore_entry_fra
} else if (processor.isKbsLocked()) { } else if (processor.isKbsLocked()) {
Log.w(TAG, "Unable to continue skip flow, KBS is locked") Log.w(TAG, "Unable to continue skip flow, KBS is locked")
onAccountLocked() onAccountLocked()
} else if (processor.isIncorrectRegistrationRecoveryPassword()) {
Log.w(TAG, "Registration recovery password was incorrect. Moving to SMS verification.")
onSkipPinEntry()
} else if (processor.isServerSentError()) { } else if (processor.isServerSentError()) {
Log.i(TAG, "Error from server, not likely recoverable", processor.error) 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() Toast.makeText(requireContext(), R.string.RegistrationActivity_error_connecting_to_service, Toast.LENGTH_LONG).show()

Wyświetl plik

@ -225,7 +225,7 @@ public final class RegistrationViewModel extends BaseRegistrationViewModel {
registrationRepository.getProfileKey(getNumber().getE164Number()), registrationRepository.getProfileKey(getNumber().getE164Number()),
getFcmToken(), getFcmToken(),
registrationRepository.getPniRegistrationId(), registrationRepository.getPniRegistrationId(),
getRecoveryPassword()); getSessionId() != null ? null : getRecoveryPassword());
} }
public @NonNull Single<VerifyResponseProcessor> verifyReRegisterWithPin(@NonNull String pin) { public @NonNull Single<VerifyResponseProcessor> verifyReRegisterWithPin(@NonNull String pin) {

Wyświetl plik

@ -0,0 +1,3 @@
package org.whispersystems.signalservice.api.push.exceptions
class IncorrectRegistrationRecoveryPasswordException : NonSuccessfulResponseCodeException(403)

Wyświetl plik

@ -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.ExpectationFailedException;
import org.whispersystems.signalservice.api.push.exceptions.ExternalServiceFailureException; import org.whispersystems.signalservice.api.push.exceptions.ExternalServiceFailureException;
import org.whispersystems.signalservice.api.push.exceptions.HttpConflictException; 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.InvalidTransportModeException;
import org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException; import org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException;
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException; import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException;
@ -2519,6 +2520,8 @@ public class PushServiceSocket {
@Override @Override
public void handle(int responseCode, ResponseBody body) throws NonSuccessfulResponseCodeException, PushNetworkException { public void handle(int responseCode, ResponseBody body) throws NonSuccessfulResponseCodeException, PushNetworkException {
switch (responseCode) { switch (responseCode) {
case 403:
throw new IncorrectRegistrationRecoveryPasswordException();
case 404: case 404:
throw new NoSuchSessionException(); throw new NoSuchSessionException();
case 409: case 409: