mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
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:
@@ -16,9 +16,7 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms.service;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -28,14 +26,14 @@ public class VerificationCodeParser {
|
||||
|
||||
private static final Pattern CHALLENGE_PATTERN = Pattern.compile("(.*\\D|^)([0-9]{3,4})-([0-9]{3,4}).*", Pattern.DOTALL);
|
||||
|
||||
public static Optional<String> parse(Context context, String messageBody) {
|
||||
public static Optional<String> parse(String messageBody) {
|
||||
if (messageBody == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody);
|
||||
|
||||
if (!challengeMatcher.matches() || !TextSecurePreferences.isVerifying(context)) {
|
||||
if (!challengeMatcher.matches()) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user