Fix language settings for Canada.

Adjusts behaviour after commit 04787851cbd97. We pass in the language
from the SimRecords (from EF-PL, EF-LI) to the MccTable language
matching code. This fixes pathological cases like sim language
= "fr" for canada, where we return "fr-US" instead of "fr-CA".

♫♫
Well, blame Canada, blame Canada
It seems that everything's gone wrong
Since Canada came along
♫♫

bug: 22684963
Change-Id: Ib72dc4fbdf864897c194836219b8ffaf14fc2152
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 8273e1e..750a025 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2799,29 +2799,25 @@
         // Try and fetch the locale from the carrier properties or from the SIM language
         // preferences (EF-PL and EF-LI)...
         final int mcc = info.getMcc();
-        final Locale mccLocale = MccTable.getLocaleFromMcc(mPhone.getContext(), mcc);
         final Phone defaultPhone = getPhone(info.getSubscriptionId());
+        String simLanguage = null;
         if (defaultPhone != null) {
             final Locale localeFromDefaultSim = defaultPhone.getLocaleFromSimAndCarrierPrefs();
             if (localeFromDefaultSim != null) {
-                // The SIM language preferences only store a language (e.g. fr = French), not an
-                // exact locale (e.g. fr_FR = French/France). So, if the locale returned from
-                // the SIM and carrier preferences does not include a country we add the country
-                // determined from the SIM MCC to provide an exact locale.
-                // Note this can result in unusual locale combinatons (e.g. en_DE) being returned.
-                if ((localeFromDefaultSim.getCountry().isEmpty()) && (mccLocale != null)) {
-                    final Locale combinedLocale = new Locale (localeFromDefaultSim.getLanguage(),
-                                                              mccLocale.getCountry());
-                    if (DBG) log("Using SIM language and mcc country:" + combinedLocale);
-                    return combinedLocale.toLanguageTag();
-                } else {
+                if (!localeFromDefaultSim.getCountry().isEmpty()) {
                     if (DBG) log("Using locale from default SIM:" + localeFromDefaultSim);
                     return localeFromDefaultSim.toLanguageTag();
+                } else {
+                    simLanguage = localeFromDefaultSim.getLanguage();
                 }
             }
         }
 
-        // .. if that doesn't work, try and guess the language from the sim MCC.
+        // The SIM language preferences only store a language (e.g. fr = French), not an
+        // exact locale (e.g. fr_FR = French/France). So, if the locale returned from
+        // the SIM and carrier preferences does not include a country we add the country
+        // determined from the SIM MCC to provide an exact locale.
+        final Locale mccLocale = MccTable.getLocaleFromMcc(mPhone.getContext(), mcc, simLanguage);
         if (mccLocale != null) {
             if (DBG) log("No locale from default SIM, using mcc locale:" + mccLocale);
             return mccLocale.toLanguageTag();