summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2014-06-19 16:26:03 -0700
committerRobert Greenwalt <rgreenwalt@google.com>2014-06-23 16:04:06 -0700
commited75bcf13a0b416843cf8d8e349a3340ae270f9d (patch)
tree675ad860f0c89fcf6e5839d60188e66160e10b7f
parent15a018d81c4bd9c33ac3bd40c84d748375f77277 (diff)
downloadandroid_frameworks_opt_net_ethernet-ed75bcf13a0b416843cf8d8e349a3340ae270f9d.tar.gz
android_frameworks_opt_net_ethernet-ed75bcf13a0b416843cf8d8e349a3340ae270f9d.tar.bz2
android_frameworks_opt_net_ethernet-ed75bcf13a0b416843cf8d8e349a3340ae270f9d.zip
Don't tear down based on NetworkFactory input.
NetworkFactory only indicates if we're interested in new connections. It shouldn't be used to tear down existing connections (they have unwanted callbacks for that). Supports linger properly as well as dealing with tie scores. bug:15612739 Change-Id: Ib3dfe673d3645b9dc4756c176958409a64ec32e4
-rw-r--r--java/com/android/server/ethernet/EthernetNetworkFactory.java51
1 files changed, 25 insertions, 26 deletions
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index 483f983..b1b98d2 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -114,7 +114,6 @@ class EthernetNetworkFactory {
onRequestNetwork();
}
protected void stopNetwork() {
- onCancelRequest();
}
}
@@ -202,13 +201,13 @@ class EthernetNetworkFactory {
return;
Log.d(TAG, "Stopped tracking interface " + iface);
- onCancelRequest();
synchronized (this) {
mIface = "";
mHwAddr = null;
mNetworkInfo.setExtraInfo(null);
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORK_TYPE, "");
mLinkProperties = new LinkProperties();
+ updateAgent();
}
}
@@ -283,6 +282,10 @@ class EthernetNetworkFactory {
}
synchronized(EthernetNetworkFactory.this) {
+ if (mNetworkAgent != null) {
+ Log.e(TAG, "Already have a NetworkAgent - aborting new request");
+ return;
+ }
mLinkProperties = linkProperties;
mNetworkInfo.setIsAvailable(true);
mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, mHwAddr);
@@ -292,7 +295,25 @@ class EthernetNetworkFactory {
NETWORK_TYPE, mNetworkInfo, mNetworkCapabilities, mLinkProperties,
NETWORK_SCORE) {
public void unwanted() {
- EthernetNetworkFactory.this.onCancelRequest();
+ synchronized(EthernetNetworkFactory.this) {
+ if (this == mNetworkAgent) {
+ NetworkUtils.stopDhcp(mIface);
+
+ mLinkProperties.clear();
+ mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null,
+ mHwAddr);
+ updateAgent();
+ mNetworkAgent = null;
+ try {
+ mNMService.clearInterfaceAddresses(mIface);
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to clear addresses or disable ipv6" + e);
+ }
+ } else {
+ Log.d(TAG, "Ignoring unwanted as we have a more modern " +
+ "instance");
+ }
+ }
};
};
}
@@ -302,28 +323,6 @@ class EthernetNetworkFactory {
}
/**
- * Clears layer 3 properties and reports disconnect.
- * Does not touch interface state variables such as link state and MAC address.
- * Called when the tracked interface loses link or disappears.
- */
- public void onCancelRequest() {
- NetworkUtils.stopDhcp(mIface);
-
- synchronized(this) {
- mLinkProperties.clear();
- mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr);
- updateAgent();
- mNetworkAgent = null;
- }
-
- try {
- mNMService.clearInterfaceAddresses(mIface);
- } catch (Exception e) {
- Log.e(TAG, "Failed to clear addresses or disable ipv6" + e);
- }
- }
-
- /**
* Begin monitoring connectivity
*/
public synchronized void start(Context context, Handler target) {
@@ -379,12 +378,12 @@ class EthernetNetworkFactory {
}
public synchronized void stop() {
- onCancelRequest();
mIface = "";
mHwAddr = null;
mLinkUp = false;
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORK_TYPE, "");
mLinkProperties = new LinkProperties();
+ updateAgent();
mFactory.unregister();
}