Include NET_CAPABILITY_NOT_VCN_MANAGED for tethering local network agent
Currently, NET_CAPABILITY_NOT_VCN_MANAGED is implicited added for
NetworkRequest built by normal apps.
However, the tethering network agent doesn't have this capability,
which makes the agent being exposed to VcnManager and cannot be
seen by normal apps.
Add NET_CAPABILITY_NOT_VCN_MANAGED to tethering NetworkAgent. Include
NET_CAPABILITY_NOT_VCN_MANAGED in local network capabilities for
metrics and API utilities to ensure correct evaluation of local
network connectivity. Update unit tests to reflect the new capability.
Flag: EXEMPT bug fix
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSSatisfiedByLocalNetworkMetricsTest \
ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.SatisfiedByLocalNetworkMetricsTest \
--update-device
Test: manual generate request by CTS and statsd_testdrive -e 10247
Bug: 428098173
Change-Id: Ifa9ce0827abd22d887a0e8a2ab6f4d7391b2b8ed
This commit is contained in:
parent
7e86ed2fb1
commit
fbf102a88b
3 changed files with 9 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED;
|
|||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
|
@ -86,12 +87,15 @@ public class ConnectivityInternalApiUtil {
|
|||
public static NetworkAgent buildTetheringNetworkAgent(@NonNull Context ctx,
|
||||
@NonNull Looper looper, @NonNull String logTag, int transportType,
|
||||
@NonNull LinkProperties lp) {
|
||||
// LINT.IfChange
|
||||
final NetworkCapabilities.Builder builder = new NetworkCapabilities.Builder()
|
||||
.addCapability(NET_CAPABILITY_NOT_METERED)
|
||||
.addCapability(NET_CAPABILITY_NOT_ROAMING)
|
||||
.addCapability(NET_CAPABILITY_NOT_CONGESTED)
|
||||
.addCapability(NET_CAPABILITY_NOT_SUSPENDED)
|
||||
.addCapability(NET_CAPABILITY_NOT_VCN_MANAGED)
|
||||
.addTransportType(transportType);
|
||||
// LINT.ThenChange(../../../../../service/src/com/android/metrics/SatisfiedByLocalNetworkMetrics.java)
|
||||
// TODO: Change to use the constant definition. Flags.netCapabilityLocalNetwork() was not
|
||||
// fully rolled out but the service will still process this capability, set it anyway.
|
||||
builder.addCapability(36 /* NET_CAPABILITY_LOCAL_NETWORK */);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED;
|
|||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED;
|
||||
|
||||
import static com.android.net.module.util.FrameworkConnectivityStatsLog.SATISFIED_BY_LOCAL_NETWORK_REQUESTS;
|
||||
import static com.android.net.module.util.FrameworkConnectivityStatsLog.SATISFIED_BY_LOCAL_NETWORK_REQUESTS__TYPE__NETWORK_REQUEST_TYPE_BACKGROUND_REQUEST;
|
||||
|
|
@ -107,6 +108,7 @@ public class SatisfiedByLocalNetworkMetrics implements StatsManager.StatsPullAto
|
|||
.addCapability(NET_CAPABILITY_NOT_ROAMING)
|
||||
.addCapability(NET_CAPABILITY_NOT_CONGESTED)
|
||||
.addCapability(NET_CAPABILITY_NOT_SUSPENDED)
|
||||
.addCapability(NET_CAPABILITY_NOT_VCN_MANAGED)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_USB)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||
|
|
@ -218,4 +220,3 @@ public class SatisfiedByLocalNetworkMetrics implements StatsManager.StatsPullAto
|
|||
pw.println("SatisfiedByLocalNetworkMetrics: " + mSatisfiedRequestsPerTypeAndUid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import android.content.Context
|
|||
import android.net.NetworkCapabilities
|
||||
import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET
|
||||
import android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED
|
||||
import android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED
|
||||
import android.net.NetworkCapabilities.TRANSPORT_WIFI
|
||||
import android.net.NetworkRequest
|
||||
import android.net.NetworkRequest.Type
|
||||
|
|
@ -66,7 +67,9 @@ class SatisfiedByLocalNetworkMetricsTest {
|
|||
|
||||
// Simulate caps which can potentially be satisfied by non-thread
|
||||
// local networks.
|
||||
// Note that requests built by NetworkRequest normally have deduced NOT_VCN_MANAGED.
|
||||
private val WIFI_CAPS = NetworkCapabilities.Builder()
|
||||
.addCapability(NET_CAPABILITY_NOT_VCN_MANAGED)
|
||||
.addCapability(NET_CAPABILITY_NOT_METERED)
|
||||
.addTransportType(TRANSPORT_WIFI)
|
||||
.build()
|
||||
|
|
|
|||
Loading…
Reference in a new issue