|
|
@ -34,13 +34,13 @@ public abstract class PushSendJob extends MasterSecretJob {
|
|
|
|
super(context, parameters);
|
|
|
|
super(context, parameters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected static JobParameters constructParameters(Context context, String destination) {
|
|
|
|
protected static JobParameters constructParameters(Context context, String destination, boolean media) {
|
|
|
|
JobParameters.Builder builder = JobParameters.newBuilder();
|
|
|
|
JobParameters.Builder builder = JobParameters.newBuilder();
|
|
|
|
builder.withPersistence();
|
|
|
|
builder.withPersistence();
|
|
|
|
builder.withGroupId(destination);
|
|
|
|
builder.withGroupId(destination);
|
|
|
|
builder.withRequirement(new MasterSecretRequirement(context));
|
|
|
|
builder.withRequirement(new MasterSecretRequirement(context));
|
|
|
|
|
|
|
|
|
|
|
|
if (!isSmsFallbackSupported(context, destination)) {
|
|
|
|
if (!isSmsFallbackSupported(context, destination, media)) {
|
|
|
|
builder.withRequirement(new NetworkRequirement(context));
|
|
|
|
builder.withRequirement(new NetworkRequirement(context));
|
|
|
|
builder.withRetryCount(5);
|
|
|
|
builder.withRetryCount(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -48,7 +48,7 @@ public abstract class PushSendJob extends MasterSecretJob {
|
|
|
|
return builder.create();
|
|
|
|
return builder.create();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected static boolean isSmsFallbackSupported(Context context, String destination) {
|
|
|
|
protected static boolean isSmsFallbackSupported(Context context, String destination, boolean media) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String e164number = Util.canonicalizeNumber(context, destination);
|
|
|
|
String e164number = Util.canonicalizeNumber(context, destination);
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +60,10 @@ public abstract class PushSendJob extends MasterSecretJob {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (media && !TextSecurePreferences.isFallbackMmsEnabled(context)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
|
|
|
|
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
|
|
|
|
return directory.isSmsFallbackSupported(e164number);
|
|
|
|
return directory.isSmsFallbackSupported(e164number);
|
|
|
|
} catch (InvalidNumberException e) {
|
|
|
|
} catch (InvalidNumberException e) {
|
|
|
@ -74,8 +78,8 @@ public abstract class PushSendJob extends MasterSecretJob {
|
|
|
|
return new PushAddress(recipient.getRecipientId(), e164number, 1, relay);
|
|
|
|
return new PushAddress(recipient.getRecipientId(), e164number, 1, relay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean isSmsFallbackApprovalRequired(String destination) {
|
|
|
|
protected boolean isSmsFallbackApprovalRequired(String destination, boolean media) {
|
|
|
|
return (isSmsFallbackSupported(context, destination) && TextSecurePreferences.isFallbackSmsAskRequired(context));
|
|
|
|
return (isSmsFallbackSupported(context, destination, media) && TextSecurePreferences.isFallbackSmsAskRequired(context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected List<TextSecureAttachment> getAttachments(SendReq message) {
|
|
|
|
protected List<TextSecureAttachment> getAttachments(SendReq message) {
|
|
|
|