diff options
author | Sharvil Nanavati <sharvil@google.com> | 2016-03-03 14:12:19 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-03-03 14:12:19 +0000 |
commit | 2791875608a19bde5bf431294502a9b138125278 (patch) | |
tree | e5157c133a328c3489d079968c6c448a3d19b977 /service | |
parent | 90ee0a6ad4ce8ac3280fd07a0b148d82678fc6a0 (diff) | |
parent | 799d849a809a8f98bf13ac5cbbb441882d35509f (diff) |
Merge "Make sure WiFi country code gets set properly." into mm-wireless-dev
am: 799d849a80
* commit '799d849a809a8f98bf13ac5cbbb441882d35509f':
Make sure WiFi country code gets set properly.
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 5b34dd5c4..e24de0d23 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -426,6 +426,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 @@ -2576,18 +2577,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); } @@ -5468,17 +5468,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: |