diff options
Diffstat (limited to 'telephony')
4 files changed, 98 insertions, 24 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index d3942fc..77669c3 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1003,6 +1003,7 @@ public class PhoneNumberUtils * as: * * <p><code> + * xxxxx * xxx-xxxx * xxx-xxx-xxxx * 1-xxx-xxx-xxxx @@ -1016,7 +1017,11 @@ public class PhoneNumberUtils if (length > "+1-nnn-nnn-nnnn".length()) { // The string is too long to be formatted return; + } else if (length <= 5) { + // The string is either a shortcode or too short to be formatted + return; } + CharSequence saved = text.subSequence(0, length); // Strip the dashes first, as we're going to add them back diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java index 0783fe0..c34f26e 100644 --- a/telephony/java/com/android/internal/telephony/PhoneBase.java +++ b/telephony/java/com/android/internal/telephony/PhoneBase.java @@ -21,6 +21,7 @@ import android.app.IActivityManager; import android.content.Context; import android.content.res.Configuration; import android.content.SharedPreferences; +import android.net.wifi.WifiManager; import android.os.AsyncResult; import android.os.Handler; import android.os.Looper; @@ -28,6 +29,7 @@ import android.os.Message; import android.os.RegistrantList; import android.os.SystemProperties; import android.preference.PreferenceManager; +import android.provider.Settings; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.text.TextUtils; @@ -185,7 +187,7 @@ public abstract class PhoneBase implements Phone { this.mContext = context; mLooper = Looper.myLooper(); - setLocaleByCarrier(); + setPropertiesByCarrier(); setUnitTestMode(unitTestMode); @@ -450,10 +452,10 @@ public abstract class PhoneBase implements Phone { } /** - * Set the locale by matching the carrier string in + * Set the properties by matching the carrier string in * a string-array resource */ - private void setLocaleByCarrier() { + private void setPropertiesByCarrier() { String carrier = SystemProperties.get("ro.carrier"); if (null == carrier || 0 == carrier.length()) { @@ -461,18 +463,36 @@ public abstract class PhoneBase implements Phone { } CharSequence[] carrierLocales = mContext. - getResources().getTextArray(R.array.carrier_locales); + getResources().getTextArray(R.array.carrier_properties); - for (int i = 0; i < carrierLocales.length-1; i+=2) { + for (int i = 0; i < carrierLocales.length; i+=3) { String c = carrierLocales[i].toString(); - String l = carrierLocales[i+1].toString(); if (carrier.equals(c)) { + String l = carrierLocales[i+1].toString(); + int wifiChannels = 0; + try { + wifiChannels = Integer.parseInt( + carrierLocales[i+2].toString()); + } catch (NumberFormatException e) { } + String language = l.substring(0, 2); String country = ""; if (l.length() >=5) { country = l.substring(3, 5); } setSystemLocale(language, country); + + if (wifiChannels != 0) { + try { + Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.WIFI_NUM_ALLOWED_CHANNELS); + } catch (Settings.SettingNotFoundException e) { + // note this is not persisting + WifiManager wM = (WifiManager) + mContext.getSystemService(Context.WIFI_SERVICE); + wM.setNumAllowedChannels(wifiChannels, false); + } + } return; } } diff --git a/telephony/java/com/android/internal/telephony/gsm/MccTable.java b/telephony/java/com/android/internal/telephony/gsm/MccTable.java index e18da56..22b1f4f 100644 --- a/telephony/java/com/android/internal/telephony/gsm/MccTable.java +++ b/telephony/java/com/android/internal/telephony/gsm/MccTable.java @@ -35,6 +35,7 @@ public final class MccTable int smallestDigitsMnc; String timezone; String language; + int wifiChannelsAllowed; MccEntry(int mnc, String iso, int smallestDigitsMCC) { this(mnc, iso, smallestDigitsMCC, null); @@ -45,11 +46,16 @@ public final class MccTable } MccEntry(int mnc, String iso, int smallestDigitsMCC, String timezone, String language) { + this(mnc, iso, smallestDigitsMCC, timezone, language, 0); + } + + MccEntry(int mnc, String iso, int smallestDigitsMCC, String timezone, String language, int wifiChannels) { this.mcc = mnc; this.iso = iso; this.smallestDigitsMnc = smallestDigitsMCC; this.timezone = timezone; this.language = language; + this.wifiChannelsAllowed = wifiChannels; } public int compareTo(MccEntry o) @@ -148,6 +154,23 @@ public final class MccTable } } + /** + * Given a GSM Mobile Country Code, returns + * the number of wifi channels allowed in that country. + * Returns 0 if unavailable + */ + public static int wifiChannelsForMcc(int mcc) { + MccEntry entry; + + entry = entryForMcc(mcc); + + if (entry == null) { + return 0; + } else { + return entry.wifiChannelsAllowed; + } + } + static { table = new ArrayList<MccEntry>(240); @@ -169,7 +192,7 @@ public final class MccTable */ table.add(new MccEntry(202,"gr",2)); //Greece - table.add(new MccEntry(204,"nl",2,"Europe/Amsterdam","nl")); //Netherlands (Kingdom of the) + table.add(new MccEntry(204,"nl",2,"Europe/Amsterdam","nl",13)); //Netherlands (Kingdom of the) table.add(new MccEntry(206,"be",2)); //Belgium table.add(new MccEntry(208,"fr",2,"Europe/Paris","fr")); //France table.add(new MccEntry(212,"mc",2)); //Monaco (Principality of) @@ -183,11 +206,11 @@ public final class MccTable table.add(new MccEntry(225,"va",2,"Europe/Rome","it")); //Vatican City State table.add(new MccEntry(226,"ro",2)); //Romania table.add(new MccEntry(228,"ch",2,"Europe/Zurich","de")); //Switzerland (Confederation of) - table.add(new MccEntry(230,"cz",2,"Europe/Prague","cs")); //Czech Republic + table.add(new MccEntry(230,"cz",2,"Europe/Prague","cs", 13)); //Czech Republic table.add(new MccEntry(231,"sk",2)); //Slovak Republic - table.add(new MccEntry(232,"at",2,"Europe/Vienna","de")); //Austria - table.add(new MccEntry(234,"gb",2,"Europe/London","en")); //United Kingdom of Great Britain and Northern Ireland - table.add(new MccEntry(235,"gb",2,"Europe/London","en")); //United Kingdom of Great Britain and Northern Ireland + table.add(new MccEntry(232,"at",2,"Europe/Vienna","de", 13)); //Austria + table.add(new MccEntry(234,"gb",2,"Europe/London","en", 13)); //United Kingdom of Great Britain and Northern Ireland + table.add(new MccEntry(235,"gb",2,"Europe/London","en", 13)); //United Kingdom of Great Britain and Northern Ireland table.add(new MccEntry(238,"dk",2)); //Denmark table.add(new MccEntry(240,"se",2)); //Sweden table.add(new MccEntry(242,"no",2)); //Norway @@ -200,7 +223,7 @@ public final class MccTable table.add(new MccEntry(257,"by",2)); //Belarus (Republic of) table.add(new MccEntry(259,"md",2)); //Moldova (Republic of) table.add(new MccEntry(260,"pl",2,"Europe/Warsaw")); //Poland (Republic of) - table.add(new MccEntry(262,"de",2,"Europe/Berlin","de")); //Germany (Federal Republic of) + table.add(new MccEntry(262,"de",2,"Europe/Berlin","de", 13)); //Germany (Federal Republic of) table.add(new MccEntry(266,"gi",2)); //Gibraltar table.add(new MccEntry(268,"pt",2)); //Portugal table.add(new MccEntry(270,"lu",2)); //Luxembourg @@ -219,15 +242,15 @@ public final class MccTable table.add(new MccEntry(293,"sl",2)); //Slovenia (Republic of) table.add(new MccEntry(294,"mk",2)); //The Former Yugoslav Republic of Macedonia table.add(new MccEntry(295,"li",2)); //Liechtenstein (Principality of) - table.add(new MccEntry(302,"ca",2)); //Canada + table.add(new MccEntry(302,"ca",2, "", "", 11)); //Canada table.add(new MccEntry(308,"pm",2)); //Saint Pierre and Miquelon (Collectivit territoriale de la Rpublique franaise) - table.add(new MccEntry(310,"us",3,"","en")); //United States of America - table.add(new MccEntry(311,"us",3,"","en")); //United States of America - table.add(new MccEntry(312,"us",3,"","en")); //United States of America - table.add(new MccEntry(313,"us",3,"","en")); //United States of America - table.add(new MccEntry(314,"us",3,"","en")); //United States of America - table.add(new MccEntry(315,"us",3,"","en")); //United States of America - table.add(new MccEntry(316,"us",3,"","en")); //United States of America + table.add(new MccEntry(310,"us",3,"","en", 11)); //United States of America + table.add(new MccEntry(311,"us",3,"","en", 11)); //United States of America + table.add(new MccEntry(312,"us",3,"","en", 11)); //United States of America + table.add(new MccEntry(313,"us",3,"","en", 11)); //United States of America + table.add(new MccEntry(314,"us",3,"","en", 11)); //United States of America + table.add(new MccEntry(315,"us",3,"","en", 11)); //United States of America + table.add(new MccEntry(316,"us",3,"","en", 11)); //United States of America table.add(new MccEntry(330,"pr",2)); //Puerto Rico table.add(new MccEntry(332,"vi",2)); //United States Virgin Islands table.add(new MccEntry(334,"mx",3)); //Mexico @@ -283,8 +306,8 @@ public final class MccTable table.add(new MccEntry(436,"tj",2)); //Tajikistan (Republic of) table.add(new MccEntry(437,"kg",2)); //Kyrgyz Republic table.add(new MccEntry(438,"tm",2)); //Turkmenistan - table.add(new MccEntry(440,"jp",2,"Asia/Tokyo","ja")); //Japan - table.add(new MccEntry(441,"jp",2,"Asia/Tokyo","ja")); //Japan + table.add(new MccEntry(440,"jp",2,"Asia/Tokyo","ja", 14)); //Japan + table.add(new MccEntry(441,"jp",2,"Asia/Tokyo","ja", 14)); //Japan table.add(new MccEntry(450,"kr",2)); //Korea (Republic of) table.add(new MccEntry(452,"vn",2)); //Viet Nam (Socialist Republic of) table.add(new MccEntry(454,"hk",2)); //"Hong Kong, China" @@ -298,12 +321,12 @@ public final class MccTable table.add(new MccEntry(470,"bd",2)); //Bangladesh (People's Republic of) table.add(new MccEntry(472,"mv",2)); //Maldives (Republic of) table.add(new MccEntry(502,"my",2)); //Malaysia - table.add(new MccEntry(505,"au",2,"Australia/Sydney","en")); //Australia + table.add(new MccEntry(505,"au",2,"Australia/Sydney","en", 11)); //Australia table.add(new MccEntry(510,"id",2)); //Indonesia (Republic of) table.add(new MccEntry(514,"tl",2)); //Democratic Republic of Timor-Leste table.add(new MccEntry(515,"ph",2)); //Philippines (Republic of the) table.add(new MccEntry(520,"th",2)); //Thailand - table.add(new MccEntry(525,"sg",2,"Singapore","en")); //Singapore (Republic of) + table.add(new MccEntry(525,"sg",2,"Singapore","en", 11)); //Singapore (Republic of) table.add(new MccEntry(528,"bn",2)); //Brunei Darussalam table.add(new MccEntry(530,"nz",2,"Pacific/Auckland", "en")); //New Zealand table.add(new MccEntry(534,"mp",2)); //Northern Mariana Islands (Commonwealth of the) diff --git a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java index b886410..65d3362 100644 --- a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java +++ b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java @@ -21,11 +21,13 @@ import android.app.AlarmManager; import android.app.IActivityManager; import android.content.Context; import android.content.res.Configuration; +import android.net.wifi.WifiManager; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.SystemProperties; import android.os.Registrant; +import android.provider.Settings; import android.util.Log; import java.util.ArrayList; @@ -513,6 +515,29 @@ public final class SIMRecords extends IccRecords { phone.setSystemLocale(language, country); } + /** + * If the number of allowed wifi channels has not been set, set it based on + * the MCC of the SIM. + * @param mcc Mobile Country Code of the SIM + */ + private void setWifiChannelsFromMccIfNeeded(int mcc) { + int wifiChannels = MccTable.wifiChannelsForMcc(mcc); + + if (wifiChannels != 0) { + Context context = phone.getContext(); + // only set to this default if the user hasn't manually set it + try { + Settings.Secure.getInt(context.getContentResolver(), + Settings.Secure.WIFI_NUM_ALLOWED_CHANNELS); + } catch (Settings.SettingNotFoundException e) { + WifiManager wM = (WifiManager) + context.getSystemService(Context.WIFI_SERVICE); + // don't persist + wM.setNumAllowedChannels(wifiChannels, false); + } + } + } + //***** Overridden from Handler public void handleMessage(Message msg) { AsyncResult ar; @@ -559,6 +584,7 @@ public final class SIMRecords extends IccRecords { int mcc = Integer.parseInt(imsi.substring(0, 3)); setTimezoneFromMccIfNeeded(mcc); setLocaleFromMccIfNeeded(mcc); + setWifiChannelsFromMccIfNeeded(mcc); break; case EVENT_GET_MBI_DONE: |