Merge "More cleanly separate requests and listens."

This commit is contained in:
Lorenzo Colitti
2021-02-07 18:04:50 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 31 deletions

View File

@@ -435,25 +435,7 @@ public class NetworkRequest implements Parcelable {
* @hide
*/
public boolean isRequest() {
return isForegroundRequest() || isBackgroundRequest();
}
/**
* Returns true iff. the contained NetworkRequest is one that:
*
* - should be associated with at most one satisfying network
* at a time;
*
* - should cause a network to be kept up and in the foreground if
* it is the best network which can satisfy the NetworkRequest.
*
* For full detail of how isRequest() is used for pairing Networks with
* NetworkRequests read rematchNetworkAndRequests().
*
* @hide
*/
public boolean isForegroundRequest() {
return type == Type.TRACK_DEFAULT || type == Type.REQUEST;
return type == Type.REQUEST || type == Type.BACKGROUND_REQUEST;
}
/**

View File

@@ -3589,10 +3589,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// As this request was not satisfied on rematch and thus never had any scores sent to the
// factories, send null now for each request of type REQUEST.
for (final NetworkRequest req : nri.mRequests) {
if (!req.isRequest()) {
continue;
}
sendUpdatedScoreToFactories(req, null);
if (req.isRequest()) sendUpdatedScoreToFactories(req, null);
}
}
@@ -3769,7 +3766,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mNetworkRequestInfoLogs.log("RELEASE " + nri);
if (null != nri.getActiveRequest()) {
if (nri.getActiveRequest().isRequest()) {
if (!nri.getActiveRequest().isListen()) {
removeSatisfiedNetworkRequestFromNetwork(nri);
} else {
nri.setSatisfier(null, null);
@@ -5517,7 +5514,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
// The network currently satisfying this NRI. Only one request in an NRI can have a
// satisfier. For non-multilayer requests, only REQUEST-type requests can have a satisfier.
// satisfier. For non-multilayer requests, only non-listen requests can have a satisfier.
@Nullable
private NetworkAgentInfo mSatisfier;
NetworkAgentInfo getSatisfier() {
@@ -7005,8 +7002,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void sendUpdatedScoreToFactories(NetworkAgentInfo nai) {
for (int i = 0; i < nai.numNetworkRequests(); i++) {
NetworkRequest nr = nai.requestAt(i);
// Don't send listening requests to factories. b/17393458
if (nr.isListen()) continue;
// Don't send listening or track default request to factories. b/17393458
if (!nr.isRequest()) continue;
sendUpdatedScoreToFactories(nr, nai);
}
}
@@ -7068,10 +7065,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
ensureRunningOnConnectivityServiceThread();
for (final NetworkRequestInfo nri : getNrisFromGlobalRequests()) {
for (final NetworkRequest req : nri.mRequests) {
if (req.isListen() && nri.getActiveRequest() == req) {
if (!req.isRequest() && nri.getActiveRequest() == req) {
break;
}
if (req.isListen()) {
if (!req.isRequest()) {
continue;
}
// Only set the nai for the request it is satisfying.
@@ -7221,8 +7218,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (nai.numRequestNetworkRequests() != 0) {
for (int i = 0; i < nai.numNetworkRequests(); i++) {
NetworkRequest nr = nai.requestAt(i);
// Ignore listening requests.
if (nr.isListen()) continue;
// Ignore listening and track default requests.
if (!nr.isRequest()) continue;
loge("Dead network still had at least " + nr);
break;
}