Fix crash when receiving SMS before finishing registration.

If someone has set Signal as the default SMS but has cleared data or
otherwise reset the app's storage state, it can get into a weird
situation. Notably, it'll crash because SmsReceiveJob.onRun() expects
Recipient.self() to be available.

However, it also makes it impossible to get the registration SMS,
because the app won't post a notification for the code.

This change will post notifications and SmsRetriever broadcasts for
relevant SMS messages.
This commit is contained in:
Greyson Parrelli
2020-09-21 10:26:22 -04:00
parent b471a72856
commit 97b7b4a501
8 changed files with 77 additions and 29 deletions

View File

@@ -77,7 +77,7 @@ public final class RegistrationNavigationActivity extends AppCompatActivity {
switch (status.getStatusCode()) {
case CommonStatusCodes.SUCCESS:
Optional<String> code = VerificationCodeParser.parse(context, (String) extras.get(SmsRetriever.EXTRA_SMS_MESSAGE));
Optional<String> code = VerificationCodeParser.parse((String) extras.get(SmsRetriever.EXTRA_SMS_MESSAGE));
if (code.isPresent()) {
Log.i(TAG, "Received verification code.");
handleVerificationCodeReceived(code.get());

View File

@@ -258,7 +258,6 @@ public final class CodeVerificationRequest {
identityKey.getPublicKey(), IdentityDatabase.VerifiedStatus.VERIFIED,
true, System.currentTimeMillis(), true);
TextSecurePreferences.setVerifying(context, false);
TextSecurePreferences.setPushRegistered(context, true);
TextSecurePreferences.setPushServerPassword(context, credentials.getPassword());
TextSecurePreferences.setSignedPreKeyRegistered(context, true);

View File

@@ -77,8 +77,6 @@ public final class RegistrationCodeRequest {
}
private static void markAsVerifying(Context context) {
TextSecurePreferences.setVerifying(context, true);
TextSecurePreferences.setPushRegistered(context, false);
}