OSDN Git Service

DO NOT MERGE Add CarrierConfig to overlay incorrect country ISO
authorallenwtsu <allenwtsu@google.com>
Fri, 4 Jan 2019 03:37:44 +0000 (11:37 +0800)
committerAllen Su <allenwtsu@google.com>
Thu, 31 Jan 2019 06:54:33 +0000 (06:54 +0000)
The issues happens when CDMA is roaming to GSM, some US operator's mcc/mnc would change to 204/04
whose country belongs to NL not US. It doesn't always change but error occurs once changed.
MMSService would check if locale matches with phoneNumber.
The error results in HTTP header bringing incorrect MDN to server.
In Q, AOSP fixes it by using CarrierConfig to enforce 'US' as iso-country for all error scenarios.
Since the change is great, migrating all the patches to P for the time being is risky.
So, we use the same CarrierConfig as Q and narrow the range to MMS only.
That's why we use "DO NOT MERGE".

Bug: 120448454
Bug: 122332763
Test: Build pass
Change-Id: I74a7be348f37c06c015c50f96fbcf7db4fb15246

telephony/java/android/telephony/CarrierConfigManager.java
telephony/java/android/telephony/SmsManager.java

index 806e139..ef0f71a 100644 (file)
@@ -1092,6 +1092,19 @@ public class CarrierConfigManager {
     public static final String KEY_CARRIER_NAME_STRING = "carrier_name_string";
 
     /**
+     * String to override sim country iso.
+     * Sim country iso is based on sim MCC which is coarse and doesn't work with dual IMSI SIM where
+     * a SIM can have multiple MCC from different countries.
+     * Instead, each sim carrier should have a single country code, apply per carrier based iso
+     * code as an override. The overridden value can be read from
+     * {@link TelephonyManager#getSimCountryIso()} and {@link SubscriptionInfo#getCountryIso()}
+     *
+     * @hide
+     */
+    public static final String KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING =
+            "sim_country_iso_override_string";
+
+    /**
      * Override the registered PLMN name using #KEY_CDMA_HOME_REGISTERED_PLMN_NAME_STRING.
      *
      * If true, then the registered PLMN name (only for CDMA/CDMA-LTE and only when not roaming)
@@ -2237,6 +2250,7 @@ public class CarrierConfigManager {
         sDefaults.putBoolean(KEY_CONFIG_WIFI_DISABLE_IN_ECBM, false);
         sDefaults.putBoolean(KEY_CARRIER_NAME_OVERRIDE_BOOL, false);
         sDefaults.putString(KEY_CARRIER_NAME_STRING, "");
+        sDefaults.putString(KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING, "");
         sDefaults.putBoolean(KEY_CDMA_HOME_REGISTERED_PLMN_NAME_OVERRIDE_BOOL, false);
         sDefaults.putString(KEY_CDMA_HOME_REGISTERED_PLMN_NAME_STRING, "");
         sDefaults.putBoolean(KEY_SUPPORT_DIRECT_FDN_DIALING_BOOL, false);
index 38bc640..200cbc0 100644 (file)
@@ -257,6 +257,15 @@ public final class SmsManager {
      */
     public static final String MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER =
             CarrierConfigManager.KEY_MMS_SUPPORT_HTTP_CHARSET_HEADER_BOOL;
+
+    /**
+     * When roaming, some operator's MCC would change. It results in MMSService's verification
+     * failure. This config could use correct country.
+     * @hide
+     */
+    public static final String MMS_CONFIG_SIM_COUNTRY_ISO_OVERRIDE =
+            CarrierConfigManager.KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING;
+
     /**
      * If true, add "Connection: close" header to MMS HTTP requests so the connection
      * is immediately closed (disabling keep-alive). (Boolean type)
@@ -2065,6 +2074,8 @@ public final class SmsManager {
         filtered.putString(MMS_CONFIG_EMAIL_GATEWAY_NUMBER,
                 config.getString(MMS_CONFIG_EMAIL_GATEWAY_NUMBER));
         filtered.putString(MMS_CONFIG_NAI_SUFFIX, config.getString(MMS_CONFIG_NAI_SUFFIX));
+        filtered.putString(MMS_CONFIG_SIM_COUNTRY_ISO_OVERRIDE,
+                config.getString(MMS_CONFIG_SIM_COUNTRY_ISO_OVERRIDE));
         filtered.putBoolean(MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS,
                 config.getBoolean(MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS));
         filtered.putBoolean(MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER,