Merge "Remove usages of hidden connectivity APIs" am: 8d8f48f0fd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1564501 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I8c9125091d0d348f310c31e59d5e94f7b6e9a8c0
This commit is contained in:
@@ -168,8 +168,8 @@ public class Vcn extends Handler {
|
||||
@NonNull NetworkRequest request, int score, int providerId) {
|
||||
if (score > getNetworkScore()) {
|
||||
Slog.v(getLogTag(),
|
||||
"Request " + request.requestId + " already satisfied by higher-scoring ("
|
||||
+ score + ") network from provider " + providerId);
|
||||
"Request already satisfied by higher-scoring (" + score + ") network from "
|
||||
+ "provider " + providerId + ": " + request);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,8 +177,7 @@ public class Vcn extends Handler {
|
||||
for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) {
|
||||
if (requestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
|
||||
Slog.v(getLogTag(),
|
||||
"Request " + request.requestId
|
||||
+ " satisfied by existing VcnGatewayConnection");
|
||||
"Request already satisfied by existing VcnGatewayConnection: " + request);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -202,12 +201,12 @@ public class Vcn extends Handler {
|
||||
|
||||
private boolean requestSatisfiedByGatewayConnectionConfig(
|
||||
@NonNull NetworkRequest request, @NonNull VcnGatewayConnectionConfig config) {
|
||||
final NetworkCapabilities configCaps = new NetworkCapabilities();
|
||||
final NetworkCapabilities.Builder builder = new NetworkCapabilities.Builder();
|
||||
for (int cap : config.getAllExposedCapabilities()) {
|
||||
configCaps.addCapability(cap);
|
||||
builder.addCapability(cap);
|
||||
}
|
||||
|
||||
return request.networkCapabilities.satisfiedByNetworkCapabilities(configCaps);
|
||||
return request.canBeSatisfiedBy(builder.build());
|
||||
}
|
||||
|
||||
private String getLogTag() {
|
||||
|
||||
@@ -963,18 +963,18 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
@VisibleForTesting(visibility = Visibility.PRIVATE)
|
||||
static NetworkCapabilities buildNetworkCapabilities(
|
||||
@NonNull VcnGatewayConnectionConfig gatewayConnectionConfig) {
|
||||
final NetworkCapabilities caps = new NetworkCapabilities();
|
||||
final NetworkCapabilities.Builder builder = new NetworkCapabilities.Builder();
|
||||
|
||||
caps.addTransportType(TRANSPORT_CELLULAR);
|
||||
caps.addCapability(NET_CAPABILITY_NOT_CONGESTED);
|
||||
caps.addCapability(NET_CAPABILITY_NOT_SUSPENDED);
|
||||
builder.addTransportType(TRANSPORT_CELLULAR);
|
||||
builder.addCapability(NET_CAPABILITY_NOT_CONGESTED);
|
||||
builder.addCapability(NET_CAPABILITY_NOT_SUSPENDED);
|
||||
|
||||
// Add exposed capabilities
|
||||
for (int cap : gatewayConnectionConfig.getAllExposedCapabilities()) {
|
||||
caps.addCapability(cap);
|
||||
builder.addCapability(cap);
|
||||
}
|
||||
|
||||
return caps;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static LinkProperties buildConnectedLinkProperties(
|
||||
|
||||
@@ -21,9 +21,9 @@ import android.content.Context;
|
||||
import android.net.NetworkProvider;
|
||||
import android.net.NetworkRequest;
|
||||
import android.os.Looper;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -40,7 +40,13 @@ public class VcnNetworkProvider extends NetworkProvider {
|
||||
private static final String TAG = VcnNetworkProvider.class.getSimpleName();
|
||||
|
||||
private final Set<NetworkRequestListener> mListeners = new ArraySet<>();
|
||||
private final SparseArray<NetworkRequestEntry> mRequests = new SparseArray<>();
|
||||
|
||||
/**
|
||||
* Cache of NetworkRequest(s), scores and network providers, keyed by NetworkRequest
|
||||
*
|
||||
* <p>NetworkRequests are immutable once created, and therefore can be used as stable keys.
|
||||
*/
|
||||
private final ArrayMap<NetworkRequest, NetworkRequestEntry> mRequests = new ArrayMap<>();
|
||||
|
||||
public VcnNetworkProvider(Context context, Looper looper) {
|
||||
super(context, looper, VcnNetworkProvider.class.getSimpleName());
|
||||
@@ -51,8 +57,8 @@ public class VcnNetworkProvider extends NetworkProvider {
|
||||
mListeners.add(listener);
|
||||
|
||||
// Send listener all cached requests
|
||||
for (int i = 0; i < mRequests.size(); i++) {
|
||||
notifyListenerForEvent(listener, mRequests.valueAt(i));
|
||||
for (NetworkRequestEntry entry : mRequests.values()) {
|
||||
notifyListenerForEvent(listener, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +81,9 @@ public class VcnNetworkProvider extends NetworkProvider {
|
||||
request, score, providerId));
|
||||
|
||||
final NetworkRequestEntry entry = new NetworkRequestEntry(request, score, providerId);
|
||||
mRequests.put(request.requestId, entry);
|
||||
|
||||
// NetworkRequests are immutable once created, and therefore can be used as stable keys.
|
||||
mRequests.put(request, entry);
|
||||
|
||||
// TODO(b/176939047): Intelligently route requests to prioritized VcnInstances (based on
|
||||
// Default Data Sub, or similar)
|
||||
@@ -86,7 +94,7 @@ public class VcnNetworkProvider extends NetworkProvider {
|
||||
|
||||
@Override
|
||||
public void onNetworkRequestWithdrawn(@NonNull NetworkRequest request) {
|
||||
mRequests.remove(request.requestId);
|
||||
mRequests.remove(request);
|
||||
}
|
||||
|
||||
private static class NetworkRequestEntry {
|
||||
|
||||
Reference in New Issue
Block a user