Add NetworkAgent event for ExplicitlySelected
Lets Wifi tell us when the user selected this AP vs auto-connected.
bug:17396168
Change-Id: I6e067ab62ed49040629aa31fe07ff880d3d542f0
diff --git a/core/java/android/net/NetworkMisc.java b/core/java/android/net/NetworkMisc.java
index 34f6cf4..5d2a43d 100644
--- a/core/java/android/net/NetworkMisc.java
+++ b/core/java/android/net/NetworkMisc.java
@@ -25,12 +25,32 @@
* @hide
*/
public class NetworkMisc implements Parcelable {
+
/**
* If the {@link Network} is a VPN, whether apps are allowed to bypass the VPN. This is set by
* a {@link VpnService} and used by {@link ConnectivityService} when creating a VPN.
*/
public boolean allowBypass;
+ /**
+ * Set if the network was manually/explicitly connected to by the user either from settings
+ * or a 3rd party app. For example, turning on cell data is not explicit but tapping on a wifi
+ * ap in the wifi settings to trigger a connection is explicit. A 3rd party app asking to
+ * connect to a particular access point is also explicit, though this may change in the future
+ * as we want apps to use the multinetwork apis.
+ */
+ public boolean explicitlySelected;
+
+ public NetworkMisc() {
+ }
+
+ public NetworkMisc(NetworkMisc nm) {
+ if (nm != null) {
+ allowBypass = nm.allowBypass;
+ explicitlySelected = nm.explicitlySelected;
+ }
+ }
+
@Override
public int describeContents() {
return 0;
@@ -39,6 +59,7 @@
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(allowBypass ? 1 : 0);
+ out.writeInt(explicitlySelected ? 1 : 0);
}
public static final Creator<NetworkMisc> CREATOR = new Creator<NetworkMisc>() {
@@ -46,6 +67,7 @@
public NetworkMisc createFromParcel(Parcel in) {
NetworkMisc networkMisc = new NetworkMisc();
networkMisc.allowBypass = in.readInt() != 0;
+ networkMisc.explicitlySelected = in.readInt() != 0;
return networkMisc;
}