diff options
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 12 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 35 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 2 |
5 files changed, 48 insertions, 5 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 55de065..1e67938 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -61,6 +61,8 @@ interface IWifiManager void setCountryCode(String country, boolean persist); + String getCountryCode(); + void setFrequencyBand(int band, boolean persist); int getFrequencyBand(); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 0e29882..e3ef913 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -814,6 +814,18 @@ public class WifiManager { } /** + * Get the operational country code. + * @hide + */ + public String getCountryCode() { + try { + return mService.getCountryCode(); + } catch (RemoteException e) { + return null; + } + } + + /** * Set the operational frequency band. * @param band One of * {@link #WIFI_FREQUENCY_BAND_AUTO}, diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 5e25623..733fb91 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -798,4 +798,6 @@ public class WifiNative { public boolean p2pServDiscCancelReq(String id) { return doBooleanCommand("P2P_SERV_DISC_CANCEL_REQ " + id); } + + public native static boolean setMode(int mode); } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index dafa8e8..67e8ac9 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -209,6 +209,9 @@ public class WifiStateMachine extends StateMachine { /* Tracks current frequency mode */ private AtomicInteger mFrequencyBand = new AtomicInteger(WifiManager.WIFI_FREQUENCY_BAND_AUTO); + /* Tracks current country code */ + private String mCountryCode = "GB"; + /* Tracks if we are filtering Multicast v4 packets. Default is to filter. */ private AtomicBoolean mFilteringMulticastV4Packets = new AtomicBoolean(true); @@ -758,6 +761,7 @@ public class WifiStateMachine extends StateMachine { public void setWifiEnabled(boolean enable) { mLastEnableUid.set(Binder.getCallingUid()); if (enable) { + WifiNative.setMode(0); /* Argument is the state that is entered prior to load */ sendMessage(obtainMessage(CMD_LOAD_DRIVER, WIFI_STATE_ENABLING, 0)); sendMessage(CMD_START_SUPPLICANT); @@ -774,6 +778,7 @@ public class WifiStateMachine extends StateMachine { public void setWifiApEnabled(WifiConfiguration wifiConfig, boolean enable) { mLastApEnableUid.set(Binder.getCallingUid()); if (enable) { + WifiNative.setMode(1); /* Argument is the state that is entered prior to load */ sendMessage(obtainMessage(CMD_LOAD_DRIVER, WIFI_AP_STATE_ENABLING, 0)); sendMessage(obtainMessage(CMD_START_AP, wifiConfig)); @@ -1079,6 +1084,13 @@ public class WifiStateMachine extends StateMachine { } /** + * Returns the operational country code + */ + public String getCountryCode() { + return mCountryCode; + } + + /** * Set the operational frequency band * @param band * @param persist {@code true} if the setting should be remembered. @@ -1334,7 +1346,15 @@ public class WifiStateMachine extends StateMachine { if (countryCode != null && !countryCode.isEmpty()) { setCountryCode(countryCode, false); } else { - //use driver default + // On wifi-only devices, some drivers don't find hidden SSIDs unless DRIVER COUNTRY + // is called. Use the default country code to ping the driver. + ConnectivityManager cm = + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + if (!cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) { + setCountryCode(mCountryCode, false); + } + + // In other case, mcc tables from carrier do the trick of starting up the wifi driver } } @@ -2799,9 +2819,12 @@ public class WifiStateMachine extends StateMachine { break; case CMD_SET_COUNTRY_CODE: String country = (String) message.obj; - if (DBG) log("set country code " + country); - if (!mWifiNative.setCountryCode(country.toUpperCase())) { - loge("Failed to set country code " + country); + String countryCode = country != null ? country.toUpperCase() : null; + if (DBG) log("set country code " + countryCode); + if (mWifiNative.setCountryCode(countryCode)) { + mCountryCode = countryCode; + } else { + loge("Failed to set country code " + countryCode); } break; case CMD_SET_FREQUENCY_BAND: @@ -3412,6 +3435,10 @@ public class WifiStateMachine extends StateMachine { case CMD_SET_HIGH_PERF_MODE: deferMessage(message); break; + /* Defer scan request since we should not switch to other channels at DHCP */ + case CMD_START_SCAN: + deferMessage(message); + break; default: return NOT_HANDLED; } diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index 039319d..135b418 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -302,7 +302,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { mContext = context; //STOPSHIP: get this from native side - mInterface = "p2p0"; + mInterface = SystemProperties.get("wifi.p2pinterface", "p2p0"); mActivityMgr = (ActivityManager)context.getSystemService(Activity.ACTIVITY_SERVICE); mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI_P2P, 0, NETWORKTYPE, ""); |