From 7c19a1abd634c8053c54982f782e5ed4e1fe6ad8 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 27 Oct 2017 17:22:59 -0600 Subject: [PATCH] Define NOT_ROAMING network capability. The "roaming" state of a network really belongs on NetworkCapabilities instead of being published through NetworkInfo.isRoaming(). One major reason is to support developers creating NetworkRequests for a non-roaming network. Watch for any capability changes that network statistics are interested in (either metered or roaming) and notify it to perform an update pass; fixes bug where we previously only triggered on roaming changes. Fix bug in VPNs where metered/roaming capabilities of underlying networks weren't being propagated; this was probably preventing some jobs from running over unmetered networks, and causing other jobs to run over roaming networks! Also passes along link bandwidth information from underlying networks, and propegates any changes to underlying networks. Fix race condition by reading prevNc inside lock. Utility methods correctly calculate min/max link bandwidth values. Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.,com.android.server.ConnectivityServiceTest Bug: 68397798, 16207332 Change-Id: I3e1a6544c902bf3a79356b72d3616af1fd2b0f49 --- core/java/android/net/NetworkIdentity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java index 0775bdaaf3..df404b7dce 100644 --- a/core/java/android/net/NetworkIdentity.java +++ b/core/java/android/net/NetworkIdentity.java @@ -189,7 +189,8 @@ public class NetworkIdentity implements Comparable { String subscriberId = null; String networkId = null; - boolean roaming = false; + boolean roaming = !state.networkCapabilities.hasCapability( + NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING); boolean metered = !state.networkCapabilities.hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED); @@ -203,7 +204,6 @@ public class NetworkIdentity implements Comparable { } subscriberId = state.subscriberId; - roaming = state.networkInfo.isRoaming(); } else if (type == TYPE_WIFI) { if (state.networkId != null) {