From a134636a4bef27885b32918321bfa0cfa5acd9df Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Tue, 8 Jul 2014 15:31:37 -0700 Subject: [PATCH] Add Trust to NetworkCapabilities. Indicates the user has indicated implicit trust of a network. This generally means it's a sim-selected carrier, a plugged in ethernet, a paired BT device or a wifi they've asked to connect to. Untrusted networks are probably limited to unknown wifi AP. Change-Id: I89490bdaa3c2d63d33f876c72d8b088dc155fa3d --- core/java/android/net/NetworkCapabilities.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java index fe96287c83..00200d0f42 100644 --- a/core/java/android/net/NetworkCapabilities.java +++ b/core/java/android/net/NetworkCapabilities.java @@ -63,7 +63,8 @@ public final class NetworkCapabilities implements Parcelable { * Represents the network's capabilities. If any are specified they will be satisfied * by any Network that matches all of them. */ - private long mNetworkCapabilities = (1 << NET_CAPABILITY_NOT_RESTRICTED); + private long mNetworkCapabilities = (1 << NET_CAPABILITY_NOT_RESTRICTED) | + (1 << NET_CAPABILITY_TRUSTED); /** * Indicates this is a network that has the ability to reach the @@ -149,8 +150,17 @@ public final class NetworkCapabilities implements Parcelable { */ public static final int NET_CAPABILITY_NOT_RESTRICTED = 13; + /** + * Indicates that the user has indicated implicit trust of this network. This + * generally means it's a sim-selected carrier, a plugged in ethernet, a paired + * BT device or a wifi the user asked to connect to. Untrusted networks + * are probably limited to unknown wifi AP. Set by default. + */ + public static final int NET_CAPABILITY_TRUSTED = 14; + + private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS; - private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_NOT_RESTRICTED; + private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_TRUSTED; /** * Adds the given capability to this {@code NetworkCapability} instance. @@ -512,6 +522,7 @@ public final class NetworkCapabilities implements Parcelable { case NET_CAPABILITY_NOT_METERED: capabilities += "NOT_METERED"; break; case NET_CAPABILITY_INTERNET: capabilities += "INTERNET"; break; case NET_CAPABILITY_NOT_RESTRICTED: capabilities += "NOT_RESTRICTED"; break; + case NET_CAPABILITY_TRUSTED: capabilities += "TRUSTED"; break; } if (++i < types.length) capabilities += "&"; }