diff options
author | Bryse Flowers <bflowers@codeaurora.org> | 2016-02-18 16:20:12 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2016-05-21 05:06:14 -0700 |
commit | 5fafd29ddcc892ed057653a3e5481f655e5a87a0 (patch) | |
tree | f5c1ea88980188116a29c5ba3f39b64ea3e693fe /services/core | |
parent | cca9cb7a8a64b21280045fe76c0902dbab75f386 (diff) | |
download | frameworks_base-5fafd29ddcc892ed057653a3e5481f655e5a87a0.zip frameworks_base-5fafd29ddcc892ed057653a3e5481f655e5a87a0.tar.gz frameworks_base-5fafd29ddcc892ed057653a3e5481f655e5a87a0.tar.bz2 |
server: Whitelist non-INTERNET/non-CELLULAR Network for metering
Avoid setting a quota or counting statistics for non-internet
and non-cellular Networks. Fixes an issue with metering feature
where mobile data usage is incorrectly applied to IMS or other
non-internet PDN.
Change-Id: Ib68f5e560ea1dd230747e4f367081501b70cfc60
CRs-Fixed: 984189
Diffstat (limited to 'services/core')
-rw-r--r-- | services/core/java/com/android/server/net/NetworkPolicyManagerService.java | 7 | ||||
-rw-r--r-- | services/core/java/com/android/server/net/NetworkStatsService.java | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java index 1738684..4c847a2 100644 --- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java @@ -108,6 +108,7 @@ import android.net.INetworkPolicyListener; import android.net.INetworkPolicyManager; import android.net.INetworkStatsService; import android.net.LinkProperties; +import android.net.NetworkCapabilities; import android.net.NetworkIdentity; import android.net.NetworkInfo; import android.net.NetworkPolicy; @@ -1209,7 +1210,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { final ArrayList<Pair<String, NetworkIdentity>> connIdents = new ArrayList<>(states.length); final ArraySet<String> connIfaces = new ArraySet<String>(states.length); for (NetworkState state : states) { - if (state.networkInfo.isConnected()) { + if (state.networkInfo.isConnected() && (state.networkCapabilities == null + || !state.networkCapabilities.hasTransport( + NetworkCapabilities.TRANSPORT_CELLULAR) + || state.networkCapabilities.hasCapability( + NetworkCapabilities.NET_CAPABILITY_INTERNET))) { final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state); final String baseIface = state.linkProperties.getInterfaceName(); diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java index 963aa7c..baaf055 100644 --- a/services/core/java/com/android/server/net/NetworkStatsService.java +++ b/services/core/java/com/android/server/net/NetworkStatsService.java @@ -81,6 +81,7 @@ import android.net.INetworkManagementEventObserver; import android.net.INetworkStatsService; import android.net.INetworkStatsSession; import android.net.LinkProperties; +import android.net.NetworkCapabilities; import android.net.NetworkIdentity; import android.net.NetworkInfo; import android.net.NetworkState; @@ -941,7 +942,11 @@ public class NetworkStatsService extends INetworkStatsService.Stub { final ArraySet<String> mobileIfaces = new ArraySet<>(); for (NetworkState state : states) { - if (state.networkInfo.isConnected()) { + if (state.networkInfo.isConnected() && (state.networkCapabilities == null + || !state.networkCapabilities.hasTransport( + NetworkCapabilities.TRANSPORT_CELLULAR) + || state.networkCapabilities.hasCapability( + NetworkCapabilities.NET_CAPABILITY_INTERNET))) { final boolean isMobile = isNetworkTypeMobile(state.networkInfo.getType()); final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state); |