Merge "Respect metered filter in matchesMobile*" into sc-v2-dev am: 3a1184edf3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15939043 Change-Id: If8af6d0b150f3bc4dbbc12f8a96478cf08b23f5d
This commit is contained in:
@@ -168,11 +168,11 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
@NetworkType int ratType) {
|
@NetworkType int ratType) {
|
||||||
if (TextUtils.isEmpty(subscriberId)) {
|
if (TextUtils.isEmpty(subscriberId)) {
|
||||||
return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null, null,
|
return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null, null,
|
||||||
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
||||||
}
|
}
|
||||||
return new NetworkTemplate(MATCH_MOBILE, subscriberId, new String[]{subscriberId}, null,
|
return new NetworkTemplate(MATCH_MOBILE, subscriberId, new String[]{subscriberId}, null,
|
||||||
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +305,7 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Deprecate this constructor, mark it @UnsupportedAppUsage(maxTargetSdk = S)
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public NetworkTemplate(int matchRule, String subscriberId, String networkId) {
|
public NetworkTemplate(int matchRule, String subscriberId, String networkId) {
|
||||||
this(matchRule, subscriberId, new String[] { subscriberId }, networkId);
|
this(matchRule, subscriberId, new String[] { subscriberId }, networkId);
|
||||||
@@ -312,9 +313,14 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
|
|
||||||
public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds,
|
public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds,
|
||||||
String networkId) {
|
String networkId) {
|
||||||
this(matchRule, subscriberId, matchSubscriberIds, networkId, METERED_ALL, ROAMING_ALL,
|
// Older versions used to only match MATCH_MOBILE and MATCH_MOBILE_WILDCARD templates
|
||||||
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL,
|
// to metered networks. It is now possible to match mobile with any meteredness, but
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
// in order to preserve backward compatibility of @UnsupportedAppUsage methods, this
|
||||||
|
//constructor passes METERED_YES for these types.
|
||||||
|
this(matchRule, subscriberId, matchSubscriberIds, networkId,
|
||||||
|
(matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD) ? METERED_YES
|
||||||
|
: METERED_ALL , ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
|
||||||
|
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove it after updating all of the caller.
|
// TODO: Remove it after updating all of the caller.
|
||||||
@@ -589,11 +595,7 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
// TODO: consider matching against WiMAX subscriber identity
|
// TODO: consider matching against WiMAX subscriber identity
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Only metered mobile network would be matched regardless of metered filter.
|
return ident.mType == TYPE_MOBILE && !ArrayUtils.isEmpty(mMatchSubscriberIds)
|
||||||
// This is used to exclude non-metered APNs, e.g. IMS. See ag/908650.
|
|
||||||
// TODO: Respect metered filter and remove mMetered condition.
|
|
||||||
return (ident.mType == TYPE_MOBILE && ident.mMetered)
|
|
||||||
&& !ArrayUtils.isEmpty(mMatchSubscriberIds)
|
|
||||||
&& ArrayUtils.contains(mMatchSubscriberIds, ident.mSubscriberId)
|
&& ArrayUtils.contains(mMatchSubscriberIds, ident.mSubscriberId)
|
||||||
&& matchesCollapsedRatType(ident);
|
&& matchesCollapsedRatType(ident);
|
||||||
}
|
}
|
||||||
@@ -707,8 +709,7 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
if (ident.mType == TYPE_WIMAX) {
|
if (ident.mType == TYPE_WIMAX) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return (ident.mType == TYPE_MOBILE && ident.mMetered)
|
return ident.mType == TYPE_MOBILE && matchesCollapsedRatType(ident);
|
||||||
&& matchesCollapsedRatType(ident);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public class MultipathPolicyTracker {
|
|||||||
subscriberId = tele.getSubscriberId();
|
subscriberId = tele.getSubscriberId();
|
||||||
mNetworkTemplate = new NetworkTemplate(
|
mNetworkTemplate = new NetworkTemplate(
|
||||||
NetworkTemplate.MATCH_MOBILE, subscriberId, new String[] { subscriberId },
|
NetworkTemplate.MATCH_MOBILE, subscriberId, new String[] { subscriberId },
|
||||||
null, NetworkStats.METERED_ALL, NetworkStats.ROAMING_ALL,
|
null, NetworkStats.METERED_YES, NetworkStats.ROAMING_ALL,
|
||||||
NetworkStats.DEFAULT_NETWORK_NO, NETWORK_TYPE_ALL, OEM_MANAGED_ALL,
|
NetworkStats.DEFAULT_NETWORK_NO, NETWORK_TYPE_ALL, OEM_MANAGED_ALL,
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
||||||
mUsageCallback = new UsageCallback() {
|
mUsageCallback = new UsageCallback() {
|
||||||
|
|||||||
Reference in New Issue
Block a user