Created
September 1, 2015 19:23
-
-
Save binkybear/96de1580a99929e7c3e9 to your computer and use it in GitHub Desktop.
Lollipop patch for Android source that does a check for Ethernet and then skips replacing network if found. Allows for eth0 and wlan0 to be active at same time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur A/frameworks/base/services/core/java/com/android/server/ConnectivityService.java B/frameworks/base/services/core/java/com/android/server/ConnectivityService.java | |
--- A/frameworks/base/services/core/java/com/android/server/ConnectivityService.java 2015-09-01 12:55:15.000000000 -0500 | |
+++ B/frameworks/base/services/core/java/com/android/server/ConnectivityService.java 2015-09-01 13:06:55.000000000 -0500 | |
@@ -3915,6 +3915,7 @@ | |
if (!newNetwork.created) loge("ERROR: uncreated network being rematched."); | |
if (nascent && !newNetwork.validated) loge("ERROR: nascent network not validated."); | |
boolean keep = newNetwork.isVPN(); | |
+ boolean keep_ethernet = newNetwork.isETHERNET(); | |
boolean isNewDefault = false; | |
if (DBG) log("rematching " + newNetwork.name()); | |
// Find and migrate to this Network any NetworkRequests for | |
@@ -3950,54 +3951,57 @@ | |
(currentNetwork != null ? currentNetwork.getCurrentScore() : 0) + | |
", newScore = " + newNetwork.getCurrentScore()); | |
} | |
- if (currentNetwork == null || | |
- currentNetwork.getCurrentScore() < newNetwork.getCurrentScore()) { | |
- if (currentNetwork != null) { | |
- if (DBG) log(" accepting network in place of " + currentNetwork.name()); | |
- currentNetwork.networkRequests.remove(nri.request.requestId); | |
- currentNetwork.networkLingered.add(nri.request); | |
- affectedNetworks.add(currentNetwork); | |
- } else { | |
- if (DBG) log(" accepting network in place of null"); | |
- } | |
- mNetworkForRequestId.put(nri.request.requestId, newNetwork); | |
- newNetwork.addRequest(nri.request); | |
- if (nri.isRequest && nri.request.legacyType != TYPE_NONE) { | |
- mLegacyTypeTracker.add(nri.request.legacyType, newNetwork); | |
- } | |
- keep = true; | |
- // Tell NetworkFactories about the new score, so they can stop | |
- // trying to connect if they know they cannot match it. | |
- // TODO - this could get expensive if we have alot of requests for this | |
- // network. Think about if there is a way to reduce this. Push | |
- // netid->request mapping to each factory? | |
- sendUpdatedScoreToFactories(nri.request, newNetwork.getCurrentScore()); | |
- if (mDefaultRequest.requestId == nri.request.requestId) { | |
- isNewDefault = true; | |
- // TODO: Remove following line. It's redundant with makeDefault call. | |
- mActiveDefaultNetwork = newNetwork.networkInfo.getType(); | |
- if (newNetwork.linkProperties != null) { | |
- updateTcpBufferSizes(newNetwork); | |
- setDefaultDnsSystemProperties( | |
- newNetwork.linkProperties.getDnsServers()); | |
+ if (!keep_ethernet) { | |
+ log("[NH] Ethernet should not get past here"); | |
+ if (currentNetwork == null || | |
+ currentNetwork.getCurrentScore() < newNetwork.getCurrentScore()) { | |
+ if (currentNetwork != null) { | |
+ if (DBG) log(" accepting network in place of " + currentNetwork.name()); | |
+ currentNetwork.networkRequests.remove(nri.request.requestId); | |
+ currentNetwork.networkLingered.add(nri.request); | |
+ affectedNetworks.add(currentNetwork); | |
} else { | |
- setDefaultDnsSystemProperties(new ArrayList<InetAddress>()); | |
+ if (DBG) log(" accepting network in place of null"); | |
} | |
- // Maintain the illusion: since the legacy API only | |
- // understands one network at a time, we must pretend | |
- // that the current default network disconnected before | |
- // the new one connected. | |
- if (currentNetwork != null) { | |
- mLegacyTypeTracker.remove(currentNetwork.networkInfo.getType(), | |
- currentNetwork); | |
+ mNetworkForRequestId.put(nri.request.requestId, newNetwork); | |
+ newNetwork.addRequest(nri.request); | |
+ if (nri.isRequest && nri.request.legacyType != TYPE_NONE) { | |
+ mLegacyTypeTracker.add(nri.request.legacyType, newNetwork); | |
+ } | |
+ keep = true; | |
+ // Tell NetworkFactories about the new score, so they can stop | |
+ // trying to connect if they know they cannot match it. | |
+ // TODO - this could get expensive if we have alot of requests for this | |
+ // network. Think about if there is a way to reduce this. Push | |
+ // netid->request mapping to each factory? | |
+ sendUpdatedScoreToFactories(nri.request, newNetwork.getCurrentScore()); | |
+ if (mDefaultRequest.requestId == nri.request.requestId) { | |
+ isNewDefault = true; | |
+ // TODO: Remove following line. It's redundant with makeDefault call. | |
+ mActiveDefaultNetwork = newNetwork.networkInfo.getType(); | |
+ if (newNetwork.linkProperties != null) { | |
+ updateTcpBufferSizes(newNetwork); | |
+ setDefaultDnsSystemProperties( | |
+ newNetwork.linkProperties.getDnsServers()); | |
+ } else { | |
+ setDefaultDnsSystemProperties(new ArrayList<InetAddress>()); | |
+ } | |
+ // Maintain the illusion: since the legacy API only | |
+ // understands one network at a time, we must pretend | |
+ // that the current default network disconnected before | |
+ // the new one connected. | |
+ if (currentNetwork != null) { | |
+ mLegacyTypeTracker.remove(currentNetwork.networkInfo.getType(), | |
+ currentNetwork); | |
+ } | |
+ mDefaultInetConditionPublished = newNetwork.validated ? 100 : 0; | |
+ mLegacyTypeTracker.add(newNetwork.networkInfo.getType(), newNetwork); | |
+ notifyLockdownVpn(newNetwork); | |
+ } | |
} | |
- mDefaultInetConditionPublished = newNetwork.validated ? 100 : 0; | |
- mLegacyTypeTracker.add(newNetwork.networkInfo.getType(), newNetwork); | |
- notifyLockdownVpn(newNetwork); | |
} | |
} | |
} | |
- } | |
// Linger any networks that are no longer needed. | |
for (NetworkAgentInfo nai : affectedNetworks) { | |
boolean teardown = !nai.isVPN() && nai.validated; | |
diff -ur A/frameworks/base/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java B/frameworks/base/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java | |
--- A/frameworks/base/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java 2015-09-01 12:59:00.000000000 -0500 | |
+++ B/frameworks/base/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java 2015-09-01 13:01:37.000000000 -0500 | |
@@ -125,6 +125,11 @@ | |
return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN); | |
} | |
+ // Add Ethernet check | |
+ public boolean isETHERNET() { | |
+ return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET); | |
+ } | |
+ | |
// Get the current score for this Network. This may be modified from what the | |
// NetworkAgent sent, as it has modifiers applied to it. | |
public int getCurrentScore() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been working on getting both interfaces working and I need to test this patch on a clean Android build.