DO NOT MERGE Use original country locale to parse phone number without country code.

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: Manual: Build pass and MMS sending works.
Change-Id: Idc01d9dd2b139ed0263d499e42afdd66dbef64c0
diff --git a/src/com/android/mms/service/MmsHttpClient.java b/src/com/android/mms/service/MmsHttpClient.java
index 40e03cd..fc0d67e 100644
--- a/src/com/android/mms/service/MmsHttpClient.java
+++ b/src/com/android/mms/service/MmsHttpClient.java
@@ -456,7 +456,7 @@
      * Example: "LINE1" returns the phone number, etc.
      *
      * @param macro The macro name
-     * @param mmsConfig The MMS config which contains NAI suffix.
+     * @param mmsConfig The MMS config which contains NAI suffix and SIM country ISO to override.
      * @param subId The subscription ID used to get line number, etc.
      * @return The value of the defined macro
      */
@@ -465,7 +465,7 @@
         if (MACRO_LINE1.equals(macro)) {
             return getLine1(context, subId);
         } else if (MACRO_LINE1NOCOUNTRYCODE.equals(macro)) {
-            return getLine1NoCountryCode(context, subId);
+            return getLine1NoCountryCode(context, mmsConfig, subId);
         } else if (MACRO_NAI.equals(macro)) {
             return getNai(context, mmsConfig, subId);
         }
@@ -485,13 +485,16 @@
     /**
      * Returns the phone number (without country code) for the given subscription ID.
      */
-    private static String getLine1NoCountryCode(Context context, int subId) {
+    private static String getLine1NoCountryCode(Context context, Bundle mmsConfig, int subId) {
         final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(
                 Context.TELEPHONY_SERVICE);
+        String countryIsoOverride =
+                mmsConfig.getString(SmsManager.MMS_CONFIG_SIM_COUNTRY_ISO_OVERRIDE);
         return PhoneUtils.getNationalNumber(
-                telephonyManager,
-                subId,
-                telephonyManager.getLine1Number(subId));
+            telephonyManager,
+            subId,
+            telephonyManager.getLine1Number(subId),
+            countryIsoOverride);
     }
 
     /**
diff --git a/src/com/android/mms/service/PhoneUtils.java b/src/com/android/mms/service/PhoneUtils.java
index 54b7ba9..a736ee2 100644
--- a/src/com/android/mms/service/PhoneUtils.java
+++ b/src/com/android/mms/service/PhoneUtils.java
@@ -37,11 +37,17 @@
      * @param telephonyManager
      * @param subId The SIM ID associated with this number
      * @param phoneText The input phone number text
+     * @param countryIsoOverride String to override sim country iso.
      * @return The formatted number or the original phone number if failed to parse
      */
     public static String getNationalNumber(TelephonyManager telephonyManager, int subId,
-            String phoneText) {
-        final String country = getSimOrDefaultLocaleCountry(telephonyManager, subId);
+            String phoneText, String countryIsoOverride) {
+        String country = getSimOrDefaultLocaleCountry(telephonyManager, subId);
+
+        if (!TextUtils.isEmpty(countryIsoOverride)) {
+            country = countryIsoOverride.toUpperCase();
+        }
+
         final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
         final Phonenumber.PhoneNumber parsed = getParsedNumber(phoneNumberUtil, phoneText, country);
         if (parsed == null) {