Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -18350,6 +18350,7 @@ package android.net { method public boolean hasTransport(int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.NetworkCapabilities> CREATOR; field public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; // 0x11 field public static final int NET_CAPABILITY_CBS = 5; // 0x5 field public static final int NET_CAPABILITY_DUN = 2; // 0x2 field public static final int NET_CAPABILITY_EIMS = 10; // 0xa api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -19851,6 +19851,7 @@ package android.net { method public boolean hasTransport(int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.NetworkCapabilities> CREATOR; field public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; // 0x11 field public static final int NET_CAPABILITY_CBS = 5; // 0x5 field public static final int NET_CAPABILITY_DUN = 2; // 0x2 field public static final int NET_CAPABILITY_EIMS = 10; // 0xa core/java/android/net/NetworkCapabilities.java +7 −1 Original line number Diff line number Diff line Loading @@ -176,8 +176,14 @@ public final class NetworkCapabilities implements Parcelable { */ public static final int NET_CAPABILITY_VALIDATED = 16; /** * Indicates that this network was found to have a captive portal in place last time it was * probed. */ public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS; private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_VALIDATED; private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_CAPTIVE_PORTAL; /** * Adds the given capability to this {@code NetworkCapability} instance. Loading services/core/java/com/android/server/ConnectivityService.java +34 −12 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.net.ConnectivityManager.TYPE_NONE; import static android.net.ConnectivityManager.TYPE_VPN; import static android.net.ConnectivityManager.getNetworkTypeName; import static android.net.ConnectivityManager.isNetworkTypeValid; import static android.net.NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL; import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED; Loading Loading @@ -1993,18 +1994,24 @@ public class ConnectivityService extends IConnectivityManager.Stub } case NetworkMonitor.EVENT_PROVISIONING_NOTIFICATION: { final int netId = msg.arg2; if (msg.arg1 == 0) { setProvNotificationVisibleIntent(false, netId, null, 0, null, null); } else { final boolean visible = (msg.arg1 != 0); final NetworkAgentInfo nai; synchronized (mNetworkForNetId) { nai = mNetworkForNetId.get(netId); } // If captive portal status has changed, update capabilities. if (nai != null && (visible != nai.lastCaptivePortalDetected)) { nai.lastCaptivePortalDetected = visible; nai.everCaptivePortalDetected |= visible; updateCapabilities(nai, nai.networkCapabilities); } if (!visible) { setProvNotificationVisibleIntent(false, netId, null, 0, null, null); } else { if (nai == null) { loge("EVENT_PROVISIONING_NOTIFICATION from unknown NetworkMonitor"); break; } nai.captivePortalDetected = true; setProvNotificationVisibleIntent(true, netId, NotificationType.SIGN_IN, nai.networkInfo.getType(),nai.networkInfo.getExtraInfo(), (PendingIntent)msg.obj); Loading Loading @@ -2426,7 +2433,7 @@ public class ConnectivityService extends IConnectivityManager.Stub // Only prompt if the network is unvalidated and was explicitly selected by the user, and if // we haven't already been told to switch to it regardless of whether it validated or not. // Also don't prompt on captive portals because we're already prompting the user to sign in. if (nai == null || nai.everValidated || nai.captivePortalDetected || if (nai == null || nai.everValidated || nai.everCaptivePortalDetected || !nai.networkMisc.explicitlySelected || nai.networkMisc.acceptUnvalidated) { return; } Loading Loading @@ -4046,17 +4053,32 @@ public class ConnectivityService extends IConnectivityManager.Stub mNumDnsEntries = last; } /** * Update the NetworkCapabilities for {@code networkAgent} to {@code networkCapabilities} * augmented with any stateful capabilities implied from {@code networkAgent} * (e.g., validated status and captive portal status). * * @param networkAgent the network having its capabilities updated. * @param networkCapabilities the new network capabilities. */ private void updateCapabilities(NetworkAgentInfo networkAgent, NetworkCapabilities networkCapabilities) { // Don't modify caller's NetworkCapabilities. networkCapabilities = new NetworkCapabilities(networkCapabilities); if (networkAgent.lastValidated) { networkCapabilities.addCapability(NET_CAPABILITY_VALIDATED); } else { networkCapabilities.removeCapability(NET_CAPABILITY_VALIDATED); } if (networkAgent.lastCaptivePortalDetected) { networkCapabilities.addCapability(NET_CAPABILITY_CAPTIVE_PORTAL); } else { networkCapabilities.removeCapability(NET_CAPABILITY_CAPTIVE_PORTAL); } if (!Objects.equals(networkAgent.networkCapabilities, networkCapabilities)) { synchronized (networkAgent) { networkAgent.networkCapabilities = networkCapabilities; } if (networkAgent.lastValidated) { networkAgent.networkCapabilities.addCapability(NET_CAPABILITY_VALIDATED); // There's no need to remove the capability if we think the network is unvalidated, // because NetworkAgents don't set the validated capability. } rematchAllNetworksAndRequests(networkAgent, networkAgent.getCurrentScore()); notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_CAP_CHANGED); } Loading services/core/java/com/android/server/connectivity/NetworkAgentInfo.java +6 −2 Original line number Diff line number Diff line Loading @@ -66,7 +66,10 @@ public class NetworkAgentInfo { // Whether a captive portal was ever detected on this network. // This is a sticky bit; once set it is never cleared. public boolean captivePortalDetected; public boolean everCaptivePortalDetected; // Whether a captive portal was found during the last network validation attempt. public boolean lastCaptivePortalDetected; // This represents the last score received from the NetworkAgent. private int currentScore; Loading Loading @@ -174,7 +177,8 @@ public class NetworkAgentInfo { "created{" + created + "} " + "explicitlySelected{" + networkMisc.explicitlySelected + "} " + "acceptUnvalidated{" + networkMisc.acceptUnvalidated + "} " + "captivePortalDetected{" + captivePortalDetected + "} " + "everCaptivePortalDetected{" + everCaptivePortalDetected + "} " + "lastCaptivePortalDetected{" + lastCaptivePortalDetected + "} " + "}"; } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -18350,6 +18350,7 @@ package android.net { method public boolean hasTransport(int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.NetworkCapabilities> CREATOR; field public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; // 0x11 field public static final int NET_CAPABILITY_CBS = 5; // 0x5 field public static final int NET_CAPABILITY_DUN = 2; // 0x2 field public static final int NET_CAPABILITY_EIMS = 10; // 0xa
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -19851,6 +19851,7 @@ package android.net { method public boolean hasTransport(int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.NetworkCapabilities> CREATOR; field public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; // 0x11 field public static final int NET_CAPABILITY_CBS = 5; // 0x5 field public static final int NET_CAPABILITY_DUN = 2; // 0x2 field public static final int NET_CAPABILITY_EIMS = 10; // 0xa
core/java/android/net/NetworkCapabilities.java +7 −1 Original line number Diff line number Diff line Loading @@ -176,8 +176,14 @@ public final class NetworkCapabilities implements Parcelable { */ public static final int NET_CAPABILITY_VALIDATED = 16; /** * Indicates that this network was found to have a captive portal in place last time it was * probed. */ public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS; private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_VALIDATED; private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_CAPTIVE_PORTAL; /** * Adds the given capability to this {@code NetworkCapability} instance. Loading
services/core/java/com/android/server/ConnectivityService.java +34 −12 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.net.ConnectivityManager.TYPE_NONE; import static android.net.ConnectivityManager.TYPE_VPN; import static android.net.ConnectivityManager.getNetworkTypeName; import static android.net.ConnectivityManager.isNetworkTypeValid; import static android.net.NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL; import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED; Loading Loading @@ -1993,18 +1994,24 @@ public class ConnectivityService extends IConnectivityManager.Stub } case NetworkMonitor.EVENT_PROVISIONING_NOTIFICATION: { final int netId = msg.arg2; if (msg.arg1 == 0) { setProvNotificationVisibleIntent(false, netId, null, 0, null, null); } else { final boolean visible = (msg.arg1 != 0); final NetworkAgentInfo nai; synchronized (mNetworkForNetId) { nai = mNetworkForNetId.get(netId); } // If captive portal status has changed, update capabilities. if (nai != null && (visible != nai.lastCaptivePortalDetected)) { nai.lastCaptivePortalDetected = visible; nai.everCaptivePortalDetected |= visible; updateCapabilities(nai, nai.networkCapabilities); } if (!visible) { setProvNotificationVisibleIntent(false, netId, null, 0, null, null); } else { if (nai == null) { loge("EVENT_PROVISIONING_NOTIFICATION from unknown NetworkMonitor"); break; } nai.captivePortalDetected = true; setProvNotificationVisibleIntent(true, netId, NotificationType.SIGN_IN, nai.networkInfo.getType(),nai.networkInfo.getExtraInfo(), (PendingIntent)msg.obj); Loading Loading @@ -2426,7 +2433,7 @@ public class ConnectivityService extends IConnectivityManager.Stub // Only prompt if the network is unvalidated and was explicitly selected by the user, and if // we haven't already been told to switch to it regardless of whether it validated or not. // Also don't prompt on captive portals because we're already prompting the user to sign in. if (nai == null || nai.everValidated || nai.captivePortalDetected || if (nai == null || nai.everValidated || nai.everCaptivePortalDetected || !nai.networkMisc.explicitlySelected || nai.networkMisc.acceptUnvalidated) { return; } Loading Loading @@ -4046,17 +4053,32 @@ public class ConnectivityService extends IConnectivityManager.Stub mNumDnsEntries = last; } /** * Update the NetworkCapabilities for {@code networkAgent} to {@code networkCapabilities} * augmented with any stateful capabilities implied from {@code networkAgent} * (e.g., validated status and captive portal status). * * @param networkAgent the network having its capabilities updated. * @param networkCapabilities the new network capabilities. */ private void updateCapabilities(NetworkAgentInfo networkAgent, NetworkCapabilities networkCapabilities) { // Don't modify caller's NetworkCapabilities. networkCapabilities = new NetworkCapabilities(networkCapabilities); if (networkAgent.lastValidated) { networkCapabilities.addCapability(NET_CAPABILITY_VALIDATED); } else { networkCapabilities.removeCapability(NET_CAPABILITY_VALIDATED); } if (networkAgent.lastCaptivePortalDetected) { networkCapabilities.addCapability(NET_CAPABILITY_CAPTIVE_PORTAL); } else { networkCapabilities.removeCapability(NET_CAPABILITY_CAPTIVE_PORTAL); } if (!Objects.equals(networkAgent.networkCapabilities, networkCapabilities)) { synchronized (networkAgent) { networkAgent.networkCapabilities = networkCapabilities; } if (networkAgent.lastValidated) { networkAgent.networkCapabilities.addCapability(NET_CAPABILITY_VALIDATED); // There's no need to remove the capability if we think the network is unvalidated, // because NetworkAgents don't set the validated capability. } rematchAllNetworksAndRequests(networkAgent, networkAgent.getCurrentScore()); notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_CAP_CHANGED); } Loading
services/core/java/com/android/server/connectivity/NetworkAgentInfo.java +6 −2 Original line number Diff line number Diff line Loading @@ -66,7 +66,10 @@ public class NetworkAgentInfo { // Whether a captive portal was ever detected on this network. // This is a sticky bit; once set it is never cleared. public boolean captivePortalDetected; public boolean everCaptivePortalDetected; // Whether a captive portal was found during the last network validation attempt. public boolean lastCaptivePortalDetected; // This represents the last score received from the NetworkAgent. private int currentScore; Loading Loading @@ -174,7 +177,8 @@ public class NetworkAgentInfo { "created{" + created + "} " + "explicitlySelected{" + networkMisc.explicitlySelected + "} " + "acceptUnvalidated{" + networkMisc.acceptUnvalidated + "} " + "captivePortalDetected{" + captivePortalDetected + "} " + "everCaptivePortalDetected{" + everCaptivePortalDetected + "} " + "lastCaptivePortalDetected{" + lastCaptivePortalDetected + "} " + "}"; } Loading