Merge "More cleanly separate requests and listens."
This commit is contained in:
@@ -435,25 +435,7 @@ public class NetworkRequest implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean isRequest() {
|
public boolean isRequest() {
|
||||||
return isForegroundRequest() || isBackgroundRequest();
|
return type == Type.REQUEST || type == Type.BACKGROUND_REQUEST;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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
|
// 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.
|
// factories, send null now for each request of type REQUEST.
|
||||||
for (final NetworkRequest req : nri.mRequests) {
|
for (final NetworkRequest req : nri.mRequests) {
|
||||||
if (!req.isRequest()) {
|
if (req.isRequest()) sendUpdatedScoreToFactories(req, null);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sendUpdatedScoreToFactories(req, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3769,7 +3766,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
||||||
|
|
||||||
if (null != nri.getActiveRequest()) {
|
if (null != nri.getActiveRequest()) {
|
||||||
if (nri.getActiveRequest().isRequest()) {
|
if (!nri.getActiveRequest().isListen()) {
|
||||||
removeSatisfiedNetworkRequestFromNetwork(nri);
|
removeSatisfiedNetworkRequestFromNetwork(nri);
|
||||||
} else {
|
} else {
|
||||||
nri.setSatisfier(null, null);
|
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
|
// 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
|
@Nullable
|
||||||
private NetworkAgentInfo mSatisfier;
|
private NetworkAgentInfo mSatisfier;
|
||||||
NetworkAgentInfo getSatisfier() {
|
NetworkAgentInfo getSatisfier() {
|
||||||
@@ -7005,8 +7002,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private void sendUpdatedScoreToFactories(NetworkAgentInfo nai) {
|
private void sendUpdatedScoreToFactories(NetworkAgentInfo nai) {
|
||||||
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
||||||
NetworkRequest nr = nai.requestAt(i);
|
NetworkRequest nr = nai.requestAt(i);
|
||||||
// Don't send listening requests to factories. b/17393458
|
// Don't send listening or track default request to factories. b/17393458
|
||||||
if (nr.isListen()) continue;
|
if (!nr.isRequest()) continue;
|
||||||
sendUpdatedScoreToFactories(nr, nai);
|
sendUpdatedScoreToFactories(nr, nai);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7068,10 +7065,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
ensureRunningOnConnectivityServiceThread();
|
ensureRunningOnConnectivityServiceThread();
|
||||||
for (final NetworkRequestInfo nri : getNrisFromGlobalRequests()) {
|
for (final NetworkRequestInfo nri : getNrisFromGlobalRequests()) {
|
||||||
for (final NetworkRequest req : nri.mRequests) {
|
for (final NetworkRequest req : nri.mRequests) {
|
||||||
if (req.isListen() && nri.getActiveRequest() == req) {
|
if (!req.isRequest() && nri.getActiveRequest() == req) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (req.isListen()) {
|
if (!req.isRequest()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Only set the nai for the request it is satisfying.
|
// Only set the nai for the request it is satisfying.
|
||||||
@@ -7221,8 +7218,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (nai.numRequestNetworkRequests() != 0) {
|
if (nai.numRequestNetworkRequests() != 0) {
|
||||||
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
||||||
NetworkRequest nr = nai.requestAt(i);
|
NetworkRequest nr = nai.requestAt(i);
|
||||||
// Ignore listening requests.
|
// Ignore listening and track default requests.
|
||||||
if (nr.isListen()) continue;
|
if (!nr.isRequest()) continue;
|
||||||
loge("Dead network still had at least " + nr);
|
loge("Dead network still had at least " + nr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user