diff options
author | Vinit Deshpande <vinitd@google.com> | 2015-09-28 20:57:27 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-28 20:57:27 +0000 |
commit | b45816dc9458590766f7bc79b225e6a6184585bc (patch) | |
tree | 6390a1c2b8668aaf5b98999e31bb60ccb2fcca4b /service/java/com/android/server/wifi/WifiStateMachine.java | |
parent | d2c4a206cbda822a1c1f575fa29975565e4a8ea3 (diff) | |
parent | 98e43e5f48a4c87343fc311feda4fa5489948822 (diff) | |
download | android_frameworks_opt_net_wifi-b45816dc9458590766f7bc79b225e6a6184585bc.tar.gz android_frameworks_opt_net_wifi-b45816dc9458590766f7bc79b225e6a6184585bc.tar.bz2 android_frameworks_opt_net_wifi-b45816dc9458590766f7bc79b225e6a6184585bc.zip |
am 98e43e5f: Don\'t reset country code on mobile signal loss
* commit '98e43e5f48a4c87343fc311feda4fa5489948822':
Don't reset country code on mobile signal loss
Diffstat (limited to 'service/java/com/android/server/wifi/WifiStateMachine.java')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 87ed29cc6..341d3f112 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -2434,24 +2434,32 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno // wifi connection is terminated; ignore resetting of code // 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 - int countryCodeSequence = mCountryCodeSequence.get(); - String currentCountryCode = getCurrentCountryCode(); - - if (countryCodeSequence == 0 - || TextUtils.equals(countryCode, currentCountryCode) == false) { - - countryCodeSequence = mCountryCodeSequence.incrementAndGet(); - if (TextUtils.isEmpty(countryCode)) { - if (mRevertCountryCodeOnCellularLoss && !TextUtils.isEmpty(mDefaultCountryCode)) { - if (DBG) Log.d(TAG,"Reverting wifi country code to default of " - + mDefaultCountryCode); - countryCode = mDefaultCountryCode; - } + + if (TextUtils.isEmpty(countryCode)) { + if (DBG) log("Ignoring resetting of country code"); + } else { + int countryCodeSequence = mCountryCodeSequence.get(); + String currentCountryCode = getCurrentCountryCode(); + if (countryCodeSequence == 0 + || TextUtils.equals(countryCode, currentCountryCode) == false) { + + countryCodeSequence = mCountryCodeSequence.incrementAndGet(); + sendMessage(CMD_SET_COUNTRY_CODE, countryCodeSequence, persist ? 1 : 0, + countryCode); } - sendMessage(CMD_SET_COUNTRY_CODE, countryCodeSequence, persist ? 1 : 0, - countryCode); + } + } + + /** + * reset the country code to default + */ + public synchronized void resetCountryCode() { + if (mRevertCountryCodeOnCellularLoss && TextUtils.isEmpty(mDefaultCountryCode) == false) { + logd("resetting country code to " + mDefaultCountryCode); + setCountryCode(mDefaultCountryCode, /* persist = */ true); } } @@ -2470,14 +2478,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno /** * Get the country code * - * @param countryCode following ISO 3166 format + * @return countryCode following ISO 3166 format */ public String getCurrentCountryCode() { return Settings.Global.getString( mContext.getContentResolver(), Settings.Global.WIFI_COUNTRY_CODE); } - /** * Set the operational frequency band * @@ -3705,9 +3712,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno if (!mRevertCountryCodeOnCellularLoss || TextUtils.isEmpty(mDefaultCountryCode) ) { countryCode = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.WIFI_COUNTRY_CODE); + Log.d(TAG,"Initialize wifi country code to persisted value of " + countryCode); } else { - Log.d(TAG,"Initialize wifi country code to default of " - + mDefaultCountryCode); + Log.d(TAG,"Initialize wifi country code to default of " + mDefaultCountryCode); countryCode = mDefaultCountryCode; } @@ -3735,8 +3742,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } } - - private void setSuspendOptimizationsNative(int reason, boolean enabled) { if (DBG) { log("setSuspendOptimizationsNative: " + reason + " " + enabled |