summaryrefslogtreecommitdiff
path: root/framework-t/src/android/app/usage/NetworkStatsManager.java
diff options
context:
space:
mode:
authorJunyu Lai <junyulai@google.com>2022-01-19 08:33:21 +0000
committerjunyulai <junyulai@google.com>2022-01-22 01:01:49 +0800
commit6f39e805a1c82ae6c32bde6d750544e620a55b21 (patch)
tree98035a23a3d25ec717d71fd8c58d186a76d0ede9 /framework-t/src/android/app/usage/NetworkStatsManager.java
parent6dcaf9dee446b003482375c11bc8f4ac870f3409 (diff)
[MS66] Initialize TrafficStats with context
TrafficStats has static methods created in API level 8 that need access to NetworkStatsManager but doesn't take a context. Previously this was achieved by using ServiceManager, but with TrafficStats moving to the connectivity module, this is no longer possible. Instead, make sure TrafficStats has an appropriate context by the time any client code can call the relevant methods. • In app code, this achieved by passing the application context from ActivityThread#handleBindApplication, before any app code can run. • In the system server, this is achieved by passing the context right after creating service. Test: atest TrafficStatsTest CtsWebkitTestCases Bug: 204830222 Change-Id: I251bb8a4431ad12ff61929879ef1363cf06b9244
Diffstat (limited to 'framework-t/src/android/app/usage/NetworkStatsManager.java')
-rw-r--r--framework-t/src/android/app/usage/NetworkStatsManager.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/framework-t/src/android/app/usage/NetworkStatsManager.java b/framework-t/src/android/app/usage/NetworkStatsManager.java
index 683678ad46..8813f98451 100644
--- a/framework-t/src/android/app/usage/NetworkStatsManager.java
+++ b/framework-t/src/android/app/usage/NetworkStatsManager.java
@@ -157,6 +157,11 @@ public class NetworkStatsManager {
setAugmentWithSubscriptionPlan(true);
}
+ /** @hide */
+ public INetworkStatsService getBinder() {
+ return mService;
+ }
+
/**
* Set poll on open flag to indicate the poll is needed before service gets statistics
* result. This is default enabled. However, for any non-privileged caller, the poll might