RK3288 Android5.1 SDK配置WiFi和以太网共存

RK3288 Android 5.1官方SDK(rk3288_android5.1_v1.00_20150515,已更新到20180412),在Rockchip官方提供的RK_EVB_RK3288核心板上验证OK。

根据Rockchip官方提供的补丁和配置方法,WiFi和以太网可以共存,而且WiFi配置连接因特网,以太网连接内部局域网,互不干扰。以下是具体的修改方法和补丁:


1)实现以太网wifi共存,补丁如下:
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 327fb8a..e5bcb04 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -166,9 +166,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
     private static final String TAG = "ConnectivityService";
 
     private static final boolean DBG = true;
     private static final boolean VDBG = false;
 
     private 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
 
@@ -4247,7 +4255,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
             loge("Dead network still had at least " + nr);
             break;
         }
-        nai.asyncChannel.disconnect();
+
+        if (ENABLE_NETWORK_COEXIST) {
+            log("Skip teardownUnneededNetwork: " + nai.name());
+        } else {
+            nai.asyncChannel.disconnect();
+        }
     }
 
     private void handleLingerComplete(NetworkAgentInfo oldNetwork) {



2)若需要wifi访问外网,以太网用于访问局域网,则打如下补丁: 
fzk@RD-DEP1-SERVER-163:~/rk3288_rel_5.1/frameworks/opt/net/ethernet$ git diff
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index e5cb6f9..8abc5ea 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -81,7 +81,7 @@ import java.lang.Exception;
 class EthernetNetworkFactory {
     private static final String NETWORK_TYPE = "Ethernet";
     private static final String TAG = "EthernetNetworkFactory";
-    private static final int NETWORK_SCORE = 150;
+    private static final int NETWORK_SCORE = 30;
     private static final boolean DBG = true;
     private static final boolean VDBG = false;



3)如果用ping命令发现只能ping通以太网wifi中的一个时,输入如下命令:

ip rule add from all lookup main pref 9999



4)共存且wifi优先级高时,若断开wifi后,设置界面以太网也显示未连接,或者先连接wifi后,再连接以太网时,以太网连接失败,则用下面补丁:
fzk@RD-DEP1-SERVER-163:~/rk3288_rel_5.1/frameworks/opt/net/ethernet$ git diff
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index e80b252..974fa0f 100755
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -411,6 +411,9 @@ class EthernetNetworkFactory {
         // TODO: Handle DHCP renew.
         Thread dhcpThread = new Thread(new Runnable() {
             public void run() {
+                if (mEthernetCurrentState != EthernetManager.ETHER_STATE_DISCONNECTED){   //注意Android6.0可能是EthernetManager.ETHERNET_CONNECT_STATE_DISCONNECT
+                        return ;
+                }
                 if (DBG) Log.i(TAG, "dhcpThread(+" + mIface + "): mNetworkInfo=" + mNetworkInfo);
                 LinkProperties linkProperties;
 
 
/rk3288_rel_5.1/frameworks/base$ git diff
diff --git a/core/java/android/net/NetworkFactory.java b/core/java/android/net/NetworkFactory.java
index 64d0fcf..c4ae1a3 100644
--- a/core/java/android/net/NetworkFactory.java
+++ b/core/java/android/net/NetworkFactory.java
@@ -220,7 +220,7 @@ public class NetworkFactory extends Handler {
 
     private void evalRequest(NetworkRequestInfo n) {
         if (VDBG) log("evalRequest");
-        if (n.requested == false && n.score < mScore &&
+        if (n.requested == false && 0 < mScore &&
                 n.request.networkCapabilities.satisfiedByNetworkCapabilities(
                 mCapabilityFilter) && acceptRequest(n.request, n.score)) {
             if (VDBG) log("  needNetworkFor");


你可能感兴趣的:(RK3288 Android5.1 SDK配置WiFi和以太网共存)