mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-27 14:40:22 +00:00
Handle SmsRetriever initialization cancellation.
This commit is contained in:
committed by
Nicholas
parent
f961f4ccac
commit
05f07d1788
@@ -77,19 +77,24 @@ class VerifyAccountRepository(private val context: Application) {
|
||||
return response
|
||||
}
|
||||
|
||||
subscriber.latch.await(PUSH_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
|
||||
val receivedPush = subscriber.latch.await(PUSH_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
eventBus.unregister(subscriber)
|
||||
|
||||
val challenge = subscriber.challenge
|
||||
|
||||
return if (challenge != null) {
|
||||
accountManager.submitPushChallengeToken(response.result.get().body.id, challenge)
|
||||
if (receivedPush) {
|
||||
val challenge = subscriber.challenge
|
||||
if (challenge != null) {
|
||||
Log.w(TAG, "Push challenge token received.")
|
||||
return accountManager.submitPushChallengeToken(response.result.get().body.id, challenge)
|
||||
} else {
|
||||
Log.w(TAG, "Push received but challenge token was null.")
|
||||
}
|
||||
} else {
|
||||
val registrationSessionState = RegistrationSessionState(pushChallengeTimedOut = true)
|
||||
val rawResponse: RegistrationSessionMetadataResponse = response.result.get()
|
||||
ServiceResponse.forResult(rawResponse.copy(state = registrationSessionState), 200, null)
|
||||
Log.i(TAG, "Push challenge timed out.")
|
||||
}
|
||||
Log.i(TAG, "Push challenge unsuccessful. Updating registration state accordingly.")
|
||||
val registrationSessionState = RegistrationSessionState(pushChallengeTimedOut = true)
|
||||
val rawResponse: RegistrationSessionMetadataResponse = response.result.get()
|
||||
return ServiceResponse.forResult(rawResponse.copy(state = registrationSessionState), 200, null)
|
||||
}
|
||||
|
||||
fun requestAndVerifyPushToken(
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
|
||||
import org.signal.core.util.ThreadUtil;
|
||||
import org.signal.core.util.concurrent.LifecycleDisposable;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.LoggingFragment;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -46,7 +47,6 @@ import org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
import org.thoughtcrime.securesms.util.Debouncer;
|
||||
import org.thoughtcrime.securesms.util.Dialogs;
|
||||
import org.signal.core.util.concurrent.LifecycleDisposable;
|
||||
import org.thoughtcrime.securesms.util.PlayServicesUtil;
|
||||
import org.thoughtcrime.securesms.util.SupportEmailUtil;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
@@ -252,6 +252,17 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
|
||||
}
|
||||
debouncer.clear();
|
||||
});
|
||||
|
||||
task.addOnCanceledListener(() -> {
|
||||
if (!handled.getAndSet(true)) {
|
||||
Log.w(TAG, "SMS listener registration canceled.");
|
||||
requestVerificationCode(Mode.SMS_WITHOUT_LISTENER);
|
||||
} else {
|
||||
Log.w(TAG, "SMS listener registration canceled after timeout.");
|
||||
}
|
||||
debouncer.clear();
|
||||
});
|
||||
|
||||
} else {
|
||||
Log.i(TAG, "FCM is not supported, using no SMS listener");
|
||||
requestVerificationCode(Mode.SMS_WITHOUT_LISTENER);
|
||||
|
||||
Reference in New Issue
Block a user