Messaging: Remove compatibility for old android versions
Change-Id: Id9065d60525a509271a0e64c0e349e857cb998e2
This commit is contained in:
@@ -286,7 +286,7 @@ class DefaultApnSettingsLoader implements ApnSettingsLoader {
|
||||
*/
|
||||
private void loadFromSystem(final int subId, final String apnName, final List<Apn> apns) {
|
||||
Uri uri;
|
||||
if (Utils.supportMSim() && subId != MmsManager.DEFAULT_SUB_ID) {
|
||||
if (subId != MmsManager.DEFAULT_SUB_ID) {
|
||||
uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "/subId/" + subId);
|
||||
} else {
|
||||
uri = Telephony.Carriers.CONTENT_URI;
|
||||
|
||||
@@ -68,12 +68,8 @@ class DefaultCarrierConfigValuesLoader implements CarrierConfigValuesLoader {
|
||||
}
|
||||
|
||||
private void loadLocked(final int subId, final Bundle values) {
|
||||
// For K and earlier, load from resources
|
||||
loadFromResources(subId, values);
|
||||
if (Utils.hasMmsApi()) {
|
||||
// For L and later, also load from system MMS service
|
||||
loadFromSystem(subId, values);
|
||||
}
|
||||
loadFromSystem(subId, values);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,13 +72,11 @@ class DefaultUserAgentInfoLoader implements UserAgentInfoLoader {
|
||||
}
|
||||
|
||||
private void loadLocked() {
|
||||
if (Utils.hasUserAgentApi()) {
|
||||
// load the MMS User agent and UaProfUrl from TelephonyManager APIs
|
||||
final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
|
||||
Context.TELEPHONY_SERVICE);
|
||||
mUserAgent = telephonyManager.getMmsUserAgent();
|
||||
mUAProfUrl = telephonyManager.getMmsUAProfUrl();
|
||||
}
|
||||
// load the MMS User agent and UaProfUrl from TelephonyManager APIs
|
||||
final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
|
||||
Context.TELEPHONY_SERVICE);
|
||||
mUserAgent = telephonyManager.getMmsUserAgent();
|
||||
mUAProfUrl = telephonyManager.getMmsUAProfUrl();
|
||||
if (TextUtils.isEmpty(mUserAgent)) {
|
||||
mUserAgent = DEFAULT_USER_AGENT;
|
||||
}
|
||||
|
||||
@@ -392,17 +392,13 @@ public class MmsHttpClient {
|
||||
* @return the phone number text
|
||||
*/
|
||||
private String getSelfNumber() {
|
||||
if (Utils.supportMSim()) {
|
||||
final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
|
||||
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(
|
||||
SmsManager.getDefaultSmsSubscriptionId());
|
||||
if (info != null) {
|
||||
return info.getNumber();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
|
||||
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(
|
||||
SmsManager.getDefaultSmsSubscriptionId());
|
||||
if (info != null) {
|
||||
return info.getNumber();
|
||||
} else {
|
||||
return mTelephonyManager.getLine1Number();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,15 +409,11 @@ public class MmsHttpClient {
|
||||
*/
|
||||
private String getSimOrLocaleCountry() {
|
||||
String country = null;
|
||||
if (Utils.supportMSim()) {
|
||||
final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
|
||||
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(
|
||||
SmsManager.getDefaultSmsSubscriptionId());
|
||||
if (info != null) {
|
||||
country = info.getCountryIso();
|
||||
}
|
||||
} else {
|
||||
country = mTelephonyManager.getSimCountryIso();
|
||||
final SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
|
||||
final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(
|
||||
SmsManager.getDefaultSmsSubscriptionId());
|
||||
if (info != null) {
|
||||
country = info.getCountryIso();
|
||||
}
|
||||
if (!TextUtils.isEmpty(country)) {
|
||||
return country.toUpperCase();
|
||||
@@ -439,13 +431,8 @@ public class MmsHttpClient {
|
||||
* @return the Base64 encoded NAI string to use as HTTP header
|
||||
*/
|
||||
private String getEncodedNai(final String naiSuffix) {
|
||||
String nai;
|
||||
if (Utils.supportMSim()) {
|
||||
nai = getNaiBySystemApi(
|
||||
getSlotId(Utils.getEffectiveSubscriptionId(MmsManager.DEFAULT_SUB_ID)));
|
||||
} else {
|
||||
nai = getNaiBySystemProperty();
|
||||
}
|
||||
String nai = getNaiBySystemApi(
|
||||
getSlotId(Utils.getEffectiveSubscriptionId(MmsManager.DEFAULT_SUB_ID)));
|
||||
if (!TextUtils.isEmpty(nai)) {
|
||||
Log.i(MmsService.TAG, "NAI is not empty");
|
||||
if (!TextUtils.isEmpty(naiSuffix)) {
|
||||
|
||||
@@ -175,7 +175,7 @@ public class MmsManager {
|
||||
* @return true if forced to use legacy APIs or platform doesn't supports MMS APIs.
|
||||
*/
|
||||
public static boolean shouldUseLegacyMms() {
|
||||
return sForceLegacyMms || !Utils.hasMmsApi();
|
||||
return sForceLegacyMms;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,10 +187,6 @@ public class MmsManager {
|
||||
* @return a Bundle containing the overrides
|
||||
*/
|
||||
private static Bundle getConfigOverrides(final int subId) {
|
||||
if (!Utils.hasMmsApi()) {
|
||||
// If MMS API is not present, it is not necessary to compute overrides
|
||||
return null;
|
||||
}
|
||||
Bundle overrides = null;
|
||||
synchronized (sConfigOverridesMap) {
|
||||
overrides = sConfigOverridesMap.get(subId);
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -350,16 +349,7 @@ class MmsNetworkManager {
|
||||
* @return The change's network type
|
||||
*/
|
||||
private static int getConnectivityChangeNetworkType(final Intent intent) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
return intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, TYPE_NONE);
|
||||
} else {
|
||||
final NetworkInfo info = intent.getParcelableExtra(
|
||||
ConnectivityManager.EXTRA_NETWORK_INFO);
|
||||
if (info != null) {
|
||||
return info.getType();
|
||||
}
|
||||
}
|
||||
return TYPE_NONE;
|
||||
return intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, TYPE_NONE);
|
||||
}
|
||||
|
||||
private static String getMmsConnectivityResultString(int result) {
|
||||
|
||||
@@ -19,11 +19,9 @@ package android.support.v7.mms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.telephony.SmsManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -34,33 +32,6 @@ import java.net.URL;
|
||||
* Utility methods
|
||||
*/
|
||||
class Utils {
|
||||
/**
|
||||
* Check if MMS API is available
|
||||
*
|
||||
* @return true if MMS API is available, false otherwise
|
||||
*/
|
||||
static boolean hasMmsApi() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if support multi-SIM
|
||||
*
|
||||
* @return true if MSIM is supported, false otherwise
|
||||
*/
|
||||
static boolean supportMSim() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if support APIs for getting UserAgent and UAProfUrl
|
||||
*
|
||||
* @return true if those APIs are supported, false otherwise
|
||||
*/
|
||||
static boolean hasUserAgentApi() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system SmsManager
|
||||
*
|
||||
@@ -68,11 +39,7 @@ class Utils {
|
||||
* @return the SmsManager for the input subId
|
||||
*/
|
||||
static SmsManager getSmsManager(final int subId) {
|
||||
if (supportMSim()) {
|
||||
return SmsManager.getSmsManagerForSubscriptionId(subId);
|
||||
} else {
|
||||
return SmsManager.getDefault();
|
||||
}
|
||||
return SmsManager.getSmsManagerForSubscriptionId(subId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,10 +49,8 @@ class Utils {
|
||||
* @return the default SMS subscription ID if the input is -1, otherwise the original
|
||||
*/
|
||||
static int getEffectiveSubscriptionId(int subId) {
|
||||
if (supportMSim()) {
|
||||
if (subId == MmsManager.DEFAULT_SUB_ID) {
|
||||
subId = SmsManager.getDefaultSmsSubscriptionId();
|
||||
}
|
||||
if (subId == MmsManager.DEFAULT_SUB_ID) {
|
||||
subId = SmsManager.getDefaultSmsSubscriptionId();
|
||||
}
|
||||
if (subId < 0) {
|
||||
subId = MmsManager.DEFAULT_SUB_ID;
|
||||
@@ -102,25 +67,11 @@ class Utils {
|
||||
*/
|
||||
static int[] getMccMnc(final Context context, final int subId) {
|
||||
final int[] mccMnc = new int[] { 0, 0 };
|
||||
if (Utils.supportMSim()) {
|
||||
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
|
||||
final SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subId);
|
||||
if (subInfo != null) {
|
||||
mccMnc[0] = subInfo.getMcc();
|
||||
mccMnc[1] = subInfo.getMnc();
|
||||
}
|
||||
} else {
|
||||
final TelephonyManager telephonyManager =
|
||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
final String mccMncString = telephonyManager.getSimOperator();
|
||||
try {
|
||||
mccMnc[0] = Integer.parseInt(mccMncString.substring(0, 3));
|
||||
mccMnc[1] = Integer.parseInt(mccMncString.substring(3));
|
||||
} catch (Exception e) {
|
||||
Log.w(MmsService.TAG, "Invalid mcc/mnc from system " + mccMncString + ": " + e);
|
||||
mccMnc[0] = 0;
|
||||
mccMnc[1] = 0;
|
||||
}
|
||||
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
|
||||
final SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subId);
|
||||
if (subInfo != null) {
|
||||
mccMnc[0] = subInfo.getMcc();
|
||||
mccMnc[1] = subInfo.getMnc();
|
||||
}
|
||||
return mccMnc;
|
||||
}
|
||||
@@ -133,9 +84,6 @@ class Utils {
|
||||
* @return the sub-dependent Context
|
||||
*/
|
||||
static Context getSubDepContext(final Context context, final int subId) {
|
||||
if (!supportMSim()) {
|
||||
return context;
|
||||
}
|
||||
final int[] mccMnc = getMccMnc(context, subId);
|
||||
final int mcc = mccMnc[0];
|
||||
final int mnc = mccMnc[1];
|
||||
|
||||
Reference in New Issue
Block a user