diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-06-16 10:26:28 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2011-06-17 10:03:13 -0700 |
commit | f5600618df153d9c51388562ebf3524e3bdc8b7d (patch) | |
tree | 00667f737ef4a6a35b6c1955a7143283ed0c56eb /wifi/java/android | |
parent | ad4c9ed7de1c3c3b7781db9c46503263c5bf8464 (diff) | |
download | frameworks_base-f5600618df153d9c51388562ebf3524e3bdc8b7d.zip frameworks_base-f5600618df153d9c51388562ebf3524e3bdc8b7d.tar.gz frameworks_base-f5600618df153d9c51388562ebf3524e3bdc8b7d.tar.bz2 |
Fix IP address cleanup on network disconnect
We used to bring down the interface on network disconnect
which would in turn clean up all the IP addresses.
The interface bringup/shutdown is now handled by wpa_supplicant.
Add netd interface for clearing all IP addresses
Bug: 4676254
Change-Id: I7e24c0ab2e4a412b8d61e9c33ce028966913aaf6
Diffstat (limited to 'wifi/java/android')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 4f5349a..cf25818 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1028,9 +1028,6 @@ public class WifiStateMachine extends StateMachine { boolean wifiTethered = false; boolean wifiAvailable = false; - IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); - if (mCm == null) { mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); } @@ -1043,14 +1040,14 @@ public class WifiStateMachine extends StateMachine { InterfaceConfiguration ifcg = null; try { - ifcg = service.getInterfaceConfig(intf); + ifcg = nwService.getInterfaceConfig(intf); if (ifcg != null) { /* IP/netmask: 192.168.43.1/255.255.255.0 */ ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress( "192.168.43.1"), 24); ifcg.interfaceFlags = "[up]"; - service.setInterfaceConfig(intf, ifcg); + nwService.setInterfaceConfig(intf, ifcg); } } catch (Exception e) { Log.e(TAG, "Error configuring interface " + intf + ", :" + e); @@ -1451,7 +1448,7 @@ public class WifiStateMachine extends StateMachine { * using the interface, stopping DHCP & disabling interface */ private void handleNetworkDisconnect() { - Log.d(TAG, "Reset connections and stopping DHCP"); + Log.d(TAG, "Stopping DHCP and clearing IP"); /* * stop DHCP @@ -1462,6 +1459,12 @@ public class WifiStateMachine extends StateMachine { mDhcpStateMachine = null; } + try { + nwService.clearInterfaceAddresses(mInterfaceName); + } catch (Exception e) { + Log.e(TAG, "Failed to clear IP addresses on disconnect" + e); + } + /* Reset data structures */ mWifiInfo.setInetAddress(null); mWifiInfo.setBSSID(null); @@ -2657,13 +2660,11 @@ public class WifiStateMachine extends StateMachine { } else { DhcpInfoInternal dhcpInfoInternal = WifiConfigStore.getIpConfiguration( mLastNetworkId); - IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - INetworkManagementService netd = INetworkManagementService.Stub.asInterface(b); InterfaceConfiguration ifcg = new InterfaceConfiguration(); ifcg.addr = dhcpInfoInternal.makeLinkAddress(); ifcg.interfaceFlags = "[up]"; try { - netd.setInterfaceConfig(mInterfaceName, ifcg); + nwService.setInterfaceConfig(mInterfaceName, ifcg); Log.v(TAG, "Static IP configuration succeeded"); sendMessage(CMD_STATIC_IP_SUCCESS, dhcpInfoInternal); } catch (RemoteException re) { |