am 16ef5779: Merge "API to adjust network stats. DO NOT MERGE." into jb-mr1-dev
* commit '16ef57791766b92b8e34de4f752db2f522f34c82': API to adjust network stats. DO NOT MERGE.
This commit is contained in:
@@ -45,4 +45,7 @@ interface INetworkStatsService {
|
|||||||
/** Advise persistance threshold; may be overridden internally. */
|
/** Advise persistance threshold; may be overridden internally. */
|
||||||
void advisePersistThreshold(long thresholdBytes);
|
void advisePersistThreshold(long thresholdBytes);
|
||||||
|
|
||||||
|
/** Adjust recorded network stats. */
|
||||||
|
void adjustNetworkStats(int uid, int tag, long rxBytes, long rxPackets, long txBytes, long txPackets, long operationCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,13 @@ public class TrafficStats {
|
|||||||
*/
|
*/
|
||||||
public static final int TAG_SYSTEM_BACKUP = 0xFFFFFF03;
|
public static final int TAG_SYSTEM_BACKUP = 0xFFFFFF03;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default tag value for cloud messaging traffic.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int TAG_SYSTEM_CLOUD_MESSAGING = 0xFFFFFF04;
|
||||||
|
|
||||||
private static INetworkStatsService sStatsService;
|
private static INetworkStatsService sStatsService;
|
||||||
|
|
||||||
private synchronized static INetworkStatsService getStatsService() {
|
private synchronized static INetworkStatsService getStatsService() {
|
||||||
@@ -246,6 +253,27 @@ public class TrafficStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjust network statistics for the given UID and tag by the requested
|
||||||
|
* amount. This can be used to correctly account network usage performed on
|
||||||
|
* behalf of another application. Values can be negative.
|
||||||
|
* <p>
|
||||||
|
* Requires that caller holds
|
||||||
|
* {@link android.Manifest.permission#MODIFY_NETWORK_ACCOUNTING} permission.
|
||||||
|
*
|
||||||
|
* @see #setThreadStatsUid(int)
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void adjustNetworkStats(int uid, int tag, long rxBytes, long rxPackets,
|
||||||
|
long txBytes, long txPackets, long operationCount) {
|
||||||
|
try {
|
||||||
|
getStatsService().adjustNetworkStats(
|
||||||
|
uid, tag, rxBytes, rxPackets, txBytes, txPackets, operationCount);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public static void closeQuietly(INetworkStatsSession session) {
|
public static void closeQuietly(INetworkStatsSession session) {
|
||||||
// TODO: move to NetworkStatsService once it exists
|
// TODO: move to NetworkStatsService once it exists
|
||||||
|
|||||||
@@ -695,6 +695,14 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
mGlobalAlertBytes = mSettings.getGlobalAlertBytes(mPersistThreshold);
|
mGlobalAlertBytes = mSettings.getGlobalAlertBytes(mPersistThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustNetworkStats(int uid, int tag, long rxBytes, long rxPackets, long txBytes,
|
||||||
|
long txPackets, long operationCount) {
|
||||||
|
mContext.enforceCallingOrSelfPermission(MODIFY_NETWORK_ACCOUNTING, TAG);
|
||||||
|
|
||||||
|
// TODO: store adjusted network stats in separate data structure
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receiver that watches for {@link IConnectivityManager} to claim network
|
* Receiver that watches for {@link IConnectivityManager} to claim network
|
||||||
* interfaces. Used to associate {@link TelephonyManager#getSubscriberId()}
|
* interfaces. Used to associate {@link TelephonyManager#getSubscriberId()}
|
||||||
|
|||||||
Reference in New Issue
Block a user