diff options
author | Sharvil Nanavati <sharvil@google.com> | 2016-02-25 17:52:12 -0800 |
---|---|---|
committer | Paul Stewart <pstew@google.com> | 2016-03-02 18:59:42 +0000 |
commit | 6c8745470e4819996b3797dbec324b1cb88e892b (patch) | |
tree | 73a99c51b296a3fbf2e2f7b7724217d5a6656b8b /service | |
parent | 6f5af9b7f69b15369238bd2642c46638ba1f0255 (diff) |
Make sure WiFi country code gets set properly.
The current logic forces the country code to be set if it has never
been *attempted* to be set before or if a new country code is being set.
However, it doesn't handle the case where setting the country code with
the driver fails.
This change always forces the country code to be set if it has never
been set for, taking into account potential failures coming back
from the native layer.
Cherry picked from 96cbf09d2430d0f1dc4a06bb62263c56469d63f2
Bug: 25208308
Change-Id: Ie0f03e9a16a0f681b2977f4ee19af9339281a9c0
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index a6f81caed..13c317237 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -429,6 +429,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno private int mWifiLinkLayerStatsSupported = 4; // Temporary disable + private final AtomicBoolean mHasSetCountryCode = new AtomicBoolean(false); private final AtomicInteger mCountryCodeSequence = new AtomicInteger(); // Whether the state machine goes thru the Disconnecting->Disconnected->ObtainingIpAddress @@ -2574,18 +2575,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno // for now (it is unclear what the chipset should do when // country code is reset) - // if mCountryCodeSequence == 0, it is the first time to set country code, always set - // else only when the new country code is different from the current one to set + // Set country code if it has never been set before or if the new country code is different + // from the previous one. if (TextUtils.isEmpty(countryCode)) { if (DBG) log("Ignoring resetting of country code"); } else { - int countryCodeSequence = mCountryCodeSequence.get(); String currentCountryCode = getCurrentCountryCode(); - if (countryCodeSequence == 0 + if (!mHasSetCountryCode.get() || TextUtils.equals(countryCode, currentCountryCode) == false) { - countryCodeSequence = mCountryCodeSequence.incrementAndGet(); + int countryCodeSequence = mCountryCodeSequence.incrementAndGet(); sendMessage(CMD_SET_COUNTRY_CODE, countryCodeSequence, persist ? 1 : 0, countryCode); } @@ -5467,17 +5467,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno if (!TextUtils.equals(mDriverSetCountryCode, country)) { if (mWifiNative.setCountryCode(country)) { mDriverSetCountryCode = country; + mHasSetCountryCode.set(true); + if (persist) { + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE, + country == null ? "" : country); + } } else { loge("Failed to set country code " + country); } } - if (persist) { - Settings.Global.putString(mContext.getContentResolver(), - Settings.Global.WIFI_COUNTRY_CODE, - country == null ? "" : country); - } - mWifiP2pChannel.sendMessage(WifiP2pServiceImpl.SET_COUNTRY_CODE, country); break; case CMD_RESET_SIM_NETWORKS: |