mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 23:03:46 +00:00
Add missing MSISDN headers to MMS send request
Fixes #1935 Fixes #2451 Closes #2605 // FREEBIE
This commit is contained in:
parent
0b8430ff43
commit
b998c5f86c
@ -24,6 +24,7 @@ import org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException;
|
|||||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||||
import org.thoughtcrime.securesms.util.Hex;
|
import org.thoughtcrime.securesms.util.Hex;
|
||||||
import org.thoughtcrime.securesms.util.NumberUtil;
|
import org.thoughtcrime.securesms.util.NumberUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
||||||
import org.whispersystems.jobqueue.JobParameters;
|
import org.whispersystems.jobqueue.JobParameters;
|
||||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||||
import org.whispersystems.libaxolotl.NoSessionException;
|
import org.whispersystems.libaxolotl.NoSessionException;
|
||||||
@ -146,7 +147,7 @@ public class MmsSendJob extends SendJob {
|
|||||||
boolean usingMmsRadio, boolean useProxy)
|
boolean usingMmsRadio, boolean useProxy)
|
||||||
throws IOException, UndeliverableMessageException, InsecureFallbackApprovalException
|
throws IOException, UndeliverableMessageException, InsecureFallbackApprovalException
|
||||||
{
|
{
|
||||||
String number = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
|
String number = TelephonyUtil.getManager(context).getLine1Number();
|
||||||
boolean upgradedSecure = false;
|
boolean upgradedSecure = false;
|
||||||
|
|
||||||
prepareMessageMedia(masterSecret, message, MediaConstraints.MMS_CONSTRAINTS, true);
|
prepareMessageMedia(masterSecret, message, MediaConstraints.MMS_CONSTRAINTS, true);
|
||||||
|
@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.apache.http.Header;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.HttpGetHC4;
|
import org.apache.http.client.methods.HttpGetHC4;
|
||||||
@ -41,7 +42,9 @@ public class IncomingMmsConnection extends MmsConnection {
|
|||||||
@Override
|
@Override
|
||||||
protected HttpUriRequest constructRequest(boolean useProxy) throws IOException {
|
protected HttpUriRequest constructRequest(boolean useProxy) throws IOException {
|
||||||
HttpGetHC4 request = new HttpGetHC4(apn.getMmsc());
|
HttpGetHC4 request = new HttpGetHC4(apn.getMmsc());
|
||||||
request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
|
for (Header header : getBaseHeaders()) {
|
||||||
|
request.addHeader(header);
|
||||||
|
}
|
||||||
if (useProxy) {
|
if (useProxy) {
|
||||||
HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
|
HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
|
||||||
request.setConfig(RequestConfig.custom().setProxy(proxy).build());
|
request.setConfig(RequestConfig.custom().setProxy(proxy).build());
|
||||||
|
@ -21,6 +21,7 @@ import android.net.ConnectivityManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.apache.http.Header;
|
||||||
import org.apache.http.auth.AuthScope;
|
import org.apache.http.auth.AuthScope;
|
||||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||||
import org.apache.http.client.CredentialsProvider;
|
import org.apache.http.client.CredentialsProvider;
|
||||||
@ -33,6 +34,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.impl.client.LaxRedirectStrategy;
|
import org.apache.http.impl.client.LaxRedirectStrategy;
|
||||||
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
|
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.thoughtcrime.securesms.database.ApnDatabase;
|
import org.thoughtcrime.securesms.database.ApnDatabase;
|
||||||
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
import org.thoughtcrime.securesms.util.Conversions;
|
||||||
@ -45,6 +47,8 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class MmsConnection {
|
public abstract class MmsConnection {
|
||||||
private static final String TAG = "MmsCommunication";
|
private static final String TAG = "MmsCommunication";
|
||||||
@ -168,6 +172,22 @@ public abstract class MmsConnection {
|
|||||||
|
|
||||||
protected abstract HttpUriRequest constructRequest(boolean useProxy) throws IOException;
|
protected abstract HttpUriRequest constructRequest(boolean useProxy) throws IOException;
|
||||||
|
|
||||||
|
protected List<Header> getBaseHeaders() {
|
||||||
|
final String number = TelephonyUtil.getManager(context).getLine1Number();
|
||||||
|
return new LinkedList<Header>() {{
|
||||||
|
add(new BasicHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic"));
|
||||||
|
add(new BasicHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml"));
|
||||||
|
add(new BasicHeader("Content-Type", "application/vnd.wap.mms-message"));
|
||||||
|
add(new BasicHeader("x-carrier-magic", "http://magic.google.com"));
|
||||||
|
if (!TextUtils.isEmpty(number)) {
|
||||||
|
add(new BasicHeader("x-up-calling-line-id", number));
|
||||||
|
add(new BasicHeader("X-MDN", number));
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class Apn {
|
public static class Apn {
|
||||||
|
|
||||||
public static Apn EMPTY = new Apn("", "", "", "", "");
|
public static Apn EMPTY = new Apn("", "", "", "", "");
|
||||||
|
@ -20,13 +20,18 @@ import android.content.Context;
|
|||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.apache.http.Header;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.HttpPostHC4;
|
import org.apache.http.client.methods.HttpPostHC4;
|
||||||
import org.apache.http.client.methods.HttpUriRequest;
|
import org.apache.http.client.methods.HttpUriRequest;
|
||||||
import org.apache.http.entity.ByteArrayEntityHC4;
|
import org.apache.http.entity.ByteArrayEntityHC4;
|
||||||
|
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -49,9 +54,10 @@ public class OutgoingMmsConnection extends MmsConnection {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
HttpPostHC4 request = new HttpPostHC4(apn.getMmsc());
|
HttpPostHC4 request = new HttpPostHC4(apn.getMmsc());
|
||||||
request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
|
for (Header header : getBaseHeaders()) {
|
||||||
request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
|
request.addHeader(header);
|
||||||
request.addHeader("Content-Type", "application/vnd.wap.mms-message");
|
}
|
||||||
|
|
||||||
request.setEntity(new ByteArrayEntityHC4(mms));
|
request.setEntity(new ByteArrayEntityHC4(mms));
|
||||||
if (useProxy) {
|
if (useProxy) {
|
||||||
HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
|
HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
|
||||||
|
@ -9,6 +9,10 @@ import android.util.Log;
|
|||||||
public class TelephonyUtil {
|
public class TelephonyUtil {
|
||||||
private static final String TAG = TelephonyUtil.class.getSimpleName();
|
private static final String TAG = TelephonyUtil.class.getSimpleName();
|
||||||
|
|
||||||
|
public static TelephonyManager getManager(final Context context) {
|
||||||
|
return (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getMccMnc(final Context context) {
|
public static String getMccMnc(final Context context) {
|
||||||
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
final int configMcc = context.getResources().getConfiguration().mcc;
|
final int configMcc = context.getResources().getConfiguration().mcc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user