From 80eb975f5f51ed409ce76ab46be168417ba34635 Mon Sep 17 00:00:00 2001 From: Taesu Lee Date: Fri, 15 Nov 2019 14:45:15 +0900 Subject: Get MMS config through SmsManager It gets the MMS config through SmsManager and getCarrierConfigValues() to provide the config is removed because it will return null or old config if it receives ACTION_CARRIER_CONFIG_CHANGED later than caller. Bug: 145768042 Test: manual Change-Id: I502bd4fdd3f7d0616bc66e303d7fe26fbe7be388 Merged-In: I502bd4fdd3f7d0616bc66e303d7fe26fbe7be388 Signed-off-by: Taesu Lee --- src/com/android/mms/service/MmsConfigManager.java | 93 ++--------------------- src/com/android/mms/service/MmsService.java | 18 ----- 2 files changed, 5 insertions(+), 106 deletions(-) diff --git a/src/com/android/mms/service/MmsConfigManager.java b/src/com/android/mms/service/MmsConfigManager.java index 20ae9e4..3606ed8 100644 --- a/src/com/android/mms/service/MmsConfigManager.java +++ b/src/com/android/mms/service/MmsConfigManager.java @@ -20,9 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.os.BaseBundle; import android.os.Bundle; -import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; import android.telephony.SmsManager; import android.telephony.SubscriptionInfo; @@ -98,91 +96,11 @@ public class MmsConfigManager { return null; } - /** - * Filters a bundle to only contain MMS config variables. - * - * This is for use with bundles returned by {@link CarrierConfigManager} which contain MMS - * config and unrelated config. It is assumed that all MMS_CONFIG_* keys are present in the - * supplied bundle. - * - * @param config a Bundle that contains MMS config variables and possibly more. - * @return a new Bundle that only contains the MMS_CONFIG_* keys defined above. - * @hide - */ - private static Bundle getMmsConfig(BaseBundle config) { - Bundle filtered = new Bundle(); - filtered.putBoolean(SmsManager.MMS_CONFIG_APPEND_TRANSACTION_ID, - config.getBoolean(SmsManager.MMS_CONFIG_APPEND_TRANSACTION_ID)); - filtered.putBoolean(SmsManager.MMS_CONFIG_MMS_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_MMS_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_GROUP_MMS_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_GROUP_MMS_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_ALIAS_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_ALIAS_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_ALLOW_ATTACH_AUDIO, - config.getBoolean(SmsManager.MMS_CONFIG_ALLOW_ATTACH_AUDIO)); - filtered.putBoolean(SmsManager.MMS_CONFIG_MULTIPART_SMS_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_MULTIPART_SMS_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION, - config.getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION)); - filtered.putBoolean(SmsManager.MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES, - config.getBoolean(SmsManager.MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES)); - filtered.putBoolean(SmsManager.MMS_CONFIG_MMS_READ_REPORT_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_MMS_READ_REPORT_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED, - config.getBoolean(SmsManager.MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED)); - filtered.putBoolean(SmsManager.MMS_CONFIG_CLOSE_CONNECTION, - config.getBoolean(SmsManager.MMS_CONFIG_CLOSE_CONNECTION)); - filtered.putInt(SmsManager.MMS_CONFIG_MAX_MESSAGE_SIZE, - config.getInt(SmsManager.MMS_CONFIG_MAX_MESSAGE_SIZE)); - filtered.putInt(SmsManager.MMS_CONFIG_MAX_IMAGE_WIDTH, - config.getInt(SmsManager.MMS_CONFIG_MAX_IMAGE_WIDTH)); - filtered.putInt(SmsManager.MMS_CONFIG_MAX_IMAGE_HEIGHT, - config.getInt(SmsManager.MMS_CONFIG_MAX_IMAGE_HEIGHT)); - filtered.putInt(SmsManager.MMS_CONFIG_RECIPIENT_LIMIT, - config.getInt(SmsManager.MMS_CONFIG_RECIPIENT_LIMIT)); - filtered.putInt(SmsManager.MMS_CONFIG_ALIAS_MIN_CHARS, - config.getInt(SmsManager.MMS_CONFIG_ALIAS_MIN_CHARS)); - filtered.putInt(SmsManager.MMS_CONFIG_ALIAS_MAX_CHARS, - config.getInt(SmsManager.MMS_CONFIG_ALIAS_MAX_CHARS)); - filtered.putInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD, - config.getInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD)); - filtered.putInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD, - config.getInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD)); - filtered.putInt(SmsManager.MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE, - config.getInt(SmsManager.MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE)); - filtered.putInt(SmsManager.MMS_CONFIG_SUBJECT_MAX_LENGTH, - config.getInt(SmsManager.MMS_CONFIG_SUBJECT_MAX_LENGTH)); - filtered.putInt(SmsManager.MMS_CONFIG_HTTP_SOCKET_TIMEOUT, - config.getInt(SmsManager.MMS_CONFIG_HTTP_SOCKET_TIMEOUT)); - filtered.putString(SmsManager.MMS_CONFIG_UA_PROF_TAG_NAME, - config.getString(SmsManager.MMS_CONFIG_UA_PROF_TAG_NAME)); - filtered.putString(SmsManager.MMS_CONFIG_USER_AGENT, - config.getString(SmsManager.MMS_CONFIG_USER_AGENT)); - filtered.putString(SmsManager.MMS_CONFIG_UA_PROF_URL, - config.getString(SmsManager.MMS_CONFIG_UA_PROF_URL)); - filtered.putString(SmsManager.MMS_CONFIG_HTTP_PARAMS, - config.getString(SmsManager.MMS_CONFIG_HTTP_PARAMS)); - filtered.putString(SmsManager.MMS_CONFIG_EMAIL_GATEWAY_NUMBER, - config.getString(SmsManager.MMS_CONFIG_EMAIL_GATEWAY_NUMBER)); - filtered.putString(SmsManager.MMS_CONFIG_NAI_SUFFIX, - config.getString(SmsManager.MMS_CONFIG_NAI_SUFFIX)); - filtered.putBoolean(SmsManager.MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS, - config.getBoolean(SmsManager.MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS)); - filtered.putBoolean(SmsManager.MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER, - config.getBoolean(SmsManager.MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER)); - return filtered; - } - /** * This loads the MMS config for each active subscription. * - * MMS config is fetched from CarrierConfigManager and filtered to only include MMS config - * variables. The resulting bundles are stored in mSubIdConfigMap. + * MMS config is fetched from SmsManager#getCarrierConfigValues(). The resulting bundles are + * stored in mSubIdConfigMap. */ private void load(Context context) { List subs = mSubscriptionManager.getActiveSubscriptionInfoList(); @@ -193,15 +111,14 @@ public class MmsConfigManager { // Load all the config bundles into a new map and then swap it with the real map to avoid // blocking. final Map newConfigMap = new ArrayMap(); - final CarrierConfigManager configManager = - (CarrierConfigManager) context.getSystemService(Context.CARRIER_CONFIG_SERVICE); for (SubscriptionInfo sub : subs) { final int subId = sub.getSubscriptionId(); LogUtil.i("MmsConfigManager loads mms config for " + sub.getMccString() + "/" + sub.getMncString() + ", CarrierId " + sub.getCarrierId()); - PersistableBundle config = configManager.getConfigForSubId(subId); - newConfigMap.put(subId, getMmsConfig(config)); + newConfigMap.put( + subId, + SmsManager.getSmsManagerForSubscriptionId(subId).getCarrierConfigValues()); } synchronized(mSubIdConfigMap) { mSubIdConfigMap.clear(); diff --git a/src/com/android/mms/service/MmsService.java b/src/com/android/mms/service/MmsService.java index 66b23ac..20e74d5 100644 --- a/src/com/android/mms/service/MmsService.java +++ b/src/com/android/mms/service/MmsService.java @@ -262,24 +262,6 @@ public class MmsService extends Service implements MmsRequest.RequestManager { addSimRequest(request); } - @Override - public Bundle getCarrierConfigValues(int subId) { - LogUtil.d("getCarrierConfigValues"); - // Make sure the subId is correct - if (!SubscriptionManager.isValidSubscriptionId(subId)) { - LogUtil.e("Invalid subId " + subId); - return new Bundle(); - } - if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { - subId = SubscriptionManager.getDefaultSmsSubscriptionId(); - } - final Bundle mmsConfig = MmsConfigManager.getInstance().getMmsConfigBySubId(subId); - if (mmsConfig == null) { - return new Bundle(); - } - return mmsConfig; - } - @Override public Uri importTextMessage(String callingPkg, String address, int type, String text, long timestampMillis, boolean seen, boolean read) { -- cgit v1.2.3