Increase logging during registration.

This commit is contained in:
Nicholas Tinsley
2023-10-24 09:34:55 -04:00
committed by Cody Henthorne
parent 87bdebb21c
commit a45c685893
4 changed files with 39 additions and 16 deletions

View File

@@ -226,9 +226,11 @@ public final class RegistrationRepository {
public Single<BackupAuthCheckProcessor> getSvrAuthCredential(@NonNull RegistrationData registrationData, List<String> usernamePasswords) {
SignalServiceAccountManager accountManager = AccountManagerFactory.getInstance().createUnauthenticated(context, registrationData.getE164(), SignalServiceAddress.DEFAULT_DEVICE_ID, registrationData.getPassword());
Log.d(TAG, "Fetching SVR backup credentials.");
return accountManager.checkBackupAuthCredentials(registrationData.getE164(), usernamePasswords)
.map(BackupAuthCheckProcessor::new)
.doOnSuccess(processor -> {
Log.d(TAG, "Received SVR backup auth credential response.");
if (SignalStore.svr().removeAuthTokens(processor.getInvalid())) {
new BackupManager(context).dataChanged();
}

View File

@@ -11,6 +11,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ScrollView;
import androidx.annotation.NonNull;
@@ -204,13 +205,13 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
private void onE164EnteredSuccessfully(@NonNull Context context, boolean fcmSupported) {
enterInProgressUiState();
Log.d(TAG, "E164 entered successfully.");
Disposable disposable = viewModel.canEnterSkipSmsFlow()
.observeOn(AndroidSchedulers.mainThread())
.onErrorReturnItem(false)
.subscribe(canEnter -> {
if (canEnter) {
Log.i(TAG, "Enter skip flow");
Log.i(TAG, "Entering skip flow.");
SafeNavigation.safeNavigate(NavHostFragment.findNavController(this), EnterPhoneNumberFragmentDirections.actionReRegisterWithPinFragment());
} else {
Log.i(TAG, "Unable to collect necessary data to enter skip flow, returning to normal");
@@ -452,6 +453,7 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
}
private void handlePromptForNoPlayServices(@NonNull Context context) {
Log.d(TAG, "Device does not have Play Services, showing consent dialog.");
new MaterialAlertDialogBuilder(context)
.setTitle(R.string.RegistrationActivity_missing_google_play_services)
.setMessage(R.string.RegistrationActivity_this_device_is_missing_google_play_services)
@@ -469,20 +471,31 @@ public final class EnterPhoneNumberFragment extends LoggingFragment implements R
disposables.add(
viewModel.canEnterSkipSmsFlow()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(canSkipSms -> showConfirmNumberDialogIfTranslated(context,
viewModel.hasUserSkippedReRegisterFlow() ? R.string.RegistrationActivity_additional_verification_required
: R.string.RegistrationActivity_phone_number_verification_dialog_title,
canSkipSms ? null
: R.string.RegistrationActivity_a_verification_code_will_be_sent_to_this_number,
e164number,
() -> {
ViewUtil.hideKeyboard(context, number.getEditText());
onConfirmed.run();
},
() -> {
exitInProgressUiState();
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(this.number.getEditText());
}))
.subscribe(canSkipSms -> {
Log.d(TAG, "Showing confirm number dialog. canSkipSms = " + canSkipSms + " hasUserSkipped = " + viewModel.hasUserSkippedReRegisterFlow());
final EditText editText = this.number.getEditText();
showConfirmNumberDialogIfTranslated(context,
viewModel.hasUserSkippedReRegisterFlow() ? R.string.RegistrationActivity_additional_verification_required
: R.string.RegistrationActivity_phone_number_verification_dialog_title,
canSkipSms ? null
: R.string.RegistrationActivity_a_verification_code_will_be_sent_to_this_number,
e164number,
() -> {
Log.d(TAG, "User confirmed number.");
if (editText != null) {
ViewUtil.hideKeyboard(context, editText);
}
onConfirmed.run();
},
() -> {
Log.d(TAG, "User canceled confirm number, returning to edit number.");
exitInProgressUiState();
if (editText != null) {
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(editText);
}
});
}
)
);
}
}

View File

@@ -182,6 +182,7 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.pin_restore_entry_fra
}
private fun onAccountLocked() {
Log.d(TAG, "Showing Incorrect PIN dialog. Is local verification: ${reRegisterViewModel.isLocalVerification}")
val message = if (reRegisterViewModel.isLocalVerification) R.string.ReRegisterWithPinFragment_out_of_guesses_local else R.string.PinRestoreLockedFragment_youve_run_out_of_pin_guesses
MaterialAlertDialogBuilder(requireContext())
@@ -243,6 +244,7 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.pin_restore_entry_fra
}
private fun onSkipPinEntry() {
Log.d(TAG, "User skipping PIN entry.")
registrationViewModel.setUserSkippedReRegisterFlow(true)
findNavController().safeNavigate(R.id.action_reRegisterWithPinFragment_to_enterPhoneNumberFragment)
}

View File

@@ -336,9 +336,11 @@ public final class RegistrationViewModel extends BaseRegistrationViewModel {
public @NonNull Single<Boolean> canEnterSkipSmsFlow() {
if (userSkippedReRegisterFlow) {
Log.d(TAG, "User skipped re-register flow.");
return Single.just(false);
}
Log.d(TAG, "Querying if user can enter skip SMS flow.");
return Single.just(hasRecoveryPassword())
.flatMap(hasRecoveryPassword -> {
Log.i(TAG, "Checking if user has existing recovery password: " + hasRecoveryPassword);
@@ -365,15 +367,19 @@ public final class RegistrationViewModel extends BaseRegistrationViewModel {
.collect(Collectors.toList());
if (usernamePasswords.isEmpty()) {
Log.d(TAG, "No valid SVR tokens in local store.");
return Single.just(false);
}
Log.d(TAG, "Valid tokens in local store, validating with SVR.");
return registrationRepository.getSvrAuthCredential(getRegistrationData(), usernamePasswords)
.flatMap(p -> {
if (p.hasValidSvr2AuthCredential()) {
Log.d(TAG, "Saving valid SVR2 auth credential.");
setSvrAuthCredentials(new SvrAuthCredentialSet(null, p.requireSvr2AuthCredential()));
return Single.just(true);
} else {
Log.d(TAG, "SVR2 response contained no valid SVR2 auth credentials.");
return Single.just(false);
}
})