diff options
| author | Lorenzo Colitti <lorenzo@google.com> | 2014-11-28 11:21:30 +0900 |
|---|---|---|
| committer | Jeff Davidson <jpd@google.com> | 2014-12-02 10:27:05 -0800 |
| commit | 403aa2684e0e93b4792aabc0bbe1f32ac5e417af (patch) | |
| tree | 79716af3091615cbc20fbefce2271900d5d13f4a /core/java/android | |
| parent | dc1baa16b1c559b07d392f7d899fcfe18fa7036c (diff) | |
Make StatusBar display all default networks.
The basic principle is: if an app's traffic could possibly go
over a network without the app using the multinetwork APIs (hence
"by default"), then the status bar should show that network's
connectivity.
In the normal case, app traffic only goes over the system's default
network connection, so that's the only network returned.
With a VPN in force, some app traffic may go into the VPN, and thus over
whatever underlying networks the VPN specifies, while other app traffic
may go over the system default network (e.g.: a split-tunnel VPN, or an
app disallowed by the VPN), so the set of networks returned includes the
VPN's underlying networks and the system default.
Specifically:
1. Add a NETWORK_CAPABILITY_VALIDATED bit to NetworkCapabilities.
2. Add a hidden API to retrieve the NetworkCapabilities of
all default networks for a given macro-user.
3. Modify the status bar code that used getActiveNetworkInfo to
determine which network was active, and make it consider all
validated networks instead.
4. Because the set of active networks depends on which VPN app
the user is running, make the status bar re-evaluate the
networking situation when the active user changes.
Bug: 17460017
Change-Id: Ie4965f35fb5936b088e6060ee06e362c22297ab2
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/net/ConnectivityManager.java | 13 | ||||
| -rw-r--r-- | core/java/android/net/IConnectivityManager.aidl | 1 | ||||
| -rw-r--r-- | core/java/android/net/NetworkCapabilities.java | 9 |
3 files changed, 22 insertions, 1 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index ff1a4414ebce..4215f207eae0 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -721,6 +721,19 @@ public class ConnectivityManager { } /** + * Returns an array of of {@link NetworkCapabilities} objects, representing + * the Networks that applications run by the given user will use by default. + * @hide + */ + public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId) { + try { + return mService.getDefaultNetworkCapabilitiesForUser(userId); + } catch (RemoteException e) { + return null; + } + } + + /** * Returns details about the Provisioning or currently active default data network. When * connected, this network is the default route for outgoing connections. * You should always check {@link NetworkInfo#isConnected()} before initiating diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index 79f920e0c28f..802121093a64 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -49,6 +49,7 @@ interface IConnectivityManager NetworkInfo[] getAllNetworkInfo(); Network getNetworkForType(int networkType); Network[] getAllNetworks(); + NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId); NetworkInfo getProvisioningOrActiveNetworkInfo(); diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java index ce7ad65fef2d..a7f9c5bcc0ab 100644 --- a/core/java/android/net/NetworkCapabilities.java +++ b/core/java/android/net/NetworkCapabilities.java @@ -154,9 +154,16 @@ public final class NetworkCapabilities implements Parcelable { */ public static final int NET_CAPABILITY_NOT_VPN = 15; + /** + * Indicates that connectivity on this network was successfully validated. For example, for a + * network with NET_CAPABILITY_INTERNET, it means that Internet connectivity was successfully + * detected. + * @hide + */ + public static final int NET_CAPABILITY_VALIDATED = 16; private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS; - private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_NOT_VPN; + private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_VALIDATED; /** * Adds the given capability to this {@code NetworkCapability} instance. |
