Loading core/java/android/net/TrafficStats.java +16 −44 Original line number Original line Diff line number Diff line Loading @@ -775,18 +775,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidTxBytes(int uid) { public static long getUidTxBytes(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_TX_BYTES); return getStatsService().getUidStats(uid, TYPE_TX_BYTES); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading @@ -808,18 +801,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidRxBytes(int uid) { public static long getUidRxBytes(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_RX_BYTES); return getStatsService().getUidStats(uid, TYPE_RX_BYTES); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading @@ -841,18 +827,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidTxPackets(int uid) { public static long getUidTxPackets(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_TX_PACKETS); return getStatsService().getUidStats(uid, TYPE_TX_PACKETS); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading @@ -874,18 +853,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidRxPackets(int uid) { public static long getUidRxPackets(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_RX_PACKETS); return getStatsService().getUidStats(uid, TYPE_RX_PACKETS); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading services/core/java/com/android/server/net/NetworkStatsService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,7 @@ import static android.net.NetworkTemplate.buildTemplateMobileWildcard; import static android.net.NetworkTemplate.buildTemplateWifiWildcard; import static android.net.NetworkTemplate.buildTemplateWifiWildcard; import static android.net.TrafficStats.KB_IN_BYTES; import static android.net.TrafficStats.KB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES; import static android.net.TrafficStats.UNSUPPORTED; import static android.os.Trace.TRACE_TAG_NETWORK; import static android.os.Trace.TRACE_TAG_NETWORK; import static android.provider.Settings.Global.NETSTATS_AUGMENT_ENABLED; import static android.provider.Settings.Global.NETSTATS_AUGMENT_ENABLED; import static android.provider.Settings.Global.NETSTATS_COMBINE_SUBTYPE_ENABLED; import static android.provider.Settings.Global.NETSTATS_COMBINE_SUBTYPE_ENABLED; Loading Loading @@ -1031,6 +1032,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub { @Override @Override public long getUidStats(int uid, int type) { public long getUidStats(int uid, int type) { final int callingUid = Binder.getCallingUid(); if (callingUid != android.os.Process.SYSTEM_UID && callingUid != uid) { return UNSUPPORTED; } return nativeGetUidStat(uid, type, checkBpfStatsEnable()); return nativeGetUidStat(uid, type, checkBpfStatsEnable()); } } Loading Loading
core/java/android/net/TrafficStats.java +16 −44 Original line number Original line Diff line number Diff line Loading @@ -775,18 +775,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidTxBytes(int uid) { public static long getUidTxBytes(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_TX_BYTES); return getStatsService().getUidStats(uid, TYPE_TX_BYTES); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading @@ -808,18 +801,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidRxBytes(int uid) { public static long getUidRxBytes(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_RX_BYTES); return getStatsService().getUidStats(uid, TYPE_RX_BYTES); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading @@ -841,18 +827,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidTxPackets(int uid) { public static long getUidTxPackets(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_TX_PACKETS); return getStatsService().getUidStats(uid, TYPE_TX_PACKETS); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading @@ -874,18 +853,11 @@ public class TrafficStats { * @see android.content.pm.ApplicationInfo#uid * @see android.content.pm.ApplicationInfo#uid */ */ public static long getUidRxPackets(int uid) { public static long getUidRxPackets(int uid) { // This isn't actually enforcing any security; it just returns the // unsupported value. The real filtering is done at the kernel level. final int callingUid = android.os.Process.myUid(); if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) { try { try { return getStatsService().getUidStats(uid, TYPE_RX_PACKETS); return getStatsService().getUidStats(uid, TYPE_RX_PACKETS); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } else { return UNSUPPORTED; } } } /** /** Loading
services/core/java/com/android/server/net/NetworkStatsService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,7 @@ import static android.net.NetworkTemplate.buildTemplateMobileWildcard; import static android.net.NetworkTemplate.buildTemplateWifiWildcard; import static android.net.NetworkTemplate.buildTemplateWifiWildcard; import static android.net.TrafficStats.KB_IN_BYTES; import static android.net.TrafficStats.KB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES; import static android.net.TrafficStats.UNSUPPORTED; import static android.os.Trace.TRACE_TAG_NETWORK; import static android.os.Trace.TRACE_TAG_NETWORK; import static android.provider.Settings.Global.NETSTATS_AUGMENT_ENABLED; import static android.provider.Settings.Global.NETSTATS_AUGMENT_ENABLED; import static android.provider.Settings.Global.NETSTATS_COMBINE_SUBTYPE_ENABLED; import static android.provider.Settings.Global.NETSTATS_COMBINE_SUBTYPE_ENABLED; Loading Loading @@ -1031,6 +1032,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub { @Override @Override public long getUidStats(int uid, int type) { public long getUidStats(int uid, int type) { final int callingUid = Binder.getCallingUid(); if (callingUid != android.os.Process.SYSTEM_UID && callingUid != uid) { return UNSUPPORTED; } return nativeGetUidStat(uid, type, checkBpfStatsEnable()); return nativeGetUidStat(uid, type, checkBpfStatsEnable()); } } Loading