From 3ea0c99b67407bb1612875762b037e50f013fd6d Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Thu, 3 Oct 2013 21:13:49 +0000 Subject: [PATCH] Revert "Use a build-specific wifi country code" This reverts commit c33cd23c17c24df33550a6662cedfe60b323604a. bug:11064682 Change-Id: I35825a7005e75f3abf02f23f31dee1cb7b101c31 --- core/java/android/provider/Settings.java | 7 +++++++ core/res/res/values/config.xml | 4 ---- core/res/res/values/symbols.xml | 1 - wifi/java/android/net/wifi/WifiStateMachine.java | 14 ++++++++++++-- wifi/java/android/net/wifi/p2p/WifiP2pService.java | 6 ++++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index b8cccb1c57842..6c6635dfd5310 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2797,6 +2797,7 @@ public final class Settings { MOVED_TO_GLOBAL.add(Settings.Global.USB_MASS_STORAGE_ENABLED); MOVED_TO_GLOBAL.add(Settings.Global.USE_GOOGLE_MAIL); MOVED_TO_GLOBAL.add(Settings.Global.WEB_AUTOFILL_QUERY_URL); + MOVED_TO_GLOBAL.add(Settings.Global.WIFI_COUNTRY_CODE); MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS); MOVED_TO_GLOBAL.add(Settings.Global.WIFI_FREQUENCY_BAND); MOVED_TO_GLOBAL.add(Settings.Global.WIFI_IDLE_MS); @@ -5206,6 +5207,12 @@ public final class Settings { public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = "wifi_networks_available_repeat_delay"; + /** + * 802.11 country code in ISO 3166 format + * @hide + */ + public static final String WIFI_COUNTRY_CODE = "wifi_country_code"; + /** * The interval in milliseconds to issue wake up scans when wifi needs * to connect. This is necessary to connect to an access point when diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index e39fd2a5be4f4..6019e36fac5da 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -352,10 +352,6 @@ false - - US - false diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index c786888e81160..f739bed85eed8 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -817,7 +817,6 @@ - diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 798bc2e0c61c6..76bd636e127ff 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1456,6 +1456,9 @@ public class WifiStateMachine extends StateMachine { public void setCountryCode(String countryCode, boolean persist) { if (persist) { mPersistedCountryCode = countryCode; + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE, + countryCode); } sendMessage(CMD_SET_COUNTRY_CODE, countryCode); mWifiP2pChannel.sendMessage(WifiP2pService.SET_COUNTRY_CODE, countryCode); @@ -1688,8 +1691,8 @@ public class WifiStateMachine extends StateMachine { * Set the country code from the system setting value, if any. */ private void setCountryCode() { - String countryCode = mContext.getResources().getString( - R.string.config_wifi_default_country_code); + String countryCode = Settings.Global.getString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE); if (countryCode != null && !countryCode.isEmpty()) { setCountryCode(countryCode, false); } else { @@ -2414,6 +2417,13 @@ public class WifiStateMachine extends StateMachine { case CMD_BOOT_COMPLETED: String countryCode = mPersistedCountryCode; if (TextUtils.isEmpty(countryCode) == false) { + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE, + countryCode); + // it may be that the state transition that should send this info + // to the driver happened between mPersistedCountryCode getting set + // and now, so simply persisting it here would mean we have sent + // nothing to the driver. Send the cmd so it might be set now. sendMessageAtFrontOfQueue(CMD_SET_COUNTRY_CODE, countryCode); } break; diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index 50e8e3decf689..625ffb8733d4d 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -2545,6 +2545,12 @@ public class WifiP2pService extends IWifiP2pManager.Stub { mServiceTransactionId = 0; mServiceDiscReqId = null; + String countryCode = Settings.Global.getString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE); + if (countryCode != null && !countryCode.isEmpty()) { + mP2pStateMachine.sendMessage(SET_COUNTRY_CODE, countryCode); + } + updatePersistentNetworks(RELOAD); }