diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2013-10-21 18:09:02 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-21 18:09:02 -0700 |
commit | 405f731a4dccf867166df5a1064b44a791a1696b (patch) | |
tree | 1a95a70f62087192b79789d122fecfff31f46539 /wifi | |
parent | 0cbfafdf706d96a3b2838b8470196ba1f54f2523 (diff) | |
parent | 63dd9d2f550983d890ea21eee9b8f8619608bb79 (diff) | |
download | frameworks_base-405f731a4dccf867166df5a1064b44a791a1696b.zip frameworks_base-405f731a4dccf867166df5a1064b44a791a1696b.tar.gz frameworks_base-405f731a4dccf867166df5a1064b44a791a1696b.tar.bz2 |
am 63dd9d2f: am 4802c6da: am 4d8a8392: Merge "Don\'t set same country code on supplicant again and again" into klp-dev
* commit '63dd9d2f550983d890ea21eee9b8f8619608bb79':
Don't set same country code on supplicant again and again
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 19 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 16 |
2 files changed, 32 insertions, 3 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index f877c48..8c92e55 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -85,6 +85,7 @@ import java.io.PrintWriter; import java.net.InetAddress; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicBoolean; import java.util.Iterator; @@ -494,6 +495,10 @@ public class WifiStateMachine extends StateMachine { // until after, so the write is deferred private volatile String mPersistedCountryCode; + // Supplicant doesn't like setting the same country code multiple times (it may drop + // currently connected network), so we save the country code here to avoid redundency + private String mLastSetCountryCode; + private static final int MIN_RSSI = -200; private static final int MAX_RSSI = 256; @@ -3008,8 +3013,16 @@ public class WifiStateMachine extends StateMachine { case CMD_SET_COUNTRY_CODE: String country = (String) message.obj; if (DBG) log("set country code " + country); - if (!mWifiNative.setCountryCode(country)) { - loge("Failed to set country code " + country); + if (country != null) { + country = country.toUpperCase(Locale.ROOT); + if (mLastSetCountryCode == null + || country.equals(mLastSetCountryCode) == false) { + if (mWifiNative.setCountryCode(country)) { + mLastSetCountryCode = country; + } else { + loge("Failed to set country code " + country); + } + } } break; case CMD_SET_FREQUENCY_BAND: @@ -3142,6 +3155,8 @@ public class WifiStateMachine extends StateMachine { intent.putExtra(WifiManager.EXTRA_SCAN_AVAILABLE, WIFI_STATE_DISABLED); mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); noteScanEnd(); // wrap up any pending request. + + mLastSetCountryCode = null; } } diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index 23058f4..25b2270 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -85,6 +85,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Locale; + /** * WifiP2pService includes a state machine to perform Wi-Fi p2p operations. Applications @@ -201,6 +203,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub { */ private boolean mDiscoveryBlocked; + // Supplicant doesn't like setting the same country code multiple times (it may drop + // current connected network), so we save the country code here to avoid redundency + private String mLastSetCountryCode; + /* * remember if we were in a scan when it had to be stopped */ @@ -1070,7 +1076,13 @@ public class WifiP2pService extends IWifiP2pManager.Stub { break; case SET_COUNTRY_CODE: String countryCode = (String) message.obj; - mWifiNative.setCountryCode(countryCode); + countryCode = countryCode.toUpperCase(Locale.ROOT); + if (mLastSetCountryCode == null || + countryCode.equals(mLastSetCountryCode) == false) { + if (mWifiNative.setCountryCode(countryCode)) { + mLastSetCountryCode = countryCode; + } + } break; default: return NOT_HANDLED; @@ -1083,6 +1095,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub { sendP2pDiscoveryChangedBroadcast(false); sendP2pStateChangedBroadcast(false); mNetworkInfo.setIsAvailable(false); + + mLastSetCountryCode = null; } } |