Android5.0网络评分导致的以太网不能连接

一、现象

恢复出厂设置以后;开机向导连接wifi后连接有线网络不成功,重启之后才能成功。

概率性出现。

二、log对比

1.成功

D/EthernetNetworkFactory( 2068): updateInterface: eth0 link up
D/TKTK    ( 2068): TK--------->>>>Factory>>>>setScoreFilter
D/EthernetServiceImpl( 2068): TK--------->>>>>>setConfiguration>>>4444444444
D/EthernetNetworkFactory( 2068): Ignoring unwanted as we have a more modern instance
D/TKTK    ( 2068): TK-------_>>>>>>factory,,<<<<>>>>>>factory>>>>hanldeMessage>>>CMD_SET_SCORE
D/TKTK    ( 2068): TK---------->>>factory>>>>handleSetScore
D/TKTK    ( 2068): TK-------_>>>>>>factory,,<<<<>>>factory,,,,evalRequest>>>n.requested is true n.score is 20mScore is 70
D/TKTK    ( 2068): TK---------->>>>>>>factory>>>>hanldeMessage>>>CMD_SET_SCORE
D/TKTK    ( 2068): TK---------->>>factory>>>>handleSetScore
D/TKTK    ( 2068): TK-------_>>>>>>factory,,<<<<

2.失败

I/TCL_EthernetManager( 2622): updateDevInfo:com.tcl.net.ethernet.EthernetDevInfo@39359c14
D/EthernetServiceImpl( 2070): TK--------->>>>>>setConfiguration>>>11111111
D/EthernetServiceImpl( 2070): TK--------->>>>>>setConfiguration>>>22222222
I/EthernetNetworkFactory( 2070): Updating mNetworkAgent with: [ Transports: ETHERNET Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN Li
nkUpBandwidth>=100000Kbps LinkDnBandwidth>=100000Kbps], [type: Ethernet[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: 5c
:63:b8:4d:ac:dc, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false], {InterfaceName: eth0 LinkAddre
sses: [10.120.142.99/24,]  Routes: [10.120.142.0/24 -> 0.0.0.0 eth0,0.0.0.0/0 -> 10.120.142.1 eth0,] DnsAddresses: [10.120.136.71,61.134.1.4,
218.30.19.40,] Domains: null MTU: 0 TcpBufferSizes: 524288,1048576,3145728,524288,1048576,2097152}
D/ConnectivityService( 2070): NetworkAgentInfo [Ethernet () - 100] EVENT_NETWORK_INFO_CHANGED, going from CONNECTED to DISCONNECTED
D/EthernetServiceImpl( 2070): TK--------->>>>>>setConfiguration>>>333333333
D/ConnectivityService( 2070): Update of LinkProperties for NetworkAgentInfo [Ethernet () - 100]; created=true
D/ConnectivityService( 2070): identical MTU - not setting
D/ConnectivityService( 2070): updateNetworkScore for NetworkAgentInfo [Ethernet () - 100] to 0
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 70
D/TKTK    ( 2070): TK------->>>setCurrentScore is 0
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 0
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 0
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 0
D/ConnectivityService( 2070): rematching NetworkAgentInfo [Ethernet () - 100]
D/ConnectivityService( 2070):  network has: [ Transports: ETHERNET Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN LinkUpBandwidth>=100
000Kbps LinkDnBandwidth>=100000Kbps]
D/TKTK    ( 2070): TK--------->>>>Factory>>>>setScoreFilter
D/ConnectivityService( 2070):   checking if request is satisfied: NetworkRequest [ id=1, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICT
ED&TRUSTED&NOT_VPN] ]
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 100
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 0
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 0
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 0
D/ConnectivityService( 2070): currentScore = 100, newScore = 0
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 100
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 0
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 0
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 0
D/ConnectivityService( 2070): rematching NetworkAgentInfo [WIFI () - 102]
D/ConnectivityService( 2070):  network has: [ Transports: WIFI Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN LinkUpBandwidth>=1048576
Kbps LinkDnBandwidth>=1048576Kbps]
D/ConnectivityService( 2070): Network NetworkAgentInfo [WIFI () - 102] was already satisfying request 1. No change.
D/ConnectivityService( 2070): notifyType AVAILABLE for NetworkAgentInfo [WIFI () - 102]
D/ConnectivityService( 2070):  sending notification for NetworkRequest [ id=1, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED
&NOT_VPN] ]
D/ConnectivityService( 2070): unregisterNetworkFactory for Ethernet
D/ConnectivityService( 2070): NetworkAgentInfo [Ethernet () - 100] got DISCONNECTED, was satisfying 0
D/EthernetNetworkFactory( 2070): Started tracking interface eth0
D/ConnectivityService( 2070): notifyType LOST for NetworkAgentInfo [Ethernet () - 100]
D/CommandListener( 1177): Setting iface cfg
D/CommandListener( 1177): Trying to bring up eth0
D/ConnectivityService( 2070): Got NetworkFactory Messenger for Ethernet
D/ConnectivityService( 2070): setProvNotificationVisibleIntent: E visible=false networkType=0 extraInfo=null
D/ConnectivityService( 2070): NetworkFactory connected
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 100
D/EthernetNetworkFactory( 2070): updateInterface: eth0 link up
D/TKTK    ( 2070): TK--------->>>>Factory>>>>setScoreFilter
D/EthernetServiceImpl( 2070): TK--------->>>>>>setConfiguration>>>4444444444
D/EthernetNetworkFactory( 2070): Ignoring unwanted as we have a more modern instance
D/TKTK    ( 2070): TK-------_>>>>>>factory,,<<<<>>>>>>factory>>>>hanldeMessage>>>CMD_SET_SCORE
D/TKTK    ( 2070): TK---------->>>factory>>>>handleSetScore
D/TKTK    ( 2070): TK-------_>>>>>>factory,,<<<<>>>factory,,,,evalRequest>>>n.requested is false n.score is 100mScore is -1
D/TKTK    ( 2070): TK---------->>>>>>>factory>>>>hanldeMessage>>>CMD_SET_SCORE
D/TKTK    ( 2070): TK---------->>>factory>>>>handleSetScore
D/TKTK    ( 2070): TK-------_>>>>>>factory,,<<<<>>>factory,,,,evalRequest>>>n.requested is false n.score is 100mScore is 110
D/TKTK    ( 2070): TK------->>>>>factory>>>>>needNetworkFor
D/TKTK    ( 2070): TK-------_>>>>>>factory,,<<<<>>>NetworkAgent.java>>1111111>>>score is 110
D/ConnectivityService( 2070): TK---------->>>>>currentScore is 110
D/TKTK    ( 2070): TK----------------->>>>>>score is 110
D/TKTK    ( 2070): TK----------------->>>>>>NetworkAgentInfo.java currentScore is 110
D/TKTK    ( 2070): TK----------------->>11111111>>>>NetworkAgentInfo.java currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 70
D/ConnectivityService( 2070): registerNetworkAgent NetworkAgentInfo{ ni{[type: Ethernet[], state: CONNECTED/CONNECTED, reason: (unspecified),
 extra: 5c:63:b8:4d:ac:dc, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false]}  network{null}  lp{{
InterfaceName: eth0 LinkAddresses: [10.120.142.99/24,]  Routes: [10.120.142.0/24 -> 0.0.0.0 eth0,0.0.0.0/0 -> 10.120.142.1 eth0,] DnsAddresse
s: [10.120.136.71,61.134.1.4,218.30.19.40,] Domains: null MTU: 0 TcpBufferSizes: 524288,1048576,3145728,524288,1048576,2097152}}  nc{[ Transp
orts: ETHERNET Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN LinkUpBandwidth>=100000Kbps LinkDnBandwidth>=100000Kbps]}  Score{70} val
idated{false} created{false} explicitlySelected{false} }
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 70
D/ConnectivityService( 2070): TK----------->>>nai.getCurrentScore() is 70
D/ConnectivityService( 2070): Got NetworkAgent Messenger
D/ConnectivityService( 2070): NetworkAgentInfo [Ethernet () - 103] EVENT_NETWORK_INFO_CHANGED, going from null to CONNECTED
D/ConnectivityService( 2070): Adding iface eth0 to network 103
E/ConnectivityService( 2070): Unexpected mtu value: 0, eth0
D/ConnectivityService( 2070): Adding Route [10.120.142.0/24 -> 0.0.0.0 eth0] to network 103
D/ConnectivityService( 2070): Adding Route [0.0.0.0/0 -> 10.120.142.1 eth0] to network 103
D/ConnectivityService( 2070): Setting Dns servers for network 103 to [/10.120.136.71, /61.134.1.4, /218.30.19.40]
D/ConnectivityService( 2070): notifyType IP_CHANGED for NetworkAgentInfo [Ethernet () - 103]
D/ConnectivityService( 2070): notifyType PRECHECK for NetworkAgentInfo [Ethernet () - 103]
D/ConnectivityService( 2070): rematching NetworkAgentInfo [Ethernet () - 103]
D/ConnectivityService( 2070):  network has: [ Transports: ETHERNET Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN LinkUpBandwidth>=100
000Kbps LinkDnBandwidth>=100000Kbps]
D/ConnectivityService( 2070):   checking if request is satisfied: NetworkRequest [ id=1, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICT
ED&TRUSTED&NOT_VPN] ]
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 100
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 70
D/ConnectivityService( 2070): currentScore = 100, newScore = 70
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 60
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 100
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is 110
D/TKTK    ( 2070): TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is 70
D/ConnectivityService( 2070): NetworkAgent connected
D/ConnectivityService( 2070): setProvNotificationVisibleIntent: E visible=true networkType=9 extraInfo=5c:63:b8:4d:ac:dc
D/TKTK    ( 2622): TK--------->>>>startScan()
D/TKTK    ( 2070): TK--------->>>>getConnectionInfo()
D/TKTK    ( 2622): TK--------->>>>getScanResults()

其中n.score为之前wifi的评分;mScore为当前以太网评分。

三、修改

提高以太网评分分值:

1.frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java

                    //add by tankm
                    NetworkMisc networkMisc = new NetworkMisc();
                    networkMisc.explicitlySelected = true;
                    //end tank
                    mNetworkAgent = new NetworkAgent(mFactory.getLooper(), mContext,
                            NETWORK_TYPE, mNetworkInfo, mNetworkCapabilities, mLinkProperties,
                            NETWORK_SCORE,networkMisc) { //modify by tank

2.frameworks/base/core/java/android/net/NetworkAgent.java

    public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni,
            NetworkCapabilities nc, LinkProperties lp, int score, NetworkMisc misc) {
        super(looper);
        LOG_TAG = logTag;
        mContext = context;
        if (ni == null || nc == null || lp == null) {
            throw new IllegalArgumentException();
        }
        Log.d("TKTK","TK--------->>>>NetworkAgent.java>>1111111>>>score is " + score);//add by tank
        if (VDBG) log("Registering NetworkAgent");
        ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni),
                new LinkProperties(lp), new NetworkCapabilities(nc), score, misc);
    }
3..frameworks/base/core/java/android/net/ConnectivityManager.java
    public void registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
            NetworkCapabilities nc, int score, NetworkMisc misc) {
        try {
            mService.registerNetworkAgent(messenger, ni, lp, nc, score, misc);
        } catch (RemoteException e) { }
    }
4.frameworks/base/services/core/java/com/android/server/ConnectivityService.java
    public void registerNetworkAgent(Messenger messenger, NetworkInfo networkInfo,
            LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
            int currentScore, NetworkMisc networkMisc) {
        enforceConnectivityInternalPermission();
        log("TK---------->>>>>currentScore is " + currentScore);//add by tank
        NetworkAgentInfo nai = new NetworkAgentInfo(messenger, new AsyncChannel(),
            new NetworkInfo(networkInfo), new LinkProperties(linkProperties),
            new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler,
            new NetworkMisc(networkMisc));
        synchronized (this) {
            nai.networkMonitor.systemReady = mSystemReady;
        }
        if (DBG) log("registerNetworkAgent " + nai);
        log("TK----------->>>nai.getCurrentScore() is " + nai.getCurrentScore());//add by tank
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai));
    }
5.frameworks/base/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
    public int getCurrentScore() {
        // TODO: We may want to refactor this into a NetworkScore class that takes a base score from
        // the NetworkAgent and signals from the NetworkAgent and uses those signals to modify the
        // score.  The NetworkScore class would provide a nice place to centralize score constants
        // so they are not scattered about the transports.
        Log.d("TKTK","TK----------_>>>>NetworkAgentInfo.java>>000>>>getCurrentScore() currentScore is " + currentScore);//add by tank
        int score = currentScore;
        Log.d("TKTK","TK----------_>>>>>NetworkAgentInfo.java>>111>>getCurrentScore() currentScore is " + currentScore);//add by tank
        if (!validated) score -= UNVALIDATED_SCORE_PENALTY;
        if (score < 0) score = 0;

        if (networkMisc.explicitlySelected) score = EXPLICITLY_SELECTED_NETWORK_SCORE;
        Log.d("TKTK","TK----------_>>>>NetworkAgentInfo.java>>222>>>getCurrentScore() score is " + score);//add by tank
        return score;
    }

你可能感兴趣的:(移动操作系统之Android)