diff options
author | Vinit Deshapnde <vinitd@google.com> | 2013-10-21 11:58:40 -0700 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2013-10-21 17:55:12 -0700 |
commit | da40d927667083a5f6bf752ef5fc86d8431dbff7 (patch) | |
tree | ae4cacc7fe8b30f55c30446027238321847e60a7 /wifi/java/android/net/wifi/p2p | |
parent | 644696f0a0bee1714868b9e9cf351f1380e68f39 (diff) | |
download | frameworks_base-da40d927667083a5f6bf752ef5fc86d8431dbff7.zip frameworks_base-da40d927667083a5f6bf752ef5fc86d8431dbff7.tar.gz frameworks_base-da40d927667083a5f6bf752ef5fc86d8431dbff7.tar.bz2 |
Don't set same country code on supplicant again and again
Setting the same code is redundant, and may cause supplicant to drop
currently connected connection.
Bug: 11303252
Change-Id: I1af57b3af2d0b8cc51939a8b9872fb3fe0105a91
Diffstat (limited to 'wifi/java/android/net/wifi/p2p')
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index 625ffb8..8b07208 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; @@ -1082,6 +1094,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub { public void exit() { sendP2pStateChangedBroadcast(false); mNetworkInfo.setIsAvailable(false); + + mLastSetCountryCode = null; } } |