Loading telephony/java/com/android/internal/telephony/MccTable.java +1 −1 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ public final class MccTable String country = MccTable.countryCodeForMcc(mcc); Log.d(LOG_TAG, "locale set to "+language+"_"+country); phone.setSystemLocale(language, country); phone.setSystemLocale(language, country, true); } /** Loading telephony/java/com/android/internal/telephony/PhoneBase.java +6 −2 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ public abstract class PhoneBase extends Handler implements Phone { if (l.length() >=5) { country = l.substring(3, 5); } setSystemLocale(language, country); setSystemLocale(language, country, false); if (!country.isEmpty()) { try { Loading @@ -602,10 +602,14 @@ public abstract class PhoneBase extends Handler implements Phone { * Utility code to set the system locale if it's not set already * @param language Two character language code desired * @param country Two character country code desired * @param fromMcc Indicating whether the locale is set according to MCC table. * This flag wil be ignored by default implementation. * TODO: Use a source enumeration so that source of the locale * can be prioritized. * * {@hide} */ public void setSystemLocale(String language, String country) { public void setSystemLocale(String language, String country, boolean fromMcc) { String l = SystemProperties.get("persist.sys.language"); String c = SystemProperties.get("persist.sys.country"); Loading telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java +9 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,15 @@ public class CDMALTEPhone extends CDMAPhone { return false; } @Override public void setSystemLocale(String language, String country, boolean fromMcc) { // Avoid system locale is set from MCC table if CDMALTEPhone is used. // The locale will be picked up based on EFpl/EFli once CSIM records are loaded. if (fromMcc) return; super.setSystemLocale(language, country, false); } @Override protected void log(String s) { if (DBG) Loading telephony/java/com/android/internal/telephony/cdma/CdmaLteUiccRecords.java +57 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OP import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.IccFileHandler; import com.android.internal.telephony.IccUtils; import com.android.internal.telephony.MccTable; import com.android.internal.telephony.PhoneBase; import com.android.internal.telephony.cdma.sms.UserData; import com.android.internal.telephony.gsm.SIMRecords; Loading Loading @@ -184,6 +185,12 @@ public final class CdmaLteUiccRecords extends SIMRecords { } } @Override protected void onAllRecordsLoaded() { super.onAllRecordsLoaded(); setLocaleFromCsim(); } @Override protected void fetchSimRecords() { IccFileHandler iccFh = phone.getIccFileHandler(); Loading Loading @@ -355,12 +362,58 @@ public final class CdmaLteUiccRecords extends SIMRecords { if (DBG) log("CSIM PRL version=" + mPrlVersion); } public byte[] getPreferredLanguage() { return mEFpl; private void setLocaleFromCsim() { String prefLang = null; // check EFli then EFpl prefLang = findBestLanguage(mEFli); if (prefLang == null) { prefLang = findBestLanguage(mEFpl); } if (prefLang != null) { // check country code from SIM String imsi = getIMSI(); String country = null; if (imsi != null) { country = MccTable.countryCodeForMcc( Integer.parseInt(imsi.substring(0,3))); } log("Setting locale to " + prefLang + "_" + country); phone.setSystemLocale(prefLang, country, false); } else { log ("No suitable CSIM selected locale"); } } private String findBestLanguage(byte[] languages) { String bestMatch = null; String[] locales = phone.getContext().getAssets().getLocales(); public byte[] getLanguageIndication() { return mEFli; if ((languages == null) || (locales == null)) return null; // Each 2-bytes consists of one language for (int i = 0; (i + 1) < languages.length; i += 2) { try { String lang = new String(languages, i, 2, "ISO-8859-1"); for (int j = 0; j < locales.length; j++) { if (locales[j] != null && locales[j].length() >= 2 && locales[j].substring(0, 2).equals(lang)) { return lang; } } if (bestMatch != null) break; } catch(java.io.UnsupportedEncodingException e) { log ("Failed to parse SIM language records"); } } // no match found. return null return null; } @Override protected void log(String s) { if (DBG) Log.d(LOG_TAG, "[CSIM] " + s); } public String getMdn() { Loading Loading
telephony/java/com/android/internal/telephony/MccTable.java +1 −1 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ public final class MccTable String country = MccTable.countryCodeForMcc(mcc); Log.d(LOG_TAG, "locale set to "+language+"_"+country); phone.setSystemLocale(language, country); phone.setSystemLocale(language, country, true); } /** Loading
telephony/java/com/android/internal/telephony/PhoneBase.java +6 −2 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ public abstract class PhoneBase extends Handler implements Phone { if (l.length() >=5) { country = l.substring(3, 5); } setSystemLocale(language, country); setSystemLocale(language, country, false); if (!country.isEmpty()) { try { Loading @@ -602,10 +602,14 @@ public abstract class PhoneBase extends Handler implements Phone { * Utility code to set the system locale if it's not set already * @param language Two character language code desired * @param country Two character country code desired * @param fromMcc Indicating whether the locale is set according to MCC table. * This flag wil be ignored by default implementation. * TODO: Use a source enumeration so that source of the locale * can be prioritized. * * {@hide} */ public void setSystemLocale(String language, String country) { public void setSystemLocale(String language, String country, boolean fromMcc) { String l = SystemProperties.get("persist.sys.language"); String c = SystemProperties.get("persist.sys.country"); Loading
telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java +9 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,15 @@ public class CDMALTEPhone extends CDMAPhone { return false; } @Override public void setSystemLocale(String language, String country, boolean fromMcc) { // Avoid system locale is set from MCC table if CDMALTEPhone is used. // The locale will be picked up based on EFpl/EFli once CSIM records are loaded. if (fromMcc) return; super.setSystemLocale(language, country, false); } @Override protected void log(String s) { if (DBG) Loading
telephony/java/com/android/internal/telephony/cdma/CdmaLteUiccRecords.java +57 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OP import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.IccFileHandler; import com.android.internal.telephony.IccUtils; import com.android.internal.telephony.MccTable; import com.android.internal.telephony.PhoneBase; import com.android.internal.telephony.cdma.sms.UserData; import com.android.internal.telephony.gsm.SIMRecords; Loading Loading @@ -184,6 +185,12 @@ public final class CdmaLteUiccRecords extends SIMRecords { } } @Override protected void onAllRecordsLoaded() { super.onAllRecordsLoaded(); setLocaleFromCsim(); } @Override protected void fetchSimRecords() { IccFileHandler iccFh = phone.getIccFileHandler(); Loading Loading @@ -355,12 +362,58 @@ public final class CdmaLteUiccRecords extends SIMRecords { if (DBG) log("CSIM PRL version=" + mPrlVersion); } public byte[] getPreferredLanguage() { return mEFpl; private void setLocaleFromCsim() { String prefLang = null; // check EFli then EFpl prefLang = findBestLanguage(mEFli); if (prefLang == null) { prefLang = findBestLanguage(mEFpl); } if (prefLang != null) { // check country code from SIM String imsi = getIMSI(); String country = null; if (imsi != null) { country = MccTable.countryCodeForMcc( Integer.parseInt(imsi.substring(0,3))); } log("Setting locale to " + prefLang + "_" + country); phone.setSystemLocale(prefLang, country, false); } else { log ("No suitable CSIM selected locale"); } } private String findBestLanguage(byte[] languages) { String bestMatch = null; String[] locales = phone.getContext().getAssets().getLocales(); public byte[] getLanguageIndication() { return mEFli; if ((languages == null) || (locales == null)) return null; // Each 2-bytes consists of one language for (int i = 0; (i + 1) < languages.length; i += 2) { try { String lang = new String(languages, i, 2, "ISO-8859-1"); for (int j = 0; j < locales.length; j++) { if (locales[j] != null && locales[j].length() >= 2 && locales[j].substring(0, 2).equals(lang)) { return lang; } } if (bestMatch != null) break; } catch(java.io.UnsupportedEncodingException e) { log ("Failed to parse SIM language records"); } } // no match found. return null return null; } @Override protected void log(String s) { if (DBG) Log.d(LOG_TAG, "[CSIM] " + s); } public String getMdn() { Loading