From 74822b6dc323bdb8c5024e3749e1186fe7572f0c Mon Sep 17 00:00:00 2001 From: lesl Date: Thu, 6 May 2021 12:44:21 +0800 Subject: [PATCH] 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 Change-Id: I6fbec14e7be4dc4b5c2fd3659a801521c81b233c --- src/com/android/settings/SettingsDumpService.java | 4 ++-- src/com/android/settings/datausage/lib/DataUsageLib.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java index a935c18be01..2a041f33772 100644 --- a/src/com/android/settings/SettingsDumpService.java +++ b/src/com/android/settings/SettingsDumpService.java @@ -111,9 +111,9 @@ public class SettingsDumpService extends Service { for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) { telephonyManager = telephonyManager .createForSubscriptionId(info.getSubscriptionId()); - NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll( + NetworkTemplate carrier = NetworkTemplate.buildTemplateCarrierMetered( telephonyManager.getSubscriberId()); - final JSONObject usage = dumpDataUsage(mobileAll, controller); + final JSONObject usage = dumpDataUsage(carrier, controller); usage.put("subId", info.getSubscriptionId()); array.put(usage); } diff --git a/src/com/android/settings/datausage/lib/DataUsageLib.java b/src/com/android/settings/datausage/lib/DataUsageLib.java index 786f0ecee2e..93907aade62 100644 --- a/src/com/android/settings/datausage/lib/DataUsageLib.java +++ b/src/com/android/settings/datausage/lib/DataUsageLib.java @@ -73,7 +73,7 @@ public class DataUsageLib { private static NetworkTemplate getMobileTemplateForSubId( TelephonyManager telephonyManager, int subId) { - return NetworkTemplate.buildTemplateMobileAll( + return NetworkTemplate.buildTemplateCarrierMetered( telephonyManager.getSubscriberId(subId)); } }