diff options
author | Vinit Deshpande <vinitd@google.com> | 2015-10-02 21:19:26 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-02 21:19:26 +0000 |
commit | b0f387d0574c8745719af5a7248af399ccef1507 (patch) | |
tree | 2f8d786420fef1d5a1bb18eaae15e0e3ef4b063f | |
parent | 937c699bbef40bc1d4bc14de35d5008e2c0eaf24 (diff) | |
parent | 7ef581ab888c61229ab429e14edc2222ba29de33 (diff) | |
download | android_frameworks_opt_net_wifi-b0f387d0574c8745719af5a7248af399ccef1507.tar.gz android_frameworks_opt_net_wifi-b0f387d0574c8745719af5a7248af399ccef1507.tar.bz2 android_frameworks_opt_net_wifi-b0f387d0574c8745719af5a7248af399ccef1507.zip |
am 7ef581ab: am 70478da8: Persist and use country code reliably
* commit '7ef581ab888c61229ab429e14edc2222ba29de33':
Persist and use country code reliably
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 341d3f112..e33c6ce34 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -1197,7 +1197,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno "but there is no default country code!! Resetting ..."); mRevertCountryCodeOnCellularLoss = false; } else if (mRevertCountryCodeOnCellularLoss) { - logd("will revert to " + mDefaultCountryCode + " on MCC loss"); + logd("initializing with and will revert to " + mDefaultCountryCode + " on MCC loss"); + } + + if (mRevertCountryCodeOnCellularLoss) { + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE, mDefaultCountryCode); } mUserWantsSuspendOpt.set(Settings.Global.getInt(mContext.getContentResolver(), @@ -3708,16 +3713,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno * Set the country code from the system setting value, if any. */ private void initializeCountryCode() { - String countryCode; - 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); - countryCode = mDefaultCountryCode; - } - + String countryCode = getCurrentCountryCode(); if (countryCode != null && !countryCode.isEmpty()) { setCountryCode(countryCode, false); } else { @@ -6117,11 +6113,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } else { loge("Failed to set country code " + country); } - if (persist) { - Settings.Global.putString(mContext.getContentResolver(), - Settings.Global.WIFI_COUNTRY_CODE, - country == null ? "" : country); - } + } + + if (persist) { + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.WIFI_COUNTRY_CODE, + country == null ? "" : country); } mWifiP2pChannel.sendMessage(WifiP2pServiceImpl.SET_COUNTRY_CODE, country); |