@@ -88,6 +88,13 @@ public class TrafficStats {
8888 */
8989 public static final int TAG_SYSTEM_BACKUP = 0xFFFFFF03 ;
9090
91+ /**
92+ * Default tag value for cloud messaging traffic.
93+ *
94+ * @hide
95+ */
96+ public static final int TAG_SYSTEM_CLOUD_MESSAGING = 0xFFFFFF04 ;
97+
9198 private static INetworkStatsService sStatsService ;
9299
93100 private synchronized static INetworkStatsService getStatsService () {
@@ -246,6 +253,27 @@ public static void incrementOperationCount(int tag, int operationCount) {
246253 }
247254 }
248255
256+ /**
257+ * Adjust network statistics for the given UID and tag by the requested
258+ * amount. This can be used to correctly account network usage performed on
259+ * behalf of another application. Values can be negative.
260+ * <p>
261+ * Requires that caller holds
262+ * {@link android.Manifest.permission#MODIFY_NETWORK_ACCOUNTING} permission.
263+ *
264+ * @see #setThreadStatsUid(int)
265+ * @hide
266+ */
267+ public static void adjustNetworkStats (int uid , int tag , long rxBytes , long rxPackets ,
268+ long txBytes , long txPackets , long operationCount ) {
269+ try {
270+ getStatsService ().adjustNetworkStats (
271+ uid , tag , rxBytes , rxPackets , txBytes , txPackets , operationCount );
272+ } catch (RemoteException e ) {
273+ throw new RuntimeException (e );
274+ }
275+ }
276+
249277 /** {@hide} */
250278 public static void closeQuietly (INetworkStatsSession session ) {
251279 // TODO: move to NetworkStatsService once it exists
0 commit comments