Android 7.1 根據4G共享動態調整以太網優先級

--- a/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -47,6 +47,7 @@ import android.os.Looper;
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.os.SystemProperties;
 import android.text.TextUtils;
 import android.util.Log;
 import android.content.Intent;
@@ -94,6 +95,7 @@ class EthernetNetworkFactory {
     private static final String NETWORK_TYPE = "Ethernet";
     private static final String TAG = "EthernetNetworkFactory";
     private static final int NETWORK_SCORE = 70;
+       private static final int NETWORK_SCORE_SHARE = 30;
     private static final boolean DBG = true;
 
     /** Tracks interface changes. Called from NetworkManagementService. */
@@ -260,9 +262,16 @@ class EthernetNetworkFactory {
             // set our score lower than any network could go
             // so we get dropped.  TODO - just unregister the factory
             // when link goes down.
-            mFactory.setScoreFilter(up ? NETWORK_SCORE : -1);
+            mFactory.setScoreFilter(up ? getNetworkScore() : -1);
         }
     }
+       
+       private int getNetworkScore() {
+               if ("1".equals(SystemProperties.get("persist.tchip.iproute")))
+                       return NETWORK_SCORE_SHARE;
+               else
+                       return NETWORK_SCORE;
+       }
 
     // first disconnect, then connect
     public void reconnect(String iface) {
@@ -429,7 +438,7 @@ class EthernetNetworkFactory {
             mNetworkAgent.sendNetworkInfo(mNetworkInfo);
             mNetworkAgent.sendLinkProperties(mLinkProperties);
             // never set the network score below 0.
-            mNetworkAgent.sendNetworkScore(mLinkUp? NETWORK_SCORE : 0);
+            mNetworkAgent.sendNetworkScore(mLinkUp? getNetworkScore() : 0);
         }
     }
    @@ -585,7 +594,7 @@ class EthernetNetworkFactory {
                     // Create our NetworkAgent.
                     mNetworkAgent = new NetworkAgent(mFactory.getLooper(), mContext,
                             NETWORK_TYPE, mNetworkInfo, mNetworkCapabilities, mLinkProperties,
-                            NETWORK_SCORE) {
+                            getNetworkScore()) {
                         public void unwanted() {
                             synchronized(EthernetNetworkFactory.this) {
                                 if (this == mNetworkAgent) {
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章