Merge "Have buildTemplateMobileWithRatType take metered parameter" am: 1c4d67b35b am: 3b9f70f655 am: 38f8607d5a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1779312 Change-Id: Ieb0766d4f148b98a21ef58c954bc3c49cbcef14f
This commit is contained in:
@@ -160,19 +160,19 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template to match cellular networks with the given IMSI and {@code ratType}.
|
* Template to match cellular networks with the given IMSI, {@code ratType} and
|
||||||
* Use {@link #NETWORK_TYPE_ALL} to include all network types when filtering.
|
* {@code metered}. Use {@link #NETWORK_TYPE_ALL} to include all network types when
|
||||||
* See {@code TelephonyManager.NETWORK_TYPE_*}.
|
* filtering. See {@code TelephonyManager.NETWORK_TYPE_*}.
|
||||||
*/
|
*/
|
||||||
public static NetworkTemplate buildTemplateMobileWithRatType(@Nullable String subscriberId,
|
public static NetworkTemplate buildTemplateMobileWithRatType(@Nullable String subscriberId,
|
||||||
@NetworkType int ratType) {
|
@NetworkType int ratType, int metered) {
|
||||||
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_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
metered, 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_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
metered, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL,
|
||||||
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
SUBSCRIBER_ID_MATCH_RULE_EXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import static android.net.NetworkIdentity.OEM_PAID;
|
|||||||
import static android.net.NetworkIdentity.OEM_PRIVATE;
|
import static android.net.NetworkIdentity.OEM_PRIVATE;
|
||||||
import static android.net.NetworkStats.DEFAULT_NETWORK_ALL;
|
import static android.net.NetworkStats.DEFAULT_NETWORK_ALL;
|
||||||
import static android.net.NetworkStats.METERED_ALL;
|
import static android.net.NetworkStats.METERED_ALL;
|
||||||
|
import static android.net.NetworkStats.METERED_YES;
|
||||||
import static android.net.NetworkStats.ROAMING_ALL;
|
import static android.net.NetworkStats.ROAMING_ALL;
|
||||||
import static android.net.NetworkTemplate.MATCH_ETHERNET;
|
import static android.net.NetworkTemplate.MATCH_ETHERNET;
|
||||||
import static android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD;
|
import static android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD;
|
||||||
@@ -1340,7 +1341,7 @@ public class StatsPullAtomService extends SystemService {
|
|||||||
@Nullable private NetworkStats getUidNetworkStatsSnapshotForTransport(int transport) {
|
@Nullable private NetworkStats getUidNetworkStatsSnapshotForTransport(int transport) {
|
||||||
final NetworkTemplate template = (transport == TRANSPORT_CELLULAR)
|
final NetworkTemplate template = (transport == TRANSPORT_CELLULAR)
|
||||||
? NetworkTemplate.buildTemplateMobileWithRatType(
|
? NetworkTemplate.buildTemplateMobileWithRatType(
|
||||||
/*subscriptionId=*/null, NETWORK_TYPE_ALL)
|
/*subscriptionId=*/null, NETWORK_TYPE_ALL, METERED_YES)
|
||||||
: NetworkTemplate.buildTemplateWifiWildcard();
|
: NetworkTemplate.buildTemplateWifiWildcard();
|
||||||
return getUidNetworkStatsSnapshotForTemplate(template, /*includeTags=*/false);
|
return getUidNetworkStatsSnapshotForTemplate(template, /*includeTags=*/false);
|
||||||
}
|
}
|
||||||
@@ -1380,7 +1381,8 @@ public class StatsPullAtomService extends SystemService {
|
|||||||
final List<NetworkStatsExt> ret = new ArrayList<>();
|
final List<NetworkStatsExt> ret = new ArrayList<>();
|
||||||
for (final int ratType : getAllCollapsedRatTypes()) {
|
for (final int ratType : getAllCollapsedRatTypes()) {
|
||||||
final NetworkTemplate template =
|
final NetworkTemplate template =
|
||||||
buildTemplateMobileWithRatType(subInfo.subscriberId, ratType);
|
buildTemplateMobileWithRatType(subInfo.subscriberId, ratType,
|
||||||
|
METERED_YES);
|
||||||
final NetworkStats stats =
|
final NetworkStats stats =
|
||||||
getUidNetworkStatsSnapshotForTemplate(template, /*includeTags=*/false);
|
getUidNetworkStatsSnapshotForTemplate(template, /*includeTags=*/false);
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user