summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl2
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java5
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java2
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java57
4 files changed, 42 insertions, 24 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index fa328e8..73dbb6f 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -58,7 +58,7 @@ interface IWifiManager
int getNumAllowedChannels();
- boolean setNumAllowedChannels(int numChannels);
+ boolean setNumAllowedChannels(int numChannels, boolean persist);
int[] getValidChannelCounts();
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 74f4284..d8a03a9 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -565,14 +565,15 @@ public class WifiManager {
* for some reason.
* @param numChannels the number of allowed channels. Must be greater than 0
* and less than or equal to 16.
+ * @param persist {@code true} if you want this remembered
* @return {@code true} if the operation succeeds, {@code false} otherwise, e.g.,
* {@code numChannels} is out of range.
*
* @hide pending API council
*/
- public boolean setNumAllowedChannels(int numChannels) {
+ public boolean setNumAllowedChannels(int numChannels, boolean persist) {
try {
- return mService.setNumAllowedChannels(numChannels);
+ return mService.setNumAllowedChannels(numChannels, persist);
} catch (RemoteException e) {
return false;
}
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 0799f5f..c3c519f 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -79,6 +79,8 @@ public class WifiNative {
public native static int getRssiCommand();
+ public native static int getRssiApproxCommand();
+
public native static int getLinkSpeedCommand();
public native static String getMacAddressCommand();
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 3aa31bf..083cda3 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -183,6 +183,10 @@ public class WifiStateTracker extends NetworkStateTracker {
private boolean mUseStaticIp = false;
private int mReconnectCount;
+ // used to store the (non-persisted) num determined during device boot
+ // (from mcc or other phone info) before the driver is started.
+ private int mNumAllowedChannels = 0;
+
// Variables relating to the 'available networks' notification
/**
@@ -238,7 +242,6 @@ public class WifiStateTracker extends NetworkStateTracker {
private SettingsObserver mSettingsObserver;
private boolean mIsScanModeActive;
- private boolean mIsScanModeSetDueToAHiddenNetwork;
private boolean mEnableRssiPolling;
// Wi-Fi run states:
@@ -311,7 +314,6 @@ public class WifiStateTracker extends NetworkStateTracker {
mScanResults = new ArrayList<ScanResult>();
// Allocate DHCP info object once, and fill it in on each request
mDhcpInfo = new DhcpInfo();
- mIsScanModeSetDueToAHiddenNetwork = false;
mRunState = RUN_STATE_STARTING;
// Setting is in seconds
@@ -379,6 +381,14 @@ public class WifiStateTracker extends NetworkStateTracker {
}
/**
+ * Return the name of our WLAN network interface.
+ * @return the name of our interface.
+ */
+ public String getInterfaceName() {
+ return mInterfaceName;
+ }
+
+ /**
* Return the system properties name associated with the tcp buffer sizes
* for this network.
*/
@@ -576,9 +586,12 @@ public class WifiStateTracker extends NetworkStateTracker {
try {
return setNumAllowedChannels(
Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.WIFI_NUM_ALLOWED_CHANNELS));
+ Settings.Secure.WIFI_NUM_ALLOWED_CHANNELS));
} catch (Settings.SettingNotFoundException e) {
- // if setting doesn't exist, stick with the driver default
+ if (mNumAllowedChannels != 0) {
+ WifiNative.setNumAllowedChannelsCommand(mNumAllowedChannels);
+ }
+ // otherwise, use the driver default
}
return true;
}
@@ -592,6 +605,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* {@code numChannels} is outside the valid range.
*/
public synchronized boolean setNumAllowedChannels(int numChannels) {
+ mNumAllowedChannels = numChannels;
return WifiNative.setNumAllowedChannelsCommand(numChannels);
}
@@ -790,7 +804,7 @@ public class WifiStateTracker extends NetworkStateTracker {
WifiNative.closeSupplicantConnection();
}
if (died) {
- resetInterface();
+ resetInterface(false);
}
// When supplicant dies, kill the DHCP thread
if (mDhcpTarget != null) {
@@ -1023,17 +1037,12 @@ public class WifiStateTracker extends NetworkStateTracker {
* On receiving the first scan results after connecting to
* the supplicant, switch scan mode over to passive.
*/
- if (!mIsScanModeSetDueToAHiddenNetwork) {
- // This is the only place at the moment where we set
- // the scan mode NOT due to a hidden network. This is
- // what the second parameter value (false) stands for.
- setScanMode(false, false);
- }
+ setScanMode(false);
break;
case EVENT_POLL_INTERVAL:
if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) {
- requestPolledInfo(mWifiInfo);
+ requestPolledInfo(mWifiInfo, true);
checkPollTimer();
}
break;
@@ -1164,9 +1173,7 @@ public class WifiStateTracker extends NetworkStateTracker {
return disabledNetwork;
}
- public synchronized void setScanMode(
- boolean isScanModeActive, boolean setDueToAHiddenNetwork) {
- mIsScanModeSetDueToAHiddenNetwork = setDueToAHiddenNetwork;
+ public synchronized void setScanMode(boolean isScanModeActive) {
if (mIsScanModeActive != isScanModeActive) {
WifiNative.setScanModeCommand(mIsScanModeActive = isScanModeActive);
}
@@ -1206,7 +1213,7 @@ public class WifiStateTracker extends NetworkStateTracker {
cancelDisconnect();
}
mDisconnectExpected = false;
- resetInterface();
+ resetInterface(true);
setDetailedState(newState);
sendNetworkStateChangeBroadcast(mLastBssid);
mWifiInfo.setBSSID(null);
@@ -1219,7 +1226,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* Resets the Wi-Fi interface by clearing any state, resetting any sockets
* using the interface, stopping DHCP, and disabling the interface.
*/
- public void resetInterface() {
+ public void resetInterface(boolean reenable) {
mHaveIpAddress = false;
mObtainingIpAddress = false;
mWifiInfo.setIpAddress(0);
@@ -1240,6 +1247,9 @@ public class WifiStateTracker extends NetworkStateTracker {
}
NetworkUtils.disableInterface(mInterfaceName);
+ if (reenable) {
+ NetworkUtils.enableInterface(mInterfaceName);
+ }
}
/**
@@ -1278,7 +1288,7 @@ public class WifiStateTracker extends NetworkStateTracker {
*/
public WifiInfo requestConnectionInfo() {
requestConnectionStatus(mWifiInfo);
- requestPolledInfo(mWifiInfo);
+ requestPolledInfo(mWifiInfo, false);
return mWifiInfo;
}
@@ -1333,10 +1343,14 @@ public class WifiStateTracker extends NetworkStateTracker {
* Get the dynamic information that is not reported via events.
* @param info the object into which the information should be captured.
*/
- private synchronized void requestPolledInfo(WifiInfo info)
+ private synchronized void requestPolledInfo(WifiInfo info, boolean polling)
{
int newRssi = WifiNative.getRssiCommand();
- if (newRssi != -1 && -200 < newRssi && newRssi < 100) { // screen out invalid values
+ if (newRssi != -1 && -200 < newRssi && newRssi < 256) { // screen out invalid values
+ /* some implementations avoid negative values by adding 256
+ * so we need to adjust for that here.
+ */
+ if (newRssi > 0) newRssi -= 256;
info.setRssi(newRssi);
/*
* Rather then sending the raw RSSI out every time it
@@ -1453,6 +1467,7 @@ public class WifiStateTracker extends NetworkStateTracker {
public synchronized boolean restart() {
if (mRunState == RUN_STATE_STOPPED) {
mRunState = RUN_STATE_STARTING;
+ resetInterface(true);
return WifiNative.startDriverCommand();
} else if (mRunState == RUN_STATE_STOPPING) {
mRunState = RUN_STATE_STARTING;
@@ -1879,7 +1894,7 @@ public class WifiStateTracker extends NetworkStateTracker {
oDns2 != mDhcpInfo.dns2));
if (changed) {
- resetInterface();
+ resetInterface(true);
configureInterface();
if (mUseStaticIp) {
mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED);