Merge "Cleaning up NetworkStatsManager." into nyc-dev am: c45f0aea71
am: f49cbec84c
* commit 'f49cbec84c1e2aa21b33d54ae97c54ed9c71bb32':
Cleaning up NetworkStatsManager.
Change-Id: I0fd280e158eb3cfeb0b4f6066cc890439cffa02c
This commit is contained in:
@@ -6457,7 +6457,7 @@ package android.app.usage {
|
|||||||
public class NetworkStatsManager {
|
public class NetworkStatsManager {
|
||||||
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int);
|
method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int) throws java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
|
|||||||
@@ -31,37 +31,6 @@ package android.app.admin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.app.usage {
|
|
||||||
|
|
||||||
public class DataUsagePolicy {
|
|
||||||
field public final int networkType;
|
|
||||||
field public final java.lang.String[] subscriberIds;
|
|
||||||
field public final long thresholdInBytes;
|
|
||||||
field public final int[] uids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DataUsagePolicy.Builder {
|
|
||||||
ctor public DataUsagePolicy.Builder();
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder addUid(int);
|
|
||||||
method public android.app.usage.DataUsagePolicy build();
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NetworkStatsManager {
|
|
||||||
method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
|
|
||||||
method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
|
|
||||||
method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static abstract class NetworkStatsManager.DataUsageCallback {
|
|
||||||
ctor public NetworkStatsManager.DataUsageCallback();
|
|
||||||
method public deprecated void onLimitReached();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
package android.content {
|
package android.content {
|
||||||
|
|
||||||
public abstract class Context {
|
public abstract class Context {
|
||||||
|
|||||||
@@ -6738,7 +6738,7 @@ package android.app.usage {
|
|||||||
public class NetworkStatsManager {
|
public class NetworkStatsManager {
|
||||||
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int);
|
method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int) throws java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
|
|||||||
@@ -29,37 +29,6 @@ package android.app.admin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.app.usage {
|
|
||||||
|
|
||||||
public class DataUsagePolicy {
|
|
||||||
field public final int networkType;
|
|
||||||
field public final java.lang.String[] subscriberIds;
|
|
||||||
field public final long thresholdInBytes;
|
|
||||||
field public final int[] uids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DataUsagePolicy.Builder {
|
|
||||||
ctor public DataUsagePolicy.Builder();
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder addUid(int);
|
|
||||||
method public android.app.usage.DataUsagePolicy build();
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NetworkStatsManager {
|
|
||||||
method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
|
|
||||||
method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
|
|
||||||
method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static abstract class NetworkStatsManager.DataUsageCallback {
|
|
||||||
ctor public NetworkStatsManager.DataUsageCallback();
|
|
||||||
method public deprecated void onLimitReached();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
package android.content {
|
package android.content {
|
||||||
|
|
||||||
public abstract class Context {
|
public abstract class Context {
|
||||||
|
|||||||
@@ -6463,7 +6463,7 @@ package android.app.usage {
|
|||||||
public class NetworkStatsManager {
|
public class NetworkStatsManager {
|
||||||
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats queryDetails(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats queryDetailsForUid(int, java.lang.String, long, long, int) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int);
|
method public android.app.usage.NetworkStats queryDetailsForUidTag(int, java.lang.String, long, long, int, int) throws java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats querySummary(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
method public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, java.lang.String, long, long) throws android.os.RemoteException, java.lang.SecurityException;
|
||||||
|
|||||||
@@ -31,37 +31,6 @@ package android.app.admin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.app.usage {
|
|
||||||
|
|
||||||
public class DataUsagePolicy {
|
|
||||||
field public final int networkType;
|
|
||||||
field public final java.lang.String[] subscriberIds;
|
|
||||||
field public final long thresholdInBytes;
|
|
||||||
field public final int[] uids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DataUsagePolicy.Builder {
|
|
||||||
ctor public DataUsagePolicy.Builder();
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder addSubscriberId(java.lang.String);
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder addUid(int);
|
|
||||||
method public android.app.usage.DataUsagePolicy build();
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder setNetworkType(int);
|
|
||||||
method public android.app.usage.DataUsagePolicy.Builder setThreshold(long);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NetworkStatsManager {
|
|
||||||
method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.DataUsageCallback, android.os.Handler);
|
|
||||||
method public void registerDataUsageCallback(android.app.usage.DataUsagePolicy, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler);
|
|
||||||
method public void unregisterDataUsageCallback(android.app.usage.NetworkStatsManager.DataUsageCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static abstract class NetworkStatsManager.DataUsageCallback {
|
|
||||||
ctor public NetworkStatsManager.DataUsageCallback();
|
|
||||||
method public deprecated void onLimitReached();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
package android.content {
|
package android.content {
|
||||||
|
|
||||||
public abstract class Context {
|
public abstract class Context {
|
||||||
|
|||||||
@@ -1,175 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2016 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
|
||||||
* of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.app.usage;
|
|
||||||
|
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.util.IntArray;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a policy for data usage callbacks, made through {@link DataUsagePolicy.Builder} and used
|
|
||||||
* to be notified on data usage via {@link NetworkStatsManager#registerDataUsageCallback}.
|
|
||||||
* @removed
|
|
||||||
*/
|
|
||||||
public class DataUsagePolicy {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Network type to be monitored, as defined in {@link ConnectivityManager}, e.g.
|
|
||||||
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI} etc.
|
|
||||||
*/
|
|
||||||
public final int networkType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set of subscriber ids to be monitored for the given network type. May be empty if not
|
|
||||||
* applicable.
|
|
||||||
* <p>Should not be modified once created.
|
|
||||||
*/
|
|
||||||
public final String[] subscriberIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set of UIDs of which to monitor data usage.
|
|
||||||
*
|
|
||||||
* <p>If not {@code null}, the caller will be notified when any of the uids exceed
|
|
||||||
* the given threshold. If empty all uids for which the calling process has access
|
|
||||||
* to stats will be monitored.
|
|
||||||
* <p>Should not be modified once created.
|
|
||||||
*/
|
|
||||||
public final int[] uids;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Threshold in bytes to be notified on.
|
|
||||||
*/
|
|
||||||
public final long thresholdInBytes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
DataUsagePolicy(int networkType, String[] subscriberIds, int[] uids,
|
|
||||||
long thresholdInBytes) {
|
|
||||||
this.networkType = networkType;
|
|
||||||
this.subscriberIds = subscriberIds;
|
|
||||||
this.uids = uids;
|
|
||||||
this.thresholdInBytes = thresholdInBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builder used to create {@link DataUsagePolicy} objects.
|
|
||||||
*/
|
|
||||||
public static class Builder {
|
|
||||||
private static final int INVALID_NETWORK_TYPE = -1;
|
|
||||||
private int mNetworkType = INVALID_NETWORK_TYPE;
|
|
||||||
private List<String> mSubscriberList = new ArrayList<>();
|
|
||||||
private IntArray mUids = new IntArray();
|
|
||||||
private long mThresholdInBytes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor for Builder.
|
|
||||||
*/
|
|
||||||
public Builder() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build {@link DataUsagePolicy} given the current policies.
|
|
||||||
*/
|
|
||||||
public DataUsagePolicy build() {
|
|
||||||
if (mNetworkType == INVALID_NETWORK_TYPE) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"DataUsagePolicy requires a valid network type to be set");
|
|
||||||
}
|
|
||||||
return new DataUsagePolicy(mNetworkType,
|
|
||||||
mSubscriberList.toArray(new String[mSubscriberList.size()]),
|
|
||||||
mUids.toArray(), mThresholdInBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies that the given {@code subscriberId} should be monitored.
|
|
||||||
*
|
|
||||||
* @param subscriberId the subscriber id of the network interface.
|
|
||||||
*/
|
|
||||||
public Builder addSubscriberId(String subscriberId) {
|
|
||||||
mSubscriberList.add(subscriberId);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies that the given {@code uid} should be monitored.
|
|
||||||
*/
|
|
||||||
public Builder addUid(int uid) {
|
|
||||||
mUids.add(uid);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies that the callback should monitor the given network. It is mandatory
|
|
||||||
* to set one.
|
|
||||||
*
|
|
||||||
* @param networkType As defined in {@link ConnectivityManager}, e.g.
|
|
||||||
* {@link ConnectivityManager#TYPE_MOBILE},
|
|
||||||
* {@link ConnectivityManager#TYPE_WIFI}, etc.
|
|
||||||
*/
|
|
||||||
public Builder setNetworkType(int networkType) {
|
|
||||||
mNetworkType = networkType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the threshold in bytes on which the listener should be called. The framework may
|
|
||||||
* impose a minimum threshold to avoid too many notifications to be triggered.
|
|
||||||
*/
|
|
||||||
public Builder setThreshold(long thresholdInBytes) {
|
|
||||||
mThresholdInBytes = thresholdInBytes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "DataUsagePolicy [ networkType=" + networkType
|
|
||||||
+ ", subscriberIds=" + Arrays.toString(subscriberIds)
|
|
||||||
+ ", uids=" + Arrays.toString(uids)
|
|
||||||
+ ", thresholdInBytes=" + thresholdInBytes + " ]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof DataUsagePolicy == false) return false;
|
|
||||||
DataUsagePolicy that = (DataUsagePolicy) obj;
|
|
||||||
return that.networkType == this.networkType
|
|
||||||
&& Arrays.deepEquals(that.subscriberIds, this.subscriberIds)
|
|
||||||
&& Arrays.equals(that.uids, this.uids)
|
|
||||||
&& that.thresholdInBytes == this.thresholdInBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
// Start with a non-zero constant.
|
|
||||||
int result = 17;
|
|
||||||
|
|
||||||
// Include a hash for each field.
|
|
||||||
result = 31 * result + networkType;
|
|
||||||
result = 31 * result + Arrays.deepHashCode(subscriberIds);
|
|
||||||
result = 31 * result + Arrays.hashCode(uids);
|
|
||||||
result = 31 * result + (int) (thresholdInBytes ^ (thresholdInBytes >>> 32));
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user