summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2013-03-28 08:54:09 -0700
committerIrfan Sheriff <isheriff@google.com>2013-04-11 15:12:20 -0700
commit51e4ece385c6c34d97d5fa2dcc8e3b2c0bae7c22 (patch)
treefacd9c425481431f46658551006e140a4dde197c /wifi/java/android/net
parent2e68794a3fe08934b006677ac029fec60f5087cf (diff)
downloadframeworks_base-51e4ece385c6c34d97d5fa2dcc8e3b2c0bae7c22.zip
frameworks_base-51e4ece385c6c34d97d5fa2dcc8e3b2c0bae7c22.tar.gz
frameworks_base-51e4ece385c6c34d97d5fa2dcc8e3b2c0bae7c22.tar.bz2
Fix proxy and IP settings
- Network disconnect was clobbering IP and proxy settings. - Track settings correctly in WifiConfigStore Bug: 7299216 Change-Id: I30e5b68e59e30f7b99a71e8d7cf18750c784cec7
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r--wifi/java/android/net/wifi/WifiConfigStore.java15
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java41
2 files changed, 34 insertions, 22 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java
index 7b1a71f..d3d5b1b 100644
--- a/wifi/java/android/net/wifi/WifiConfigStore.java
+++ b/wifi/java/android/net/wifi/WifiConfigStore.java
@@ -634,6 +634,8 @@ class WifiConfigStore {
if (config.priority > mLastPriority) {
mLastPriority = config.priority;
}
+ config.ipAssignment = IpAssignment.DHCP;
+ config.proxySettings = ProxySettings.NONE;
mConfiguredNetworks.put(config.networkId, config);
mNetworkIds.put(configKey(config), config.networkId);
}
@@ -831,8 +833,9 @@ class WifiConfigStore {
while (true) {
int id = -1;
- IpAssignment ipAssignment = IpAssignment.UNASSIGNED;
- ProxySettings proxySettings = ProxySettings.UNASSIGNED;
+ // Default is DHCP with no proxy
+ IpAssignment ipAssignment = IpAssignment.DHCP;
+ ProxySettings proxySettings = ProxySettings.NONE;
LinkProperties linkProperties = new LinkProperties();
String proxyHost = null;
int proxyPort = -1;
@@ -902,7 +905,8 @@ class WifiConfigStore {
config.ipAssignment = ipAssignment;
break;
case UNASSIGNED:
- //Ignore
+ loge("BUG: Found UNASSIGNED IP on file, use DHCP");
+ config.ipAssignment = IpAssignment.DHCP;
break;
default:
loge("Ignore invalid ip assignment while reading");
@@ -920,7 +924,8 @@ class WifiConfigStore {
config.proxySettings = proxySettings;
break;
case UNASSIGNED:
- //Ignore
+ loge("BUG: Found UNASSIGNED proxy on file, use NONE");
+ config.proxySettings = ProxySettings.NONE;
break;
default:
loge("Ignore invalid proxy settings while reading");
@@ -1176,6 +1181,8 @@ class WifiConfigStore {
WifiConfiguration currentConfig = mConfiguredNetworks.get(netId);
if (currentConfig == null) {
currentConfig = new WifiConfiguration();
+ currentConfig.ipAssignment = IpAssignment.DHCP;
+ currentConfig.proxySettings = ProxySettings.NONE;
currentConfig.networkId = netId;
}
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index c0a3bc1..c09e3aa 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1648,15 +1648,7 @@ public class WifiStateMachine extends StateMachine {
private void handleNetworkDisconnect() {
if (DBG) log("Stopping DHCP and clearing IP");
- /*
- * stop DHCP
- */
- if (mDhcpStateMachine != null) {
- /* In case we were in middle of DHCP operation
- restore back powermode */
- handlePostDhcpSetup();
- mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP);
- }
+ stopDhcp();
try {
mNwService.clearInterfaceAddresses(mInterfaceName);
@@ -1734,6 +1726,24 @@ public class WifiStateMachine extends StateMachine {
}
+ void startDhcp() {
+ if (mDhcpStateMachine == null) {
+ mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
+ mContext, WifiStateMachine.this, mInterfaceName);
+
+ }
+ mDhcpStateMachine.registerForPreDhcpNotification();
+ mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
+ }
+
+ void stopDhcp() {
+ if (mDhcpStateMachine != null) {
+ /* In case we were in middle of DHCP operation restore back powermode */
+ handlePostDhcpSetup();
+ mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP);
+ }
+ }
+
void handlePostDhcpSetup() {
/* Restore power save and suspend optimizations */
setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true);
@@ -1751,7 +1761,7 @@ public class WifiStateMachine extends StateMachine {
mDhcpResults = dhcpResults;
}
LinkProperties linkProperties = dhcpResults.linkProperties;
- mWifiConfigStore.setLinkProperties(mLastNetworkId, linkProperties);
+ mWifiConfigStore.setLinkProperties(mLastNetworkId, new LinkProperties(linkProperties));
InetAddress addr = null;
Iterator<InetAddress> addrs = linkProperties.getAddresses().iterator();
if (addrs.hasNext()) {
@@ -2996,15 +3006,10 @@ public class WifiStateMachine extends StateMachine {
@Override
public void enter() {
if (!mWifiConfigStore.isUsingStaticIp(mLastNetworkId)) {
- //start DHCP
- if (mDhcpStateMachine == null) {
- mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
- mContext, WifiStateMachine.this, mInterfaceName);
-
- }
- mDhcpStateMachine.registerForPreDhcpNotification();
- mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
+ startDhcp();
} else {
+ // stop any running dhcp before assigning static IP
+ stopDhcp();
DhcpResults dhcpResults = new DhcpResults(
mWifiConfigStore.getLinkProperties(mLastNetworkId));
dhcpResults.linkProperties.setInterfaceName(mInterfaceName);