文件位置: /OK3568-android11-source/frameworks/libs/net/common/src_servicescommon/android/net/NetworkFactory.java 在229行位置找到如下代码,注释掉下方两行标红语句 protected void
handleRemoveRequest(NetworkRequest request) { NetworkRequestInfo n =
mNetworkRequests.get(request); if (n != null) { //
mNetworkRequests.remove(request); // if
(n.requested) releaseNetworkFor(n.request); } } 在292行位置找到如下两个函数,对标红部分语句,进行修改为下方状态,不再根据网络评分来加载和释放网络资源 private boolean
shouldNeedNetworkFor(NetworkRequestInfo n) { // If this request is
already tracked, it doesn't qualify for need return !n.requested // If the score of
this request is higher or equal to that of this factory and some // other factory
is responsible for it, then this factory should not track the request // because it has
no hope of satisfying it. // && (n.score < mScore ||
n.providerId == mProvider.getProviderId()) // If this factory
can't satisfy the capability needs of this request, then it // should not be
tracked. &&
n.request.canBeSatisfiedBy(mCapabilityFilter) // Finally if the
concrete implementation of the factory rejects the request, then // don't track it. &&
acceptRequest(n.request, n.score); } private boolean
shouldReleaseNetworkFor(NetworkRequestInfo n) { // Don't release a
request that's not tracked. return n.requested // The request
should be released if it can't be satisfied by this factory. That // means either of
the following conditions are met : // - Its score is too high to be satisfied by
this factory and it's not already // assigned to the factory // - This factory
can't satisfy the capability needs of the request // - The concrete
implementation of the factory rejects the request //
&& ((n.score > mScore && n.providerId !=
mProvider.getProviderId())
&& ( !n.request.canBeSatisfiedBy(mCapabilityFilter) ||
!acceptRequest(n.request, n.score)); } /OK3568-android11-source/frameworks/base/services/core/java/com/android/server/ConnectivityService.java 2726,注释nai.asyncChannel.disconnect(); 6683,注释nai.asyncChannel.disconnect(); —————— —————— 当前状况为两个网络都能ping通外网,但是默认优先使用以太网,需要进行以下修改,降低以太网网络评分,以优先使用wifi
以太网网络评分: /OK3568-android11-source/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java 在538行,修改网络评分,改为return 55
private int getNetworkScore() { // never set the network score
below 0. if (!mLinkUp) { return 0; }
int[] transportTypes =
mCapabilities.getTransportTypes(); if (transportTypes.length < 1) { Log.w(TAG, "Network
inte**ce '" + mLinkProperties.getInte**ceName() + "' has no " + "transport type
associated with it. Score set to zero"); return 0; } TransportInfo transportInfo =
sTransports.get(transportTypes[0], /* if dne */ null); if (transportInfo != null) { return 55; } return 0;
} |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-11-25 08:03
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.