rk3399-9.0-wifi-以太网共存补丁
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
old mode 100644
new mode 100755
index 150c91b..0ff90e5
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -208,6 +208,13 @@ public class ConnectivityService extends IConnectivityManager.Stubprivate static final boolean LOGD_RULES = false;private static final boolean LOGD_BLOCKED_NETWORKINFO = true;
+
+ // if true:
+ // wifi and ethernet can coexist, if wifi and ethernet connect together, prefered to use ethernet
+ // if false:
+ // wifi and ethernet can't coexist, if wifi and ethernet connect together, will tear down wifi
+ // TODO: still have bug in this case to fix (like can't reconnect wifi when ethernet disconnect)
+ private static final boolean ENABLE_NETWORK_COEXIST = true;// TODO: create better separation between radio types and network types@@ -5186,7 +5193,23 @@ public class ConnectivityService extends IConnectivityManager.Stubbreak;}}
- nai.asyncChannel.disconnect();
+ // nai.asyncChannel.disconnect();
+
+ if (ENABLE_NETWORK_COEXIST) {
+ log("Skip teardownUnneededNetwork: " + nai.name());
+ if (nai.getCurrentScore() > 0) {
+ try {
+ mNetd.removeInterfaceFromNetwork(nai.linkProperties.getInterfaceName(), nai.network.netId);
+ mNetd.addInterfaceToLocalNetwork(nai.linkProperties.getInterfaceName(), nai.linkProperties.getRoutes());
+ mLegacyTypeTracker.add(nai.networkInfo.getType(), nai);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to add iface to local network " + e);
+ }
+ }
+
+ } else {
+ nai.asyncChannel.disconnect();
+ }}private void handleLingerComplete(NetworkAgentInfo oldNetwork) {
@@ -5334,6 +5357,13 @@ public class ConnectivityService extends IConnectivityManager.Stub} else {
if (VDBG) log(" accepting network in place of null");}
+ if (ENABLE_NETWORK_COEXIST) {
+ try {
+ mNetd.removeInterfaceFromLocalNetwork(newNetwork.linkProperties.getInterfaceName());
+ } catch(RemoteException e) {
}
+ updateLinkProperties(newNetwork,null);
+ }
+newNetwork.unlingerRequest(nri.request);setNetworkForRequest(nri.request.requestId, newNetwork);if (!newNetwork.addRequest(nri.request)) {
@@ -5664,6 +5694,11 @@ public class ConnectivityService extends IConnectivityManager.Stub// This has to happen after matching the requests, because callbacks are just requests.notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_PRECHECK);} else if (state == NetworkInfo.State.DISCONNECTED) {
+ if (ENABLE_NETWORK_COEXIST) {
+ try {
+ mNetd.removeInterfaceFromLocalNetwork(networkAgent.linkProperties.getInterfaceName());
+ } catch(RemoteException e) {
}
+ }networkAgent.asyncChannel.disconnect();if (networkAgent.isVPN()) {
synchronized (mProxyLock) {
diff --git a/core/java/android/net/NetworkFactory.java b/core/java/android/net/NetworkFactory.java
old mode 100644
new mode 100755
index a897e90..1d927c3
--- a/core/java/android/net/NetworkFactory.java
+++ b/core/java/android/net/NetworkFactory.java
@@ -239,8 +239,8 @@ public class NetworkFactory extends Handler {
(n.score > mScore || n.request.networkCapabilities.satisfiedByNetworkCapabilities(mCapabilityFilter) == false || acceptRequest(n.request, n.score) == false)) {
if (VDBG) log(" releaseNetworkFor");
- releaseNetworkFor(n.request);
- n.requested = false;
+ // releaseNetworkFor(n.request);
+ // n.requested = false;} else {
if (VDBG) log(" done");}