Merge changes I62c990d0,I413bdb76,I020ba48e into main
* changes: Update NetworkRequestTest#testDefaultCapabilities Allow default messaging app to use constrained satellite network Introduce NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED
This commit is contained in:
commit
3e07102814
3 changed files with 125 additions and 51 deletions
|
|
@ -337,6 +337,7 @@ package android.net {
|
|||
field public static final int NET_CAPABILITY_MCX = 23; // 0x17
|
||||
field public static final int NET_CAPABILITY_MMS = 0; // 0x0
|
||||
field public static final int NET_CAPABILITY_MMTEL = 33; // 0x21
|
||||
field @FlaggedApi("com.android.net.flags.net_capability_not_bandwidth_constrained") public static final int NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED = 37; // 0x25
|
||||
field public static final int NET_CAPABILITY_NOT_CONGESTED = 20; // 0x14
|
||||
field public static final int NET_CAPABILITY_NOT_METERED = 11; // 0xb
|
||||
field public static final int NET_CAPABILITY_NOT_RESTRICTED = 13; // 0xd
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import android.util.Log;
|
|||
import android.util.Range;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.module.util.BitUtils;
|
||||
import com.android.net.module.util.CollectionUtils;
|
||||
import com.android.net.module.util.NetworkCapabilitiesUtils;
|
||||
|
|
@ -135,6 +136,8 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
"com.android.net.flags.request_restricted_wifi";
|
||||
static final String SUPPORT_TRANSPORT_SATELLITE =
|
||||
"com.android.net.flags.support_transport_satellite";
|
||||
static final String NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED =
|
||||
"com.android.net.flags.net_capability_not_bandwidth_constrained";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -459,6 +462,7 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
NET_CAPABILITY_PRIORITIZE_LATENCY,
|
||||
NET_CAPABILITY_PRIORITIZE_BANDWIDTH,
|
||||
NET_CAPABILITY_LOCAL_NETWORK,
|
||||
NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED,
|
||||
})
|
||||
public @interface NetCapability { }
|
||||
|
||||
|
|
@ -741,7 +745,26 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
@FlaggedApi(Flags.FLAG_NET_CAPABILITY_LOCAL_NETWORK)
|
||||
public static final int NET_CAPABILITY_LOCAL_NETWORK = 36;
|
||||
|
||||
private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_LOCAL_NETWORK;
|
||||
/**
|
||||
* Indicates that this is not a bandwidth-constrained network.
|
||||
*
|
||||
* Starting from {@link Build.VERSION_CODES.VANILLA_ICE_CREAM}, this capability is by default
|
||||
* set in {@link NetworkRequest}s and true for most networks.
|
||||
*
|
||||
* If a network lacks this capability, it is bandwidth-constrained. Bandwidth constrained
|
||||
* networks cannot support high-bandwidth data transfers and applications that request and use
|
||||
* them must ensure that they limit bandwidth usage to below the values returned by
|
||||
* {@link #getLinkDownstreamBandwidthKbps()} and {@link #getLinkUpstreamBandwidthKbps()} and
|
||||
* limit the frequency of their network usage. If applications perform high-bandwidth data
|
||||
* transfers on constrained networks or perform network access too frequently, the system may
|
||||
* block the app's access to the network. The system may take other measures to reduce network
|
||||
* usage on constrained networks, such as disabling network access to apps that are not in the
|
||||
* foreground.
|
||||
*/
|
||||
@FlaggedApi(Flags.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED)
|
||||
public static final int NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED = 37;
|
||||
|
||||
private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED;
|
||||
|
||||
// Set all bits up to the MAX_NET_CAPABILITY-th bit
|
||||
private static final long ALL_VALID_CAPABILITIES = (2L << MAX_NET_CAPABILITY) - 1;
|
||||
|
|
@ -785,10 +808,17 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
/**
|
||||
* Capabilities that are set by default when the object is constructed.
|
||||
*/
|
||||
private static final long DEFAULT_CAPABILITIES =
|
||||
(1L << NET_CAPABILITY_NOT_RESTRICTED) |
|
||||
(1L << NET_CAPABILITY_TRUSTED) |
|
||||
(1L << NET_CAPABILITY_NOT_VPN);
|
||||
private static final long DEFAULT_CAPABILITIES;
|
||||
static {
|
||||
long defaultCapabilities =
|
||||
(1L << NET_CAPABILITY_NOT_RESTRICTED)
|
||||
| (1L << NET_CAPABILITY_TRUSTED)
|
||||
| (1L << NET_CAPABILITY_NOT_VPN);
|
||||
if (SdkLevel.isAtLeastV()) {
|
||||
defaultCapabilities |= (1L << NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
|
||||
}
|
||||
DEFAULT_CAPABILITIES = defaultCapabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Capabilities that are managed by ConnectivityService.
|
||||
|
|
@ -815,7 +845,9 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
(1L << NET_CAPABILITY_NOT_ROAMING) |
|
||||
(1L << NET_CAPABILITY_NOT_CONGESTED) |
|
||||
(1L << NET_CAPABILITY_NOT_SUSPENDED) |
|
||||
(1L << NET_CAPABILITY_NOT_VCN_MANAGED);
|
||||
(1L << NET_CAPABILITY_NOT_VCN_MANAGED) |
|
||||
(1L << NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
|
||||
|
||||
|
||||
/**
|
||||
* Extra allowed capabilities for test networks that do not have TRANSPORT_CELLULAR. Test
|
||||
|
|
@ -2603,6 +2635,7 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
case NET_CAPABILITY_PRIORITIZE_LATENCY: return "PRIORITIZE_LATENCY";
|
||||
case NET_CAPABILITY_PRIORITIZE_BANDWIDTH: return "PRIORITIZE_BANDWIDTH";
|
||||
case NET_CAPABILITY_LOCAL_NETWORK: return "LOCAL_NETWORK";
|
||||
case NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED: return "NOT_BANDWIDTH_CONSTRAINED";
|
||||
default: return Integer.toString(capability);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL;
|
|||
import static android.net.NetworkCapabilities.NET_CAPABILITY_DUN;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_FOREGROUND;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED;
|
||||
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_RESTRICTED;
|
||||
|
|
@ -286,7 +287,8 @@ public class NetworkRequest implements Parcelable {
|
|||
NET_CAPABILITY_PARTIAL_CONNECTIVITY,
|
||||
NET_CAPABILITY_TEMPORARILY_NOT_METERED,
|
||||
NET_CAPABILITY_TRUSTED,
|
||||
NET_CAPABILITY_VALIDATED);
|
||||
NET_CAPABILITY_VALIDATED,
|
||||
NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
|
||||
|
||||
private final NetworkCapabilities mNetworkCapabilities;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue