Merge "Cleaning up NetworkStatsManager." into nyc-dev am: c45f0aea71 am: f49cbec84c

am: cc1524eded

* commit 'cc1524edede07e2139cd072d6256fa96952f4004':
  Cleaning up NetworkStatsManager.

Change-Id: I3f669191e7c7739870dc098d5d6357d1d3ceb6dd
This commit is contained in:
Antonio Cansado
2016-05-25 22:43:26 +00:00
committed by android-build-merger
2 changed files with 4 additions and 37 deletions

View File

@@ -240,18 +240,13 @@ public class NetworkStatsManager {
* {@link java.lang.System#currentTimeMillis}. * {@link java.lang.System#currentTimeMillis}.
* @param uid UID of app * @param uid UID of app
* @param tag TAG of interest. Use {@link NetworkStats.Bucket#TAG_NONE} for no tags. * @param tag TAG of interest. Use {@link NetworkStats.Bucket#TAG_NONE} for no tags.
* @return Statistics object or null if permissions are insufficient or error happened during * @return Statistics object or null if an error happened during statistics collection.
* statistics collection. * @throws SecurityException if permissions are insufficient to read network statistics.
*/ */
public NetworkStats queryDetailsForUidTag(int networkType, String subscriberId, public NetworkStats queryDetailsForUidTag(int networkType, String subscriberId,
long startTime, long endTime, int uid, int tag) { long startTime, long endTime, int uid, int tag) throws SecurityException {
NetworkTemplate template; NetworkTemplate template;
try { template = createTemplate(networkType, subscriberId);
template = createTemplate(networkType, subscriberId);
} catch (IllegalArgumentException e) {
if (DBG) Log.e(TAG, "Cannot create template", e);
return null;
}
NetworkStats result; NetworkStats result;
try { try {
@@ -303,17 +298,6 @@ public class NetworkStatsManager {
return result; return result;
} }
/** @removed */
public void registerDataUsageCallback(DataUsagePolicy policy, DataUsageCallback callback,
@Nullable Handler handler) {}
/** @removed */
public void registerDataUsageCallback(DataUsagePolicy policy, UsageCallback callback,
@Nullable Handler handler) {}
/** @removed */
public void unregisterDataUsageCallback(DataUsageCallback callback) {}
/** /**
* Registers to receive notifications about data usage on specified networks. * Registers to receive notifications about data usage on specified networks.
* *
@@ -396,13 +380,6 @@ public class NetworkStatsManager {
} }
} }
/** @removed */
public static abstract class DataUsageCallback {
/** @removed */
@Deprecated
public void onLimitReached() {}
}
/** /**
* Base class for usage callbacks. Should be extended by applications wanting notifications. * Base class for usage callbacks. Should be extended by applications wanting notifications.
*/ */

View File

@@ -190,11 +190,9 @@ class NetworkStatsObservers {
private void handleUpdateStats(StatsContext statsContext) { private void handleUpdateStats(StatsContext statsContext) {
if (mDataUsageRequests.size() == 0) { if (mDataUsageRequests.size() == 0) {
if (LOGV) Slog.v(TAG, "No registered listeners of data usage");
return; return;
} }
if (LOGV) Slog.v(TAG, "Checking if any registered observer needs to be notified");
for (int i = 0; i < mDataUsageRequests.size(); i++) { for (int i = 0; i < mDataUsageRequests.size(); i++) {
RequestInfo requestInfo = mDataUsageRequests.valueAt(i); RequestInfo requestInfo = mDataUsageRequests.valueAt(i);
requestInfo.updateStats(statsContext); requestInfo.updateStats(statsContext);
@@ -371,9 +369,6 @@ class NetworkStatsObservers {
NetworkStats stats = mCollection.getSummary(template, NetworkStats stats = mCollection.getSummary(template,
Long.MIN_VALUE /* start */, Long.MAX_VALUE /* end */, Long.MIN_VALUE /* start */, Long.MAX_VALUE /* end */,
mAccessLevel, mCallingUid); mAccessLevel, mCallingUid);
if (LOGV) {
Slog.v(TAG, "Netstats for " + template + ": " + stats);
}
return stats.getTotalBytes(); return stats.getTotalBytes();
} }
} }
@@ -391,11 +386,6 @@ class NetworkStatsObservers {
for (int i = 0; i < uidsToMonitor.length; i++) { for (int i = 0; i < uidsToMonitor.length; i++) {
long bytesSoFar = getTotalBytesForNetworkUid(mRequest.template, uidsToMonitor[i]); long bytesSoFar = getTotalBytesForNetworkUid(mRequest.template, uidsToMonitor[i]);
if (LOGV) {
Slog.v(TAG, bytesSoFar + " bytes so far since notification for "
+ mRequest.template + " for uid=" + uidsToMonitor[i]);
}
if (bytesSoFar > mRequest.thresholdInBytes) { if (bytesSoFar > mRequest.thresholdInBytes) {
return true; return true;
} }