Merge "Check if network has partial connectivity" am: e54e1235e6 am: 9ebfc37ff9
am: 8a7575af75
Change-Id: Ib6c5ecc8238e1ac237eddcc00802fa5e7c0e24b9
This commit is contained in:
@@ -426,6 +426,16 @@ public class ConnectivityManager {
|
||||
public static final String ACTION_PROMPT_LOST_VALIDATION =
|
||||
"android.net.conn.PROMPT_LOST_VALIDATION";
|
||||
|
||||
/**
|
||||
* Action used to display a dialog that asks the user whether to stay connected to a network
|
||||
* that has not validated. This intent is used to start the dialog in settings via
|
||||
* startActivity.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String ACTION_PROMPT_PARTIAL_CONNECTIVITY =
|
||||
"android.net.conn.PROMPT_PARTIAL_CONNECTIVITY";
|
||||
|
||||
/**
|
||||
* Invalid tethering type.
|
||||
* @see #startTethering(int, boolean, OnStartTetheringCallback)
|
||||
@@ -4034,7 +4044,7 @@ public class ConnectivityManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL)
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
|
||||
public void setAcceptUnvalidated(Network network, boolean accept, boolean always) {
|
||||
try {
|
||||
mService.setAcceptUnvalidated(network, accept, always);
|
||||
@@ -4043,6 +4053,29 @@ public class ConnectivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs the system whether it should consider the network as validated even if it only has
|
||||
* partial connectivity. If {@code accept} is true, then the network will be considered as
|
||||
* validated even if connectivity is only partial. If {@code always} is true, then the choice
|
||||
* is remembered, so that the next time the user connects to this network, the system will
|
||||
* switch to it.
|
||||
*
|
||||
* @param network The network to accept.
|
||||
* @param accept Whether to consider the network as validated even if it has partial
|
||||
* connectivity.
|
||||
* @param always Whether to remember this choice in the future.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_STACK)
|
||||
public void setAcceptPartialConnectivity(Network network, boolean accept, boolean always) {
|
||||
try {
|
||||
mService.setAcceptPartialConnectivity(network, accept, always);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs the system to penalize {@code network}'s score when it becomes unvalidated. This is
|
||||
* only meaningful if the system is configured not to penalize such networks, e.g., if the
|
||||
@@ -4053,7 +4086,7 @@ public class ConnectivityManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL)
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
|
||||
public void setAvoidUnvalidated(Network network) {
|
||||
try {
|
||||
mService.setAvoidUnvalidated(network);
|
||||
|
||||
@@ -176,6 +176,7 @@ interface IConnectivityManager
|
||||
void releaseNetworkRequest(in NetworkRequest networkRequest);
|
||||
|
||||
void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
|
||||
void setAcceptPartialConnectivity(in Network network, boolean accept, boolean always);
|
||||
void setAvoidUnvalidated(in Network network);
|
||||
void startCaptivePortalApp(in Network network);
|
||||
void startCaptivePortalAppInternal(in Network network, in Bundle appExtras);
|
||||
|
||||
@@ -143,7 +143,8 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
NET_CAPABILITY_NOT_CONGESTED,
|
||||
NET_CAPABILITY_NOT_SUSPENDED,
|
||||
NET_CAPABILITY_OEM_PAID,
|
||||
NET_CAPABILITY_MCX
|
||||
NET_CAPABILITY_MCX,
|
||||
NET_CAPABILITY_PARTIAL_CONNECTIVITY,
|
||||
})
|
||||
public @interface NetCapability { }
|
||||
|
||||
@@ -304,8 +305,15 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
*/
|
||||
public static final int NET_CAPABILITY_MCX = 23;
|
||||
|
||||
/**
|
||||
* Indicates that this network was tested to only provide partial connectivity.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int NET_CAPABILITY_PARTIAL_CONNECTIVITY = 24;
|
||||
|
||||
private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS;
|
||||
private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_MCX;
|
||||
private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_PARTIAL_CONNECTIVITY;
|
||||
|
||||
/**
|
||||
* Network capabilities that are expected to be mutable, i.e., can change while a particular
|
||||
@@ -320,7 +328,8 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
| (1 << NET_CAPABILITY_NOT_ROAMING)
|
||||
| (1 << NET_CAPABILITY_FOREGROUND)
|
||||
| (1 << NET_CAPABILITY_NOT_CONGESTED)
|
||||
| (1 << NET_CAPABILITY_NOT_SUSPENDED);
|
||||
| (1 << NET_CAPABILITY_NOT_SUSPENDED)
|
||||
| (1 << NET_CAPABILITY_PARTIAL_CONNECTIVITY);
|
||||
|
||||
/**
|
||||
* Network capabilities that are not allowed in NetworkRequests. This exists because the
|
||||
@@ -374,6 +383,15 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
(1 << NET_CAPABILITY_SUPL) |
|
||||
(1 << NET_CAPABILITY_WIFI_P2P);
|
||||
|
||||
/**
|
||||
* Capabilities that are managed by ConnectivityService.
|
||||
*/
|
||||
private static final long CONNECTIVITY_MANAGED_CAPABILITIES =
|
||||
(1 << NET_CAPABILITY_VALIDATED)
|
||||
| (1 << NET_CAPABILITY_CAPTIVE_PORTAL)
|
||||
| (1 << NET_CAPABILITY_FOREGROUND)
|
||||
| (1 << NET_CAPABILITY_PARTIAL_CONNECTIVITY);
|
||||
|
||||
/**
|
||||
* Adds the given capability to this {@code NetworkCapability} instance.
|
||||
* Multiple capabilities may be applied sequentially. Note that when searching
|
||||
@@ -507,6 +525,14 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
&& ((mUnwantedNetworkCapabilities & (1 << capability)) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this NetworkCapabilities has system managed capabilities or not.
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasConnectivityManagedCapability() {
|
||||
return ((mNetworkCapabilities & CONNECTIVITY_MANAGED_CAPABILITIES) != 0);
|
||||
}
|
||||
|
||||
/** Note this method may result in having the same capability in wanted and unwanted lists. */
|
||||
private void combineNetCapabilities(NetworkCapabilities nc) {
|
||||
this.mNetworkCapabilities |= nc.mNetworkCapabilities;
|
||||
@@ -1599,31 +1625,32 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
*/
|
||||
public static String capabilityNameOf(@NetCapability int capability) {
|
||||
switch (capability) {
|
||||
case NET_CAPABILITY_MMS: return "MMS";
|
||||
case NET_CAPABILITY_SUPL: return "SUPL";
|
||||
case NET_CAPABILITY_DUN: return "DUN";
|
||||
case NET_CAPABILITY_FOTA: return "FOTA";
|
||||
case NET_CAPABILITY_IMS: return "IMS";
|
||||
case NET_CAPABILITY_CBS: return "CBS";
|
||||
case NET_CAPABILITY_WIFI_P2P: return "WIFI_P2P";
|
||||
case NET_CAPABILITY_IA: return "IA";
|
||||
case NET_CAPABILITY_RCS: return "RCS";
|
||||
case NET_CAPABILITY_XCAP: return "XCAP";
|
||||
case NET_CAPABILITY_EIMS: return "EIMS";
|
||||
case NET_CAPABILITY_NOT_METERED: return "NOT_METERED";
|
||||
case NET_CAPABILITY_INTERNET: return "INTERNET";
|
||||
case NET_CAPABILITY_NOT_RESTRICTED: return "NOT_RESTRICTED";
|
||||
case NET_CAPABILITY_TRUSTED: return "TRUSTED";
|
||||
case NET_CAPABILITY_NOT_VPN: return "NOT_VPN";
|
||||
case NET_CAPABILITY_VALIDATED: return "VALIDATED";
|
||||
case NET_CAPABILITY_CAPTIVE_PORTAL: return "CAPTIVE_PORTAL";
|
||||
case NET_CAPABILITY_NOT_ROAMING: return "NOT_ROAMING";
|
||||
case NET_CAPABILITY_FOREGROUND: return "FOREGROUND";
|
||||
case NET_CAPABILITY_NOT_CONGESTED: return "NOT_CONGESTED";
|
||||
case NET_CAPABILITY_NOT_SUSPENDED: return "NOT_SUSPENDED";
|
||||
case NET_CAPABILITY_OEM_PAID: return "OEM_PAID";
|
||||
case NET_CAPABILITY_MCX: return "MCX";
|
||||
default: return Integer.toString(capability);
|
||||
case NET_CAPABILITY_MMS: return "MMS";
|
||||
case NET_CAPABILITY_SUPL: return "SUPL";
|
||||
case NET_CAPABILITY_DUN: return "DUN";
|
||||
case NET_CAPABILITY_FOTA: return "FOTA";
|
||||
case NET_CAPABILITY_IMS: return "IMS";
|
||||
case NET_CAPABILITY_CBS: return "CBS";
|
||||
case NET_CAPABILITY_WIFI_P2P: return "WIFI_P2P";
|
||||
case NET_CAPABILITY_IA: return "IA";
|
||||
case NET_CAPABILITY_RCS: return "RCS";
|
||||
case NET_CAPABILITY_XCAP: return "XCAP";
|
||||
case NET_CAPABILITY_EIMS: return "EIMS";
|
||||
case NET_CAPABILITY_NOT_METERED: return "NOT_METERED";
|
||||
case NET_CAPABILITY_INTERNET: return "INTERNET";
|
||||
case NET_CAPABILITY_NOT_RESTRICTED: return "NOT_RESTRICTED";
|
||||
case NET_CAPABILITY_TRUSTED: return "TRUSTED";
|
||||
case NET_CAPABILITY_NOT_VPN: return "NOT_VPN";
|
||||
case NET_CAPABILITY_VALIDATED: return "VALIDATED";
|
||||
case NET_CAPABILITY_CAPTIVE_PORTAL: return "CAPTIVE_PORTAL";
|
||||
case NET_CAPABILITY_NOT_ROAMING: return "NOT_ROAMING";
|
||||
case NET_CAPABILITY_FOREGROUND: return "FOREGROUND";
|
||||
case NET_CAPABILITY_NOT_CONGESTED: return "NOT_CONGESTED";
|
||||
case NET_CAPABILITY_NOT_SUSPENDED: return "NOT_SUSPENDED";
|
||||
case NET_CAPABILITY_OEM_PAID: return "OEM_PAID";
|
||||
case NET_CAPABILITY_MCX: return "MCX";
|
||||
case NET_CAPABILITY_PARTIAL_CONNECTIVITY: return "PARTIAL_CONNECTIVITY";
|
||||
default: return Integer.toString(capability);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,12 @@ public class NetworkMisc implements Parcelable {
|
||||
*/
|
||||
public boolean acceptUnvalidated;
|
||||
|
||||
/**
|
||||
* Whether the user explicitly set that this network should be validated even if presence of
|
||||
* only partial internet connectivity.
|
||||
*/
|
||||
public boolean acceptPartialConnectivity;
|
||||
|
||||
/**
|
||||
* Set to avoid surfacing the "Sign in to network" notification.
|
||||
* if carrier receivers/apps are registered to handle the carrier-specific provisioning
|
||||
|
||||
Reference in New Issue
Block a user