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,,<<<<<evalRequests,mNetworkRequests.size is 0
D/TKTK    ( 2068): TK---------->>>>>>>factory>>>>hanldeMessage>>>CMD_SET_SCORE
D/TKTK    ( 2068): TK---------->>>factory>>>>handleSetScore
D/TKTK    ( 2068): TK-------_>>>>>>factory,,<<<<<evalRequests,mNetworkRequests.size is 0
D/TKTK    ( 2068): TK--------->>>>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,,<<<<<evalRequests,mNetworkRequests.size is 0

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,,<<<<<evalRequests,mNetworkRequests.size is 0
D/TKTK    ( 2070): TK---------->>>>>>>factory>>>>hanldeMessage>>>CMD_SET_SCORE
D/TKTK    ( 2070): TK---------->>>factory>>>>handleSetScore
D/TKTK    ( 2070): TK-------_>>>>>>factory,,<<<<<evalRequests,mNetworkRequests.size is 0
D/TKTK    ( 2070): TK--------->>>>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,,<<<<<evalRequests,mNetworkRequests.size is 1
D/TKTK    ( 2070): TK--------->>>>factory,,,,evalRequest>>>n.requested is false n.score is 100mScore is 110
D/TKTK    ( 2070): TK------->>>>>factory>>>>>needNetworkFor
D/TKTK    ( 2070): TK-------_>>>>>>factory,,<<<<<evalRequests,mRefCount is 0
I/EthernetNetworkFactory( 2070): dhcpThread(+eth0): mNetworkInfo=[type: Ethernet[], state: UNKNOWN/IDLE, reason: (unspecified), extra: 5c:63:
b8:4d:ac:dc, roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false]
D/CommandListener( 1177): Clearing all IP addresses on eth0
E/dhcpcd  ( 5352): fopen `/system/etc/dhcpcd/dhcpcd.conf': No such file or directory
I/dhcpcd  ( 5352): version 5.5.6 starting
E/dhcpcd  ( 5352): fopen `/system/etc/dhcpcd/dhcpcd.conf': No such file or directory
E/dhcpcd  ( 5352): get_duid: Read-only file system
I/dhcpcd  ( 5352): eth0: broadcasting for a lease
I/dhcpcd  ( 5352): eth0: offered 10.120.142.99 from 10.120.136.71
I/dhcpcd  ( 5352): eth0: acknowledged 10.120.142.99 from 10.120.136.71
I/dhcpcd  ( 5352): eth0: leased 10.120.142.99 for 86400 seconds
D/TKTK    ( 2070): TK--------->>>>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;
    }

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值