diff options
author | Ningyuan Wang <nywang@google.com> | 2016-07-27 21:28:41 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-07-27 21:28:41 +0000 |
commit | cc1fe23b4a0afab4721465124fd30e9f349be243 (patch) | |
tree | a0b0f351f093080ae7c96402bf35c5ae0e7d9d3b /service | |
parent | 828b94eca5e0ffa67448f67a9dfb4d7eb492312a (diff) | |
parent | 37b06cd7aae7fe27cfaf1d95cc9901548765406b (diff) | |
download | wifi-cc1fe23b4a0afab4721465124fd30e9f349be243.tar.gz |
Fix tethering failure when wifi is not started
am: 37b06cd7aa
Change-Id: I580188c104f1729927834f95efe98a722aaa31ce
Diffstat (limited to 'service')
3 files changed, 38 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiCountryCode.java b/service/java/com/android/server/wifi/WifiCountryCode.java index bd9b14b4b..13396562a 100644 --- a/service/java/com/android/server/wifi/WifiCountryCode.java +++ b/service/java/com/android/server/wifi/WifiCountryCode.java @@ -21,6 +21,9 @@ import android.util.Log; /** * Provide functions for making changes to WiFi country code. + * This Country Code is from MCC or phone default setting. This class sends Country Code + * to driver through wpa_supplicant when WifiStateMachine marks current state as ready + * using setReadyForChange(true). */ public class WifiCountryCode { private static final String TAG = "WifiCountryCode"; @@ -149,12 +152,29 @@ public class WifiCountryCode { } /** - * @return Get the current country code, returns null if no country code is set. + * Method to get the Country Code that was sent to wpa_supplicant. + * + * @return Returns the local copy of the Country Code that was sent to the driver upon + * setReadyForChange(true). + * If wpa_supplicant was never started, this may be null even if a SIM reported a valid + * country code. + * Returns null if no Country Code was sent to driver. */ - public synchronized String getCurrentCountryCode() { + public synchronized String getCountryCodeSentToDriver() { return mCurrentCountryCode; } + /** + * Method to return the currently reported Country Code from the SIM or phone default setting. + * + * @return The currently reported Country Code from the SIM. If there is no Country Code + * reported from SIM, a phone default Country Code will be returned. + * Returns null when there is no Country Code available. + */ + public synchronized String getCountryCode() { + return pickCountryCode(); + } + private void updateCountryCode() { if (DBG) Log.d(TAG, "Update country code"); String country = pickCountryCode(); @@ -163,7 +183,7 @@ public class WifiCountryCode { // 1. Wpa supplicant may silently modify the country code. // 2. If Wifi restarted therefoere wpa_supplicant also restarted, // the country code counld be reset to '00' by wpa_supplicant. - if (country.length() != 0) { + if (country != null) { setCountryCodeNative(country); } // We do not set country code if there is no candidate. This is reasonable @@ -178,8 +198,8 @@ public class WifiCountryCode { if (mDefaultCountryCode != null) { return mDefaultCountryCode; } - // If there is no candidate country code we will return an empty string. - return ""; + // If there is no candidate country code we will return null. + return null; } private boolean setCountryCodeNative(String country) { diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index be24e49a9..740ef6e54 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1127,11 +1127,13 @@ public class WifiServiceImpl extends IWifiManager.Stub { /** * Get the country code - * @return ISO 3166 country code. + * @return Get the best choice country code for wifi, regardless of if it was set or + * not. + * Returns null when there is no country code available. */ public String getCountryCode() { enforceConnectivityInternalPermission(); - String country = mCountryCode.getCurrentCountryCode(); + String country = mCountryCode.getCountryCode(); return country; } /** diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index e3ab3bc43..ab9142020 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -2300,10 +2300,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss pw.println("mUserWantsSuspendOpt " + mUserWantsSuspendOpt); pw.println("mSuspendOptNeedsDisabled " + mSuspendOptNeedsDisabled); pw.println("Supplicant status " + mWifiNative.status(true)); - if (mCountryCode.getCurrentCountryCode() != null) { - pw.println("CurrentCountryCode " + mCountryCode.getCurrentCountryCode()); + if (mCountryCode.getCountryCodeSentToDriver() != null) { + pw.println("CountryCode sent to driver " + mCountryCode.getCountryCodeSentToDriver()); } else { - pw.println("CurrentCountryCode is not initialized"); + if (mCountryCode.getCountryCode() != null) { + pw.println("CountryCode: " + + mCountryCode.getCountryCode() + " was not sent to driver"); + } else { + pw.println("CountryCode was not initialized"); + } } pw.println("mConnectedModeGScanOffloadStarted " + mConnectedModeGScanOffloadStarted); pw.println("mGScanPeriodMilli " + mGScanPeriodMilli); @@ -7669,7 +7674,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss checkAndSetConnectivityInstance(); mSoftApManager = mFacade.makeSoftApManager( mContext, getHandler().getLooper(), mWifiNative, mNwService, - mCm, mCountryCode.getCurrentCountryCode(), + mCm, mCountryCode.getCountryCode(), mWifiApConfigStore.getAllowed2GChannel(), new SoftApListener()); mSoftApManager.start(config); |