Loading telephony/java/com/android/internal/telephony/AdnRecordCache.java +7 −7 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import java.util.Iterator; public final class AdnRecordCache extends Handler implements IccConstants { //***** Instance Variables PhoneBase phone; private IccFileHandler mFh; private UsimPhoneBookManager mUsimPhoneBookManager; // Indexed by EF ID Loading @@ -56,9 +56,9 @@ public final class AdnRecordCache extends Handler implements IccConstants { public AdnRecordCache(PhoneBase phone) { this.phone = phone; mUsimPhoneBookManager = new UsimPhoneBookManager(phone, this); public AdnRecordCache(IccFileHandler fh) { mFh = fh; mUsimPhoneBookManager = new UsimPhoneBookManager(mFh, this); } //***** Called from SIMRecords Loading Loading @@ -155,7 +155,7 @@ public final class AdnRecordCache extends Handler implements IccConstants { userWriteResponse.put(efid, response); new AdnRecordLoader(phone).updateEF(adn, efid, extensionEF, new AdnRecordLoader(mFh).updateEF(adn, efid, extensionEF, recordIndex, pin2, obtainMessage(EVENT_UPDATE_ADN_DONE, efid, recordIndex, adn)); } Loading Loading @@ -233,7 +233,7 @@ public final class AdnRecordCache extends Handler implements IccConstants { userWriteResponse.put(efid, response); new AdnRecordLoader(phone).updateEF(newAdn, efid, extensionEF, new AdnRecordLoader(mFh).updateEF(newAdn, efid, extensionEF, index, pin2, obtainMessage(EVENT_UPDATE_ADN_DONE, efid, index, newAdn)); } Loading Loading @@ -296,7 +296,7 @@ public final class AdnRecordCache extends Handler implements IccConstants { return; } new AdnRecordLoader(phone).loadAllFromEF(efid, extensionEf, new AdnRecordLoader(mFh).loadAllFromEF(efid, extensionEf, obtainMessage(EVENT_LOAD_ALL_ADN_LIKE_DONE, efid, 0)); } Loading telephony/java/com/android/internal/telephony/AdnRecordLoader.java +12 −13 Original line number Diff line number Diff line Loading @@ -20,16 +20,17 @@ import java.util.ArrayList; import android.os.AsyncResult; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.Log; public class AdnRecordLoader extends Handler { static String LOG_TAG; final static String LOG_TAG = "RIL_AdnRecordLoader"; //***** Instance Variables PhoneBase phone; private IccFileHandler mFh; int ef; int extensionEF; int pendingExtLoads; Loading @@ -56,13 +57,11 @@ public class AdnRecordLoader extends Handler { //***** Constructor public AdnRecordLoader(PhoneBase phone) { public AdnRecordLoader(IccFileHandler fh) { // The telephony unit-test cases may create AdnRecords // in secondary threads super(phone.getHandler().getLooper()); this.phone = phone; LOG_TAG = phone.getPhoneName(); super(Looper.getMainLooper()); mFh = fh; } /** Loading @@ -77,7 +76,7 @@ public class AdnRecordLoader extends Handler { this.recordNumber = recordNumber; this.userResponse = response; phone.mIccFileHandler.loadEFLinearFixed( mFh.loadEFLinearFixed( ef, recordNumber, obtainMessage(EVENT_ADN_LOAD_DONE)); Loading @@ -95,7 +94,7 @@ public class AdnRecordLoader extends Handler { this.extensionEF = extensionEF; this.userResponse = response; phone.mIccFileHandler.loadEFLinearFixedAll( mFh.loadEFLinearFixedAll( ef, obtainMessage(EVENT_ADN_LOAD_ALL_DONE)); Loading @@ -122,7 +121,7 @@ public class AdnRecordLoader extends Handler { this.userResponse = response; this.pin2 = pin2; phone.mIccFileHandler.getEFLinearRecordSize( ef, mFh.getEFLinearRecordSize( ef, obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn)); } Loading Loading @@ -163,7 +162,7 @@ public class AdnRecordLoader extends Handler { ar.exception); } phone.mIccFileHandler.updateEFLinearFixed(ef, recordNumber, mFh.updateEFLinearFixed(ef, recordNumber, data, pin2, obtainMessage(EVENT_UPDATE_RECORD_DONE)); pendingExtLoads = 1; Loading Loading @@ -203,7 +202,7 @@ public class AdnRecordLoader extends Handler { pendingExtLoads = 1; phone.mIccFileHandler.loadEFLinearFixed( mFh.loadEFLinearFixed( extensionEF, adn.extRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn)); } Loading Loading @@ -253,7 +252,7 @@ public class AdnRecordLoader extends Handler { pendingExtLoads++; phone.mIccFileHandler.loadEFLinearFixed( mFh.loadEFLinearFixed( extensionEF, adn.extRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn)); } Loading telephony/java/com/android/internal/telephony/IccCard.java +3 −2 Original line number Diff line number Diff line Loading @@ -185,13 +185,14 @@ public class IccCard { mPhone.mCM, mHandler, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null); if (phone.mCM.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE && phone instanceof CDMALTEPhone) { mIccRecords = new CdmaLteUiccRecords(phone); mIccFileHandler = new CdmaLteUiccFileHandler(this, "", mPhone.mCM); mIccRecords = new CdmaLteUiccRecords(this, mPhone.mContext, mPhone.mCM); } else { mIccRecords = is3gpp ? new SIMRecords(phone) : new RuimRecords(phone); // Correct aid will be set later (when GET_SIM_STATUS returns) mIccFileHandler = is3gpp ? new SIMFileHandler(this, "", mPhone.mCM) : new RuimFileHandler(this, "", mPhone.mCM); mIccRecords = is3gpp ? new SIMRecords(this, mPhone.mContext, mPhone.mCM) : new RuimRecords(this, mPhone.mContext, mPhone.mCM); } mPhone.mCM.registerForOffOrNotAvailable(mHandler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); mPhone.mCM.registerForOn(mHandler, EVENT_RADIO_ON, null); Loading telephony/java/com/android/internal/telephony/IccRecords.java +58 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.content.Context; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; Loading @@ -32,9 +33,16 @@ public abstract class IccRecords extends Handler implements IccConstants { protected static final boolean DBG = true; // ***** Instance Variables protected boolean mDestroyed = false; // set to true once this object needs to be disposed of protected Context mContext; protected CommandsInterface mCi; protected IccFileHandler mFh; protected IccCard mParentCard; protected PhoneBase phone; protected RegistrantList recordsLoadedRegistrants = new RegistrantList(); protected RegistrantList mRecordsEventsRegistrants = new RegistrantList(); protected RegistrantList mNewSmsRegistrants = new RegistrantList(); protected RegistrantList mNetworkSelectionModeAutomaticRegistrants = new RegistrantList(); protected int recordsToLoad; // number of pending load requests Loading Loading @@ -71,6 +79,9 @@ public abstract class IccRecords extends Handler implements IccConstants { // ***** Event Constants protected static final int EVENT_SET_MSISDN_DONE = 30; public static final int EVENT_MWI = 0; public static final int EVENT_CFI = 1; public static final int EVENT_SPN = 2; public static final int EVENT_GET_ICC_RECORD_DONE = 100; Loading @@ -91,15 +102,23 @@ public abstract class IccRecords extends Handler implements IccConstants { } // ***** Constructor public IccRecords(PhoneBase p) { this.phone = p; public IccRecords(IccCard card, Context c, CommandsInterface ci) { mContext = c; mCi = ci; mFh = card.getIccFileHandler(); mParentCard = card; } /** * Call when the IccRecords object is no longer going to be used. */ public abstract void dispose(); public void dispose() { mDestroyed = true; mParentCard = null; mFh = null; mCi = null; mContext = null; } protected abstract void onRadioOffOrNotAvailable(); public abstract void onReady(); Loading @@ -109,7 +128,15 @@ public abstract class IccRecords extends Handler implements IccConstants { return adnCache; } public IccCard getIccCard() { return mParentCard; } public void registerForRecordsLoaded(Handler h, int what, Object obj) { if (mDestroyed) { return; } Registrant r = new Registrant(h, what, obj); recordsLoadedRegistrants.add(r); Loading @@ -117,11 +144,35 @@ public abstract class IccRecords extends Handler implements IccConstants { r.notifyRegistrant(new AsyncResult(null, null, null)); } } public void unregisterForRecordsLoaded(Handler h) { recordsLoadedRegistrants.remove(h); } public void registerForRecordsEvents(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mRecordsEventsRegistrants.add(r); } public void unregisterForRecordsEvents(Handler h) { mRecordsEventsRegistrants.remove(h); } public void registerForNewSms(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mNewSmsRegistrants.add(r); } public void unregisterForNewSms(Handler h) { mNewSmsRegistrants.remove(h); } public void registerForNetworkSelectionModeAutomatic( Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mNetworkSelectionModeAutomaticRegistrants.add(r); } public void unregisterForNetworkSelectionModeAutomatic(Handler h) { mNetworkSelectionModeAutomaticRegistrants.remove(h); } /** * Get the International Mobile Subscriber ID (IMSI) on a SIM * for GSM, UMTS and like networks. Default is null if IMSI is Loading Loading @@ -163,7 +214,7 @@ public abstract class IccRecords extends Handler implements IccConstants { AdnRecord adn = new AdnRecord(msisdnTag, msisdn); new AdnRecordLoader(phone).updateEF(adn, EF_MSISDN, EF_EXT1, 1, null, new AdnRecordLoader(mFh).updateEF(adn, EF_MSISDN, EF_EXT1, 1, null, obtainMessage(EVENT_SET_MSISDN_DONE, onComplete)); } Loading telephony/java/com/android/internal/telephony/MccTable.java +71 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.app.ActivityManagerNative; import android.app.AlarmManager; import android.app.IActivityManager; import android.content.Context; import android.content.res.Configuration; import android.net.wifi.WifiManager; Loading Loading @@ -167,10 +168,10 @@ public final class MccTable /** * Updates MCC and MNC device configuration information for application retrieving * correct version of resources. If either MCC or MNC is 0, they will be ignored (not set). * @param phone PhoneBae to act on. * @param context Context to act on. * @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end */ public static void updateMccMncConfiguration(PhoneBase phone, String mccmnc) { public static void updateMccMncConfiguration(Context context, String mccmnc) { if (!TextUtils.isEmpty(mccmnc)) { int mcc, mnc; Loading @@ -185,9 +186,9 @@ public final class MccTable Log.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc); if (mcc != 0) { setTimezoneFromMccIfNeeded(phone, mcc); setLocaleFromMccIfNeeded(phone, mcc); setWifiCountryCodeFromMcc(phone, mcc); setTimezoneFromMccIfNeeded(context, mcc); setLocaleFromMccIfNeeded(context, mcc); setWifiCountryCodeFromMcc(context, mcc); } try { Configuration config = ActivityManagerNative.getDefault().getConfiguration(); Loading @@ -204,17 +205,69 @@ public final class MccTable } } /** * Utility code to set the system locale if it's not set already * @param context Context to act on. * @param language Two character language code desired * @param country Two character country code desired * * {@hide} */ public static void setSystemLocale(Context context, String language, String country) { String l = SystemProperties.get("persist.sys.language"); String c = SystemProperties.get("persist.sys.country"); if (null == language) { return; // no match possible } language = language.toLowerCase(); if (null == country) { country = ""; } country = country.toUpperCase(); if((null == l || 0 == l.length()) && (null == c || 0 == c.length())) { try { // try to find a good match String[] locales = context.getAssets().getLocales(); final int N = locales.length; String bestMatch = null; for(int i = 0; i < N; i++) { // only match full (lang + country) locales if (locales[i]!=null && locales[i].length() >= 5 && locales[i].substring(0,2).equals(language)) { if (locales[i].substring(3,5).equals(country)) { bestMatch = locales[i]; break; } else if (null == bestMatch) { bestMatch = locales[i]; } } } if (null != bestMatch) { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); config.locale = new Locale(bestMatch.substring(0,2), bestMatch.substring(3,5)); config.userSetLocale = true; am.updateConfiguration(config); } } catch (Exception e) { // Intentionally left blank } } } /** * If the timezone is not already set, set it based on the MCC of the SIM. * @param phone PhoneBase to act on (get context from). * @param context Context to act on. * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA) */ private static void setTimezoneFromMccIfNeeded(PhoneBase phone, int mcc) { private static void setTimezoneFromMccIfNeeded(Context context, int mcc) { String timezone = SystemProperties.get(ServiceStateTracker.TIMEZONE_PROPERTY); if (timezone == null || timezone.length() == 0) { String zoneId = defaultTimeZoneForMcc(mcc); if (zoneId != null && zoneId.length() > 0) { Context context = phone.getContext(); // Set time zone based on MCC AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Loading @@ -226,27 +279,31 @@ public final class MccTable /** * If the locale is not already set, set it based on the MCC of the SIM. * @param phone PhoneBase to act on. * @param context Context to act on. * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA) */ private static void setLocaleFromMccIfNeeded(PhoneBase phone, int mcc) { private static void setLocaleFromMccIfNeeded(Context context, int mcc) { if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) { // 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. return; } String language = MccTable.defaultLanguageForMcc(mcc); String country = MccTable.countryCodeForMcc(mcc); Log.d(LOG_TAG, "locale set to "+language+"_"+country); phone.setSystemLocale(language, country, true); setSystemLocale(context, language, country); } /** * If the number of allowed wifi channels has not been set, set it based on * the MCC of the SIM. * @param phone PhoneBase to act on (get context from). * @param context Context to act on. * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA) */ private static void setWifiCountryCodeFromMcc(PhoneBase phone, int mcc) { private static void setWifiCountryCodeFromMcc(Context context, int mcc) { String country = MccTable.countryCodeForMcc(mcc); if (!country.isEmpty()) { Context context = phone.getContext(); Log.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country); WifiManager wM = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); //persist Loading Loading
telephony/java/com/android/internal/telephony/AdnRecordCache.java +7 −7 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import java.util.Iterator; public final class AdnRecordCache extends Handler implements IccConstants { //***** Instance Variables PhoneBase phone; private IccFileHandler mFh; private UsimPhoneBookManager mUsimPhoneBookManager; // Indexed by EF ID Loading @@ -56,9 +56,9 @@ public final class AdnRecordCache extends Handler implements IccConstants { public AdnRecordCache(PhoneBase phone) { this.phone = phone; mUsimPhoneBookManager = new UsimPhoneBookManager(phone, this); public AdnRecordCache(IccFileHandler fh) { mFh = fh; mUsimPhoneBookManager = new UsimPhoneBookManager(mFh, this); } //***** Called from SIMRecords Loading Loading @@ -155,7 +155,7 @@ public final class AdnRecordCache extends Handler implements IccConstants { userWriteResponse.put(efid, response); new AdnRecordLoader(phone).updateEF(adn, efid, extensionEF, new AdnRecordLoader(mFh).updateEF(adn, efid, extensionEF, recordIndex, pin2, obtainMessage(EVENT_UPDATE_ADN_DONE, efid, recordIndex, adn)); } Loading Loading @@ -233,7 +233,7 @@ public final class AdnRecordCache extends Handler implements IccConstants { userWriteResponse.put(efid, response); new AdnRecordLoader(phone).updateEF(newAdn, efid, extensionEF, new AdnRecordLoader(mFh).updateEF(newAdn, efid, extensionEF, index, pin2, obtainMessage(EVENT_UPDATE_ADN_DONE, efid, index, newAdn)); } Loading Loading @@ -296,7 +296,7 @@ public final class AdnRecordCache extends Handler implements IccConstants { return; } new AdnRecordLoader(phone).loadAllFromEF(efid, extensionEf, new AdnRecordLoader(mFh).loadAllFromEF(efid, extensionEf, obtainMessage(EVENT_LOAD_ALL_ADN_LIKE_DONE, efid, 0)); } Loading
telephony/java/com/android/internal/telephony/AdnRecordLoader.java +12 −13 Original line number Diff line number Diff line Loading @@ -20,16 +20,17 @@ import java.util.ArrayList; import android.os.AsyncResult; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.Log; public class AdnRecordLoader extends Handler { static String LOG_TAG; final static String LOG_TAG = "RIL_AdnRecordLoader"; //***** Instance Variables PhoneBase phone; private IccFileHandler mFh; int ef; int extensionEF; int pendingExtLoads; Loading @@ -56,13 +57,11 @@ public class AdnRecordLoader extends Handler { //***** Constructor public AdnRecordLoader(PhoneBase phone) { public AdnRecordLoader(IccFileHandler fh) { // The telephony unit-test cases may create AdnRecords // in secondary threads super(phone.getHandler().getLooper()); this.phone = phone; LOG_TAG = phone.getPhoneName(); super(Looper.getMainLooper()); mFh = fh; } /** Loading @@ -77,7 +76,7 @@ public class AdnRecordLoader extends Handler { this.recordNumber = recordNumber; this.userResponse = response; phone.mIccFileHandler.loadEFLinearFixed( mFh.loadEFLinearFixed( ef, recordNumber, obtainMessage(EVENT_ADN_LOAD_DONE)); Loading @@ -95,7 +94,7 @@ public class AdnRecordLoader extends Handler { this.extensionEF = extensionEF; this.userResponse = response; phone.mIccFileHandler.loadEFLinearFixedAll( mFh.loadEFLinearFixedAll( ef, obtainMessage(EVENT_ADN_LOAD_ALL_DONE)); Loading @@ -122,7 +121,7 @@ public class AdnRecordLoader extends Handler { this.userResponse = response; this.pin2 = pin2; phone.mIccFileHandler.getEFLinearRecordSize( ef, mFh.getEFLinearRecordSize( ef, obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn)); } Loading Loading @@ -163,7 +162,7 @@ public class AdnRecordLoader extends Handler { ar.exception); } phone.mIccFileHandler.updateEFLinearFixed(ef, recordNumber, mFh.updateEFLinearFixed(ef, recordNumber, data, pin2, obtainMessage(EVENT_UPDATE_RECORD_DONE)); pendingExtLoads = 1; Loading Loading @@ -203,7 +202,7 @@ public class AdnRecordLoader extends Handler { pendingExtLoads = 1; phone.mIccFileHandler.loadEFLinearFixed( mFh.loadEFLinearFixed( extensionEF, adn.extRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn)); } Loading Loading @@ -253,7 +252,7 @@ public class AdnRecordLoader extends Handler { pendingExtLoads++; phone.mIccFileHandler.loadEFLinearFixed( mFh.loadEFLinearFixed( extensionEF, adn.extRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn)); } Loading
telephony/java/com/android/internal/telephony/IccCard.java +3 −2 Original line number Diff line number Diff line Loading @@ -185,13 +185,14 @@ public class IccCard { mPhone.mCM, mHandler, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null); if (phone.mCM.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE && phone instanceof CDMALTEPhone) { mIccRecords = new CdmaLteUiccRecords(phone); mIccFileHandler = new CdmaLteUiccFileHandler(this, "", mPhone.mCM); mIccRecords = new CdmaLteUiccRecords(this, mPhone.mContext, mPhone.mCM); } else { mIccRecords = is3gpp ? new SIMRecords(phone) : new RuimRecords(phone); // Correct aid will be set later (when GET_SIM_STATUS returns) mIccFileHandler = is3gpp ? new SIMFileHandler(this, "", mPhone.mCM) : new RuimFileHandler(this, "", mPhone.mCM); mIccRecords = is3gpp ? new SIMRecords(this, mPhone.mContext, mPhone.mCM) : new RuimRecords(this, mPhone.mContext, mPhone.mCM); } mPhone.mCM.registerForOffOrNotAvailable(mHandler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); mPhone.mCM.registerForOn(mHandler, EVENT_RADIO_ON, null); Loading
telephony/java/com/android/internal/telephony/IccRecords.java +58 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.content.Context; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; Loading @@ -32,9 +33,16 @@ public abstract class IccRecords extends Handler implements IccConstants { protected static final boolean DBG = true; // ***** Instance Variables protected boolean mDestroyed = false; // set to true once this object needs to be disposed of protected Context mContext; protected CommandsInterface mCi; protected IccFileHandler mFh; protected IccCard mParentCard; protected PhoneBase phone; protected RegistrantList recordsLoadedRegistrants = new RegistrantList(); protected RegistrantList mRecordsEventsRegistrants = new RegistrantList(); protected RegistrantList mNewSmsRegistrants = new RegistrantList(); protected RegistrantList mNetworkSelectionModeAutomaticRegistrants = new RegistrantList(); protected int recordsToLoad; // number of pending load requests Loading Loading @@ -71,6 +79,9 @@ public abstract class IccRecords extends Handler implements IccConstants { // ***** Event Constants protected static final int EVENT_SET_MSISDN_DONE = 30; public static final int EVENT_MWI = 0; public static final int EVENT_CFI = 1; public static final int EVENT_SPN = 2; public static final int EVENT_GET_ICC_RECORD_DONE = 100; Loading @@ -91,15 +102,23 @@ public abstract class IccRecords extends Handler implements IccConstants { } // ***** Constructor public IccRecords(PhoneBase p) { this.phone = p; public IccRecords(IccCard card, Context c, CommandsInterface ci) { mContext = c; mCi = ci; mFh = card.getIccFileHandler(); mParentCard = card; } /** * Call when the IccRecords object is no longer going to be used. */ public abstract void dispose(); public void dispose() { mDestroyed = true; mParentCard = null; mFh = null; mCi = null; mContext = null; } protected abstract void onRadioOffOrNotAvailable(); public abstract void onReady(); Loading @@ -109,7 +128,15 @@ public abstract class IccRecords extends Handler implements IccConstants { return adnCache; } public IccCard getIccCard() { return mParentCard; } public void registerForRecordsLoaded(Handler h, int what, Object obj) { if (mDestroyed) { return; } Registrant r = new Registrant(h, what, obj); recordsLoadedRegistrants.add(r); Loading @@ -117,11 +144,35 @@ public abstract class IccRecords extends Handler implements IccConstants { r.notifyRegistrant(new AsyncResult(null, null, null)); } } public void unregisterForRecordsLoaded(Handler h) { recordsLoadedRegistrants.remove(h); } public void registerForRecordsEvents(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mRecordsEventsRegistrants.add(r); } public void unregisterForRecordsEvents(Handler h) { mRecordsEventsRegistrants.remove(h); } public void registerForNewSms(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mNewSmsRegistrants.add(r); } public void unregisterForNewSms(Handler h) { mNewSmsRegistrants.remove(h); } public void registerForNetworkSelectionModeAutomatic( Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mNetworkSelectionModeAutomaticRegistrants.add(r); } public void unregisterForNetworkSelectionModeAutomatic(Handler h) { mNetworkSelectionModeAutomaticRegistrants.remove(h); } /** * Get the International Mobile Subscriber ID (IMSI) on a SIM * for GSM, UMTS and like networks. Default is null if IMSI is Loading Loading @@ -163,7 +214,7 @@ public abstract class IccRecords extends Handler implements IccConstants { AdnRecord adn = new AdnRecord(msisdnTag, msisdn); new AdnRecordLoader(phone).updateEF(adn, EF_MSISDN, EF_EXT1, 1, null, new AdnRecordLoader(mFh).updateEF(adn, EF_MSISDN, EF_EXT1, 1, null, obtainMessage(EVENT_SET_MSISDN_DONE, onComplete)); } Loading
telephony/java/com/android/internal/telephony/MccTable.java +71 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.app.ActivityManagerNative; import android.app.AlarmManager; import android.app.IActivityManager; import android.content.Context; import android.content.res.Configuration; import android.net.wifi.WifiManager; Loading Loading @@ -167,10 +168,10 @@ public final class MccTable /** * Updates MCC and MNC device configuration information for application retrieving * correct version of resources. If either MCC or MNC is 0, they will be ignored (not set). * @param phone PhoneBae to act on. * @param context Context to act on. * @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end */ public static void updateMccMncConfiguration(PhoneBase phone, String mccmnc) { public static void updateMccMncConfiguration(Context context, String mccmnc) { if (!TextUtils.isEmpty(mccmnc)) { int mcc, mnc; Loading @@ -185,9 +186,9 @@ public final class MccTable Log.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc); if (mcc != 0) { setTimezoneFromMccIfNeeded(phone, mcc); setLocaleFromMccIfNeeded(phone, mcc); setWifiCountryCodeFromMcc(phone, mcc); setTimezoneFromMccIfNeeded(context, mcc); setLocaleFromMccIfNeeded(context, mcc); setWifiCountryCodeFromMcc(context, mcc); } try { Configuration config = ActivityManagerNative.getDefault().getConfiguration(); Loading @@ -204,17 +205,69 @@ public final class MccTable } } /** * Utility code to set the system locale if it's not set already * @param context Context to act on. * @param language Two character language code desired * @param country Two character country code desired * * {@hide} */ public static void setSystemLocale(Context context, String language, String country) { String l = SystemProperties.get("persist.sys.language"); String c = SystemProperties.get("persist.sys.country"); if (null == language) { return; // no match possible } language = language.toLowerCase(); if (null == country) { country = ""; } country = country.toUpperCase(); if((null == l || 0 == l.length()) && (null == c || 0 == c.length())) { try { // try to find a good match String[] locales = context.getAssets().getLocales(); final int N = locales.length; String bestMatch = null; for(int i = 0; i < N; i++) { // only match full (lang + country) locales if (locales[i]!=null && locales[i].length() >= 5 && locales[i].substring(0,2).equals(language)) { if (locales[i].substring(3,5).equals(country)) { bestMatch = locales[i]; break; } else if (null == bestMatch) { bestMatch = locales[i]; } } } if (null != bestMatch) { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); config.locale = new Locale(bestMatch.substring(0,2), bestMatch.substring(3,5)); config.userSetLocale = true; am.updateConfiguration(config); } } catch (Exception e) { // Intentionally left blank } } } /** * If the timezone is not already set, set it based on the MCC of the SIM. * @param phone PhoneBase to act on (get context from). * @param context Context to act on. * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA) */ private static void setTimezoneFromMccIfNeeded(PhoneBase phone, int mcc) { private static void setTimezoneFromMccIfNeeded(Context context, int mcc) { String timezone = SystemProperties.get(ServiceStateTracker.TIMEZONE_PROPERTY); if (timezone == null || timezone.length() == 0) { String zoneId = defaultTimeZoneForMcc(mcc); if (zoneId != null && zoneId.length() > 0) { Context context = phone.getContext(); // Set time zone based on MCC AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Loading @@ -226,27 +279,31 @@ public final class MccTable /** * If the locale is not already set, set it based on the MCC of the SIM. * @param phone PhoneBase to act on. * @param context Context to act on. * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA) */ private static void setLocaleFromMccIfNeeded(PhoneBase phone, int mcc) { private static void setLocaleFromMccIfNeeded(Context context, int mcc) { if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) { // 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. return; } String language = MccTable.defaultLanguageForMcc(mcc); String country = MccTable.countryCodeForMcc(mcc); Log.d(LOG_TAG, "locale set to "+language+"_"+country); phone.setSystemLocale(language, country, true); setSystemLocale(context, language, country); } /** * If the number of allowed wifi channels has not been set, set it based on * the MCC of the SIM. * @param phone PhoneBase to act on (get context from). * @param context Context to act on. * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA) */ private static void setWifiCountryCodeFromMcc(PhoneBase phone, int mcc) { private static void setWifiCountryCodeFromMcc(Context context, int mcc) { String country = MccTable.countryCodeForMcc(mcc); if (!country.isEmpty()) { Context context = phone.getContext(); Log.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country); WifiManager wM = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); //persist Loading