Skip to content

Commit

Permalink
Prevent some crash loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Apr 24, 2020
1 parent 7db288b commit 5193a5d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Expand Up @@ -100,6 +100,10 @@ public void onAdded() {

@Override
public void onRun() {
if (TextSecurePreferences.getLocalUuid(context) == null && TextSecurePreferences.getLocalNumber(context) == null) {
throw new NotReadyException();
}

MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
Optional<MmsDatabase.MmsNotificationInfo> notification = database.getNotification(messageId);

Expand Down Expand Up @@ -265,4 +269,7 @@ public static final class Factory implements Job.Factory<MmsDownloadJob> {
data.getBoolean(KEY_AUTOMATIC));
}
}

private static class NotReadyException extends RuntimeException {
}
}
Expand Up @@ -49,7 +49,7 @@ private RefreshAttributesJob(@NonNull Job.Parameters parameters) {

@Override
public void onRun() throws IOException {
if (!TextSecurePreferences.isPushRegistered(context)) {
if (!TextSecurePreferences.isPushRegistered(context) || TextSecurePreferences.getLocalNumber(context) == null) {
Log.w(TAG, "Not yet registered. Skipping.");
return;
}
Expand Down
Expand Up @@ -170,6 +170,6 @@ public static final class Factory implements Job.Factory<SmsReceiveJob> {
}
}

private class NotReadyException extends RuntimeException {
private static class NotReadyException extends RuntimeException {
}
}

0 comments on commit 5193a5d

Please sign in to comment.