mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 13:48:26 +00:00
Add the verizon MSISDN x-vzw-mdn header to MMS requests.
Closes #4148 Fixes #3150
This commit is contained in:
parent
1fd8025cb5
commit
7ff8c99055
@ -19,6 +19,7 @@ package org.thoughtcrime.securesms.mms;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@ -43,6 +44,9 @@ import org.thoughtcrime.securesms.util.Conversions;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -194,7 +198,9 @@ public abstract class LegacyMmsConnection {
|
||||
}
|
||||
|
||||
protected List<Header> getBaseHeaders() {
|
||||
final String number = TelephonyUtil.getManager(context).getLine1Number();
|
||||
final String number = TelephonyUtil.getManager(context).getLine1Number(); ;
|
||||
final Optional<BasicHeader> mdnHeader = getVerizonMdnHeader(number);
|
||||
|
||||
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"));
|
||||
@ -203,10 +209,28 @@ public abstract class LegacyMmsConnection {
|
||||
if (!TextUtils.isEmpty(number)) {
|
||||
add(new BasicHeader("x-up-calling-line-id", number));
|
||||
add(new BasicHeader("X-MDN", number));
|
||||
if (mdnHeader.isPresent()) add(mdnHeader.get());
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
private Optional<BasicHeader> getVerizonMdnHeader(@Nullable String number) {
|
||||
if (TextUtils.isEmpty(number)) return Optional.absent();
|
||||
|
||||
try {
|
||||
PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
|
||||
PhoneNumber phoneNumber = phoneNumberUtil.parse(number, null);
|
||||
String mdnNumber = phoneNumberUtil.getNationalSignificantNumber(phoneNumber);
|
||||
|
||||
return Optional.of(new BasicHeader("x-vzw-mdn", mdnNumber));
|
||||
} catch (NumberParseException e) {
|
||||
Log.w(TAG, e);
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class Apn {
|
||||
|
||||
public static Apn EMPTY = new Apn("", "", "", "", "");
|
||||
|
Loading…
x
Reference in New Issue
Block a user