Loading android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfig.java +9 −17 Original line number Diff line number Diff line Loading @@ -551,9 +551,6 @@ public class MmsConfig { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { return telephonyManager.getLine1Number(); } else { try { Method method = telephonyManager.getClass().getMethod("getLine1NumberForSubscriber", int.class); return (String) method.invoke(telephonyManager, subId); Loading @@ -561,7 +558,6 @@ public class MmsConfig { return telephonyManager.getLine1Number(); } } } private static String getLine1NoCountryCode(Context context, int subId) { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Loading @@ -581,9 +577,6 @@ public class MmsConfig { String nai = ""; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai"); } else { try { Method method = telephonyManager.getClass().getMethod("getNai", int.class); Method getSlotId = SubscriptionManager.class.getMethod("getSlotId", int.class); Loading @@ -591,7 +584,6 @@ public class MmsConfig { } catch (Exception e) { nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai"); } } Timber.v("MmsConfig.getNai: nai=" + nai); Loading android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfigManager.java +38 −45 Original line number Diff line number Diff line Loading @@ -73,12 +73,10 @@ public class MmsConfigManager { public void init(final Context context) { mContext = context; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mSubscriptionManager = SubscriptionManager.from(context); // TODO: When this object "finishes" we should unregister. IntentFilter intentFilterLoaded = new IntentFilter("LOADED"); IntentFilter intentFilterLoaded = new IntentFilter("LOADED"); try { context.registerReceiver(mReceiver, intentFilterLoaded); Loading @@ -87,9 +85,6 @@ public class MmsConfigManager { } load(context); } else { load(context); } // TODO: When this object "finishes" we should unregister by invoking // SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener); Loading Loading @@ -151,7 +146,6 @@ public class MmsConfigManager { * */ private void load(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { List<SubscriptionInfo> subs = mSubscriptionManager.getActiveSubscriptionInfoList(); if (subs == null || subs.size() < 1) { Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList"); Loading Loading @@ -185,6 +179,5 @@ public class MmsConfigManager { mSubIdConfigMap.putAll(newConfigMap); } } } } android-smsmms/src/main/java/com/android/mms/service_alt/MmsNetworkManager.java +5 −12 Original line number Diff line number Diff line Loading @@ -87,18 +87,11 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network { mSubId = subId; if (!MmsRequest.useWifi(context)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mNetworkRequest = new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) .setNetworkSpecifier(Integer.toString(mSubId)) .build(); } else { mNetworkRequest = new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) .build(); } } else { mNetworkRequest = new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) Loading android-smsmms/src/main/java/com/android/mms/service_alt/MmsRequest.java +4 −16 Original line number Diff line number Diff line Loading @@ -104,12 +104,8 @@ public abstract class MmsRequest { private boolean ensureMmsConfigLoaded() { if (mMmsConfig == null) { final MmsConfig config; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { // Not yet retrieved from mms config manager. Try getting it. config = MmsConfigManager.getInstance().getMmsConfigBySubId(mSubId); } else { config = MmsConfigManager.getInstance().getMmsConfig(); } if (config != null) { mMmsConfig = new MmsConfig.Overridden(config, mMmsConfigOverrides); Loading Loading @@ -167,11 +163,7 @@ public abstract class MmsRequest { result = SmsManager.MMS_ERROR_IO_ERROR; } else if (!isDataNetworkAvailable(context, mSubId)) { Timber.e("MmsRequest: in airplane mode or mobile data disabled"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { result = SmsManager.MMS_ERROR_NO_DATA_NETWORK; } else { result = 8; } } else { // Execute long retryDelaySecs = 2; // Try multiple times of MMS HTTP request Loading Loading @@ -268,11 +260,7 @@ public abstract class MmsRequest { fillIn.putExtra("uri", messageUri.toString()); } if (result == SmsManager.MMS_ERROR_HTTP_FAILURE && httpStatusCode != 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { fillIn.putExtra(SmsManager.EXTRA_MMS_HTTP_STATUS, httpStatusCode); } else { fillIn.putExtra("android.telephony.extra.MMS_HTTP_STATUS", httpStatusCode); } } try { if (!succeeded) { Loading android-smsmms/src/main/java/com/android/mms/service_alt/SubscriptionIdChecker.java +13 −15 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ class SubscriptionIdChecker { // I met a device which does not have Telephony.Mms.SUBSCRIPTION_ID event if it's API Level is 22. private void check(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { Cursor c = null; try { c = SqliteWrapper.query(context, context.getContentResolver(), Loading @@ -33,7 +32,6 @@ class SubscriptionIdChecker { } } } } static synchronized SubscriptionIdChecker getInstance(Context context) { if (sInstance == null) { Loading Loading
android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfig.java +9 −17 Original line number Diff line number Diff line Loading @@ -551,9 +551,6 @@ public class MmsConfig { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { return telephonyManager.getLine1Number(); } else { try { Method method = telephonyManager.getClass().getMethod("getLine1NumberForSubscriber", int.class); return (String) method.invoke(telephonyManager, subId); Loading @@ -561,7 +558,6 @@ public class MmsConfig { return telephonyManager.getLine1Number(); } } } private static String getLine1NoCountryCode(Context context, int subId) { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Loading @@ -581,9 +577,6 @@ public class MmsConfig { String nai = ""; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai"); } else { try { Method method = telephonyManager.getClass().getMethod("getNai", int.class); Method getSlotId = SubscriptionManager.class.getMethod("getSlotId", int.class); Loading @@ -591,7 +584,6 @@ public class MmsConfig { } catch (Exception e) { nai = SystemPropertiesProxy.get(context, "persist.radio.cdma.nai"); } } Timber.v("MmsConfig.getNai: nai=" + nai); Loading
android-smsmms/src/main/java/com/android/mms/service_alt/MmsConfigManager.java +38 −45 Original line number Diff line number Diff line Loading @@ -73,12 +73,10 @@ public class MmsConfigManager { public void init(final Context context) { mContext = context; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mSubscriptionManager = SubscriptionManager.from(context); // TODO: When this object "finishes" we should unregister. IntentFilter intentFilterLoaded = new IntentFilter("LOADED"); IntentFilter intentFilterLoaded = new IntentFilter("LOADED"); try { context.registerReceiver(mReceiver, intentFilterLoaded); Loading @@ -87,9 +85,6 @@ public class MmsConfigManager { } load(context); } else { load(context); } // TODO: When this object "finishes" we should unregister by invoking // SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener); Loading Loading @@ -151,7 +146,6 @@ public class MmsConfigManager { * */ private void load(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { List<SubscriptionInfo> subs = mSubscriptionManager.getActiveSubscriptionInfoList(); if (subs == null || subs.size() < 1) { Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList"); Loading Loading @@ -185,6 +179,5 @@ public class MmsConfigManager { mSubIdConfigMap.putAll(newConfigMap); } } } }
android-smsmms/src/main/java/com/android/mms/service_alt/MmsNetworkManager.java +5 −12 Original line number Diff line number Diff line Loading @@ -87,18 +87,11 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network { mSubId = subId; if (!MmsRequest.useWifi(context)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mNetworkRequest = new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) .setNetworkSpecifier(Integer.toString(mSubId)) .build(); } else { mNetworkRequest = new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS) .build(); } } else { mNetworkRequest = new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) Loading
android-smsmms/src/main/java/com/android/mms/service_alt/MmsRequest.java +4 −16 Original line number Diff line number Diff line Loading @@ -104,12 +104,8 @@ public abstract class MmsRequest { private boolean ensureMmsConfigLoaded() { if (mMmsConfig == null) { final MmsConfig config; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { // Not yet retrieved from mms config manager. Try getting it. config = MmsConfigManager.getInstance().getMmsConfigBySubId(mSubId); } else { config = MmsConfigManager.getInstance().getMmsConfig(); } if (config != null) { mMmsConfig = new MmsConfig.Overridden(config, mMmsConfigOverrides); Loading Loading @@ -167,11 +163,7 @@ public abstract class MmsRequest { result = SmsManager.MMS_ERROR_IO_ERROR; } else if (!isDataNetworkAvailable(context, mSubId)) { Timber.e("MmsRequest: in airplane mode or mobile data disabled"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { result = SmsManager.MMS_ERROR_NO_DATA_NETWORK; } else { result = 8; } } else { // Execute long retryDelaySecs = 2; // Try multiple times of MMS HTTP request Loading Loading @@ -268,11 +260,7 @@ public abstract class MmsRequest { fillIn.putExtra("uri", messageUri.toString()); } if (result == SmsManager.MMS_ERROR_HTTP_FAILURE && httpStatusCode != 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { fillIn.putExtra(SmsManager.EXTRA_MMS_HTTP_STATUS, httpStatusCode); } else { fillIn.putExtra("android.telephony.extra.MMS_HTTP_STATUS", httpStatusCode); } } try { if (!succeeded) { Loading
android-smsmms/src/main/java/com/android/mms/service_alt/SubscriptionIdChecker.java +13 −15 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ class SubscriptionIdChecker { // I met a device which does not have Telephony.Mms.SUBSCRIPTION_ID event if it's API Level is 22. private void check(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { Cursor c = null; try { c = SqliteWrapper.query(context, context.getContentResolver(), Loading @@ -33,7 +32,6 @@ class SubscriptionIdChecker { } } } } static synchronized SubscriptionIdChecker getInstance(Context context) { if (sInstance == null) { Loading