Android5.0网络评分与切换策略

1.frameworks/base/core/java/android/net/NetworkFactory.java

    private void evalRequest(NetworkRequestInfo n) {
        Log.d("TKTK","TK--------->>>>factory,,,,evalRequest>>>n.requested is " + n.requested + " n.score is " + n.score + "mScore is " + mScore);//add by tan
        if (n.requested == false && n.score < mScore &&
                n.request.networkCapabilities.satisfiedByNetworkCapabilities(
                mCapabilityFilter) && acceptRequest(n.request, n.score)) {
            Log.d("TKTK","TK------->>>>>factory>>>>>needNetworkFor");//add by tank
            needNetworkFor(n.request, n.score);
            n.requested = true;
        } else if (n.requested == true &&
                (n.score > mScore || n.request.networkCapabilities.satisfiedByNetworkCapabilities(
                mCapabilityFilter) == false || acceptRequest(n.request, n.score) == false)) { //modify by tank
            Log.d("TKTK","TK------->>>>>factory>>>>>releaseNetworkFor");//add by tank
            releaseNetworkFor(n.request);
            n.requested = false;
        }
    }

2.frameworks/base/services/core/java/com/android/server/ConnectivityService.java

private void rematchNetworkAndRequests(NetworkAgentInfo newNetwork, boolean nascent) {
  if (currentNetwork == null ||
                        currentNetwork.getCurrentScore() <= newNetwork.getCurrentScore()) {  //modify by tank from < to <=

  }
}


你可能感兴趣的:(Android5.0网络评分与切换策略)