wifi: Use new API for data usage function

For mobile, a old API: buildTemplateMobileAll doesn't includes the
merged wifi network, call the new API: buildTemplateCarrierMetered
to replace the old one.

PS: Not only usage functionality but also apply to network policy
control since the default policy is changing to use
new API: buildTemplateCarrier now.

Test: make RunSettingsRoboTests ROBOTEST_FILTER=SettingsDumpServiceTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=DataUsageLibTest
Test: Manual Test, modify the mobile usage warming and limit bytes and
      check the data via adb shell dumpsys netpolicy

Bug: 176396812
Merged-In: I6fbec14e7be4dc4b5c2fd3659a801521c81b233c
Change-Id: I6fbec14e7be4dc4b5c2fd3659a801521c81b233c
This commit is contained in:
lesl
2021-05-06 12:44:21 +08:00
committed by Les Lee
parent 3940e5293c
commit 5012cef58f
2 changed files with 3 additions and 3 deletions

View File

@@ -111,9 +111,9 @@ public class SettingsDumpService extends Service {
for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) { for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) {
telephonyManager = telephonyManager telephonyManager = telephonyManager
.createForSubscriptionId(info.getSubscriptionId()); .createForSubscriptionId(info.getSubscriptionId());
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll( NetworkTemplate carrier = NetworkTemplate.buildTemplateCarrierMetered(
telephonyManager.getSubscriberId()); telephonyManager.getSubscriberId());
final JSONObject usage = dumpDataUsage(mobileAll, controller); final JSONObject usage = dumpDataUsage(carrier, controller);
usage.put("subId", info.getSubscriptionId()); usage.put("subId", info.getSubscriptionId());
array.put(usage); array.put(usage);
} }

View File

@@ -73,7 +73,7 @@ public class DataUsageLib {
private static NetworkTemplate getMobileTemplateForSubId( private static NetworkTemplate getMobileTemplateForSubId(
TelephonyManager telephonyManager, int subId) { TelephonyManager telephonyManager, int subId) {
return NetworkTemplate.buildTemplateMobileAll( return NetworkTemplate.buildTemplateCarrierMetered(
telephonyManager.getSubscriberId(subId)); telephonyManager.getSubscriberId(subId));
} }
} }