boolean roaming = false;
boolean congested = false;
- if (ArrayUtils.isEmpty(underlyingNetworks)) {
- // No idea what the underlying networks are; assume sane defaults
- metered = true;
- roaming = false;
- congested = false;
- } else {
+ boolean hadUnderlyingNetworks = false;
+ if (null != underlyingNetworks) {
for (Network underlying : underlyingNetworks) {
final NetworkCapabilities underlyingCaps = cm.getNetworkCapabilities(underlying);
if (underlyingCaps == null) continue;
+ hadUnderlyingNetworks = true;
for (int underlyingType : underlyingCaps.getTransportTypes()) {
transportTypes = ArrayUtils.appendInt(transportTypes, underlyingType);
}
congested |= !underlyingCaps.hasCapability(NET_CAPABILITY_NOT_CONGESTED);
}
}
+ if (!hadUnderlyingNetworks) {
+ // No idea what the underlying networks are; assume sane defaults
+ metered = true;
+ roaming = false;
+ congested = false;
+ }
caps.setTransportTypes(transportTypes);
caps.setLinkDownstreamBandwidthKbps(downKbps);
&& caps.hasCapability(NET_CAPABILITY_NOT_METERED),
vpnNetworkAgent);
- // Disconnect wifi too. No underlying networks should mean this is now metered,
- // unfortunately a discrepancy in the current implementation has this unmetered.
- // TODO : fix this.
+ // Disconnect wifi too. No underlying networks means this is now metered.
mWiFiNetworkAgent.disconnect();
vpnNetworkCallback.expectCapabilitiesLike((caps) -> caps.hasTransport(TRANSPORT_VPN)
&& !caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && caps.hasCapability(NET_CAPABILITY_NOT_METERED),
+ && !caps.hasCapability(NET_CAPABILITY_NOT_METERED),
vpnNetworkAgent);
mMockVpn.disconnect();