From 6d53853cfa5c5bfb36580efa6f5b2a24702deecd Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Fri, 24 Dec 2021 08:31:26 +0000 Subject: [PATCH] [MS18] Augment data usage by default Follow-up from ag/2815797, callers who uses the hidden API will have their data augmented by default, and the public API offers a way to opt-into augmentation. However, since the data usage is going to the module. All the hidden API usage must be eliminated. Also, from user perspective, it is better for UI and API to have aligned behavior. Thus, enable augment data usage for public API callers. Test: atest FrameworksNetTests \ android.app.usage.cts.NetworkUsageStatsTest Bug: 204830222 Change-Id: Ida254fac8d44c32d388f1886a866f7324a41ce75 --- .../src/android/app/usage/NetworkStatsManager.java | 1 + .../src/com/android/server/net/NetworkStatsService.java | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/ConnectivityT/framework-t/src/android/app/usage/NetworkStatsManager.java b/packages/ConnectivityT/framework-t/src/android/app/usage/NetworkStatsManager.java index 40b6371da72b6..2b9560e7ec52b 100644 --- a/packages/ConnectivityT/framework-t/src/android/app/usage/NetworkStatsManager.java +++ b/packages/ConnectivityT/framework-t/src/android/app/usage/NetworkStatsManager.java @@ -139,6 +139,7 @@ public class NetworkStatsManager { mContext = context; mService = service; setPollOnOpen(true); + setAugmentWithSubscriptionPlan(true); } /** @hide */ diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java index 2beca73ecd72d..df066c21d7be9 100644 --- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java @@ -655,8 +655,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub { @Override public INetworkStatsSession openSession() { - // NOTE: if callers want to get non-augmented data, they should go - // through the public API return openSessionInternal(NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN, null); } @@ -876,8 +874,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub { private long getNetworkTotalBytes(NetworkTemplate template, long start, long end) { assertSystemReady(); - // NOTE: if callers want to get non-augmented data, they should go - // through the public API return internalGetSummaryForNetwork(template, NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN, start, end, NetworkStatsAccess.Level.DEVICE, Binder.getCallingUid()).getTotalBytes();