From 62780368b08ab87a011d4626f37975c25fa5d6d7 Mon Sep 17 00:00:00 2001 From: Treehugger Robot Date: Fri, 16 Oct 2020 04:22:07 +0000 Subject: [PATCH] Allow the network stack to read network stats history Bug: 168984229 Test: testNetworkStatsProvider Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1450457 Change-Id: Ic9bd2d2d06c790a84e56ec8a6915f1faab16dda0 Merged-In: Ibb6342b0f263c874bb1f7ab4031a639778bad37e (cherry picked from commit 9010baec16faa806c2253f90225d002c4b2efb0c) --- .../java/com/android/server/net/NetworkStatsAccess.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/net/NetworkStatsAccess.java b/services/core/java/com/android/server/net/NetworkStatsAccess.java index 7c1c1c7ce4..72559b4825 100644 --- a/services/core/java/com/android/server/net/NetworkStatsAccess.java +++ b/services/core/java/com/android/server/net/NetworkStatsAccess.java @@ -28,6 +28,7 @@ import android.app.admin.DeviceAdminInfo; import android.app.admin.DevicePolicyManagerInternal; import android.content.Context; import android.content.pm.PackageManager; +import android.os.Process; import android.os.UserHandle; import android.telephony.TelephonyManager; @@ -113,10 +114,11 @@ public final class NetworkStatsAccess { TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; boolean isDeviceOwner = dpmi != null && dpmi.isActiveAdminWithPolicy(callingUid, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); + final int appId = UserHandle.getAppId(callingUid); if (hasCarrierPrivileges || isDeviceOwner - || UserHandle.getAppId(callingUid) == android.os.Process.SYSTEM_UID) { - // Carrier-privileged apps and device owners, and the system can access data usage for - // all apps on the device. + || appId == Process.SYSTEM_UID || appId == Process.NETWORK_STACK_UID) { + // Carrier-privileged apps and device owners, and the system (including the + // network stack) can access data usage for all apps on the device. return NetworkStatsAccess.Level.DEVICE; }