Loading packages/ConnectivityT/framework-t/src/android/net/NetworkStatsAccess.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; package android.net; import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY; import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.net.NetworkStats.UID_ALL; import static android.net.NetworkStats.UID_ALL; import static android.net.TrafficStats.UID_REMOVED; import static android.net.TrafficStats.UID_REMOVED; import static android.net.TrafficStats.UID_TETHERING; import static android.net.TrafficStats.UID_TETHERING; Loading Loading @@ -106,7 +107,7 @@ public final class NetworkStatsAccess { /** Returns the {@link NetworkStatsAccess.Level} for the given caller. */ /** Returns the {@link NetworkStatsAccess.Level} for the given caller. */ public static @NetworkStatsAccess.Level int checkAccessLevel( public static @NetworkStatsAccess.Level int checkAccessLevel( Context context, int callingUid, String callingPackage) { Context context, int callingPid, int callingUid, String callingPackage) { final DevicePolicyManager mDpm = context.getSystemService(DevicePolicyManager.class); final DevicePolicyManager mDpm = context.getSystemService(DevicePolicyManager.class); final TelephonyManager tm = (TelephonyManager) final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); context.getSystemService(Context.TELEPHONY_SERVICE); Loading @@ -123,8 +124,12 @@ public final class NetworkStatsAccess { final boolean isDeviceOwner = mDpm != null && mDpm.isDeviceOwnerApp(callingPackage); final boolean isDeviceOwner = mDpm != null && mDpm.isDeviceOwnerApp(callingPackage); final int appId = UserHandle.getAppId(callingUid); final int appId = UserHandle.getAppId(callingUid); final boolean isNetworkStack = context.checkPermission( android.Manifest.permission.NETWORK_STACK, callingPid, callingUid) == PERMISSION_GRANTED; if (hasCarrierPrivileges || isDeviceOwner if (hasCarrierPrivileges || isDeviceOwner || appId == Process.SYSTEM_UID || appId == Process.NETWORK_STACK_UID) { || appId == Process.SYSTEM_UID || isNetworkStack) { // Carrier-privileged apps and device owners, and the system (including the // Carrier-privileged apps and device owners, and the system (including the // network stack) can access data usage for all apps on the device. // network stack) can access data usage for all apps on the device. return NetworkStatsAccess.Level.DEVICE; return NetworkStatsAccess.Level.DEVICE; Loading packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -809,7 +809,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { private @NetworkStatsAccess.Level int checkAccessLevel(String callingPackage) { private @NetworkStatsAccess.Level int checkAccessLevel(String callingPackage) { return NetworkStatsAccess.checkAccessLevel( return NetworkStatsAccess.checkAccessLevel( mContext, Binder.getCallingUid(), callingPackage); mContext, Binder.getCallingPid(), Binder.getCallingUid(), callingPackage); } } /** /** Loading Loading
packages/ConnectivityT/framework-t/src/android/net/NetworkStatsAccess.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net; package android.net; import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY; import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.net.NetworkStats.UID_ALL; import static android.net.NetworkStats.UID_ALL; import static android.net.TrafficStats.UID_REMOVED; import static android.net.TrafficStats.UID_REMOVED; import static android.net.TrafficStats.UID_TETHERING; import static android.net.TrafficStats.UID_TETHERING; Loading Loading @@ -106,7 +107,7 @@ public final class NetworkStatsAccess { /** Returns the {@link NetworkStatsAccess.Level} for the given caller. */ /** Returns the {@link NetworkStatsAccess.Level} for the given caller. */ public static @NetworkStatsAccess.Level int checkAccessLevel( public static @NetworkStatsAccess.Level int checkAccessLevel( Context context, int callingUid, String callingPackage) { Context context, int callingPid, int callingUid, String callingPackage) { final DevicePolicyManager mDpm = context.getSystemService(DevicePolicyManager.class); final DevicePolicyManager mDpm = context.getSystemService(DevicePolicyManager.class); final TelephonyManager tm = (TelephonyManager) final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); context.getSystemService(Context.TELEPHONY_SERVICE); Loading @@ -123,8 +124,12 @@ public final class NetworkStatsAccess { final boolean isDeviceOwner = mDpm != null && mDpm.isDeviceOwnerApp(callingPackage); final boolean isDeviceOwner = mDpm != null && mDpm.isDeviceOwnerApp(callingPackage); final int appId = UserHandle.getAppId(callingUid); final int appId = UserHandle.getAppId(callingUid); final boolean isNetworkStack = context.checkPermission( android.Manifest.permission.NETWORK_STACK, callingPid, callingUid) == PERMISSION_GRANTED; if (hasCarrierPrivileges || isDeviceOwner if (hasCarrierPrivileges || isDeviceOwner || appId == Process.SYSTEM_UID || appId == Process.NETWORK_STACK_UID) { || appId == Process.SYSTEM_UID || isNetworkStack) { // Carrier-privileged apps and device owners, and the system (including the // Carrier-privileged apps and device owners, and the system (including the // network stack) can access data usage for all apps on the device. // network stack) can access data usage for all apps on the device. return NetworkStatsAccess.Level.DEVICE; return NetworkStatsAccess.Level.DEVICE; Loading
packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -809,7 +809,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { private @NetworkStatsAccess.Level int checkAccessLevel(String callingPackage) { private @NetworkStatsAccess.Level int checkAccessLevel(String callingPackage) { return NetworkStatsAccess.checkAccessLevel( return NetworkStatsAccess.checkAccessLevel( mContext, Binder.getCallingUid(), callingPackage); mContext, Binder.getCallingPid(), Binder.getCallingUid(), callingPackage); } } /** /** Loading