diff options
author | Mike J. Chen <mjchen@google.com> | 2011-09-30 18:05:44 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@google.com> | 2012-02-10 10:51:22 -0800 |
commit | 4bcbefdc5f24702dbbae485d016997e3efb5e5cc (patch) | |
tree | 00d6573de75498979520fd433694729d4f949d6c | |
parent | 22a7cb8d4941bfb0a6d843cac7e21257ee12d683 (diff) | |
download | frameworks_base-4bcbefdc5f24702dbbae485d016997e3efb5e5cc.zip frameworks_base-4bcbefdc5f24702dbbae485d016997e3efb5e5cc.tar.gz frameworks_base-4bcbefdc5f24702dbbae485d016997e3efb5e5cc.tar.bz2 |
Fix disconnect from wired ethernet issues.
When a cable was unplugged, we were telling the driver to release the
ip address so if a cable on a different network was plugged in, it would
still try to use it's old ip address on the new network, which probably
didn't work.
Also, we didn't notify ConnectivityService about the state change in
the unplug case. Some of this was done in the interface removed case,
but we never remove the interface in Tungsten, just unplug. So refactor
the common disconnect code into a disconnect() function that's called
by both the link status change (unplug) and interface removal (only applies
to things like USB ethernet dongles) cases.
Signed-off-by: Mike J. Chen <mjchen@google.com>
-rw-r--r-- | core/java/android/net/EthernetDataTracker.java | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java index 21ecc22..02e81b6 100644 --- a/core/java/android/net/EthernetDataTracker.java +++ b/core/java/android/net/EthernetDataTracker.java @@ -79,10 +79,7 @@ public class EthernetDataTracker implements NetworkStateTracker { if (up) { mTracker.reconnect(); } else { - NetworkUtils.stopDhcp(mIface); - mTracker.mNetworkInfo.setIsAvailable(false); - mTracker.mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, - null, null); + mTracker.disconnect(); } } } @@ -129,11 +126,7 @@ public class EthernetDataTracker implements NetworkStateTracker { runDhcp(); } - private void interfaceRemoved(String iface) { - if (!iface.equals(mIface)) - return; - - Log.d(TAG, "Removing " + iface); + public void disconnect() { NetworkUtils.stopDhcp(mIface); @@ -147,6 +140,21 @@ public class EthernetDataTracker implements NetworkStateTracker { msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); + IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); + INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); + try { + service.clearInterfaceAddresses(mIface); + } catch (Exception e) { + Log.e(TAG, "Failed to clear addresses or disable ipv6" + e); + } + } + + private void interfaceRemoved(String iface) { + if (!iface.equals(mIface)) + return; + + Log.d(TAG, "Removing " + iface); + disconnect(); mIface = ""; } |