public class NetworkStatsHistory extends Object implements Parcelable
long
series for more
efficient persistence.
Each bucket is defined by a bucketStart
timestamp, and lasts for
bucketDuration
. Internally assumes that bucketStart
is
sorted at all times.
Modifier and Type | Class and Description |
---|---|
static class |
NetworkStatsHistory.DataStreamUtils
Utility methods for interacting with
DataInputStream and
DataOutputStream , mostly dealing with writing partial arrays. |
static class |
NetworkStatsHistory.Entry |
static class |
NetworkStatsHistory.ParcelUtils
Utility methods for interacting with
Parcel structures, mostly
dealing with writing partial arrays. |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<NetworkStatsHistory> |
CREATOR |
static int |
FIELD_ACTIVE_TIME |
static int |
FIELD_ALL |
static int |
FIELD_OPERATIONS |
static int |
FIELD_RX_BYTES |
static int |
FIELD_RX_PACKETS |
static int |
FIELD_TX_BYTES |
static int |
FIELD_TX_PACKETS |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
NetworkStatsHistory(DataInputStream in) |
NetworkStatsHistory(long bucketDuration) |
NetworkStatsHistory(long bucketDuration,
int initialSize) |
NetworkStatsHistory(long bucketDuration,
int initialSize,
int fields) |
NetworkStatsHistory(NetworkStatsHistory existing,
long bucketDuration) |
NetworkStatsHistory(Parcel in) |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
|
void |
dump(com.android.internal.util.IndentingPrintWriter pw,
boolean fullHistory) |
int |
estimateResizeBuckets(long newBucketDuration) |
void |
generateRandom(long start,
long end,
long bytes)
Deprecated.
only for temporary testing
|
void |
generateRandom(long start,
long end,
long rxBytes,
long rxPackets,
long txBytes,
long txPackets,
long operations,
Random r)
Deprecated.
only for temporary testing
|
long |
getBucketDuration() |
long |
getEnd() |
int |
getIndexAfter(long time)
Return index of bucket that contains or is immediately after the
requested time.
|
int |
getIndexBefore(long time)
Return index of bucket that contains or is immediately before the
requested time.
|
long |
getStart() |
long |
getTotalBytes()
Return total bytes represented by this history.
|
NetworkStatsHistory.Entry |
getValues(int i,
NetworkStatsHistory.Entry recycle)
Return specific stats entry.
|
NetworkStatsHistory.Entry |
getValues(long start,
long end,
long now,
NetworkStatsHistory.Entry recycle)
Return interpolated data usage across the requested range.
|
NetworkStatsHistory.Entry |
getValues(long start,
long end,
NetworkStatsHistory.Entry recycle)
Return interpolated data usage across the requested range.
|
static long |
randomLong(Random r,
long start,
long end) |
void |
recordData(long start,
long end,
long rxBytes,
long txBytes)
Deprecated.
|
void |
recordData(long start,
long end,
NetworkStats.Entry entry)
Record that data traffic occurred in the given time range.
|
void |
recordEntireHistory(NetworkStatsHistory input)
Record an entire
NetworkStatsHistory into this history. |
void |
recordHistory(NetworkStatsHistory input,
long start,
long end)
Record given
NetworkStatsHistory into this history, copying only
buckets that atomically occur in the inclusive time range. |
void |
removeBucketsBefore(long cutoff)
Deprecated.
|
int |
size() |
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
void |
writeToParcel(Parcel out,
int flags)
Flatten this object in to a Parcel.
|
void |
writeToStream(DataOutputStream out) |
public static final int FIELD_ACTIVE_TIME
public static final int FIELD_RX_BYTES
public static final int FIELD_RX_PACKETS
public static final int FIELD_TX_BYTES
public static final int FIELD_TX_PACKETS
public static final int FIELD_OPERATIONS
public static final int FIELD_ALL
public static final Parcelable.Creator<NetworkStatsHistory> CREATOR
public NetworkStatsHistory(long bucketDuration)
public NetworkStatsHistory(long bucketDuration, int initialSize)
public NetworkStatsHistory(long bucketDuration, int initialSize, int fields)
public NetworkStatsHistory(NetworkStatsHistory existing, long bucketDuration)
public NetworkStatsHistory(Parcel in)
public NetworkStatsHistory(DataInputStream in) throws IOException
IOException
public void writeToParcel(Parcel out, int flags)
Parcelable
writeToParcel
in interface Parcelable
out
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public void writeToStream(DataOutputStream out) throws IOException
IOException
public int describeContents()
Parcelable
describeContents
in interface Parcelable
public int size()
public long getBucketDuration()
public long getStart()
public long getEnd()
public long getTotalBytes()
public int getIndexBefore(long time)
public int getIndexAfter(long time)
public NetworkStatsHistory.Entry getValues(int i, NetworkStatsHistory.Entry recycle)
@Deprecated public void recordData(long start, long end, long rxBytes, long txBytes)
public void recordData(long start, long end, NetworkStats.Entry entry)
public void recordEntireHistory(NetworkStatsHistory input)
NetworkStatsHistory
into this history. Usually
for combining together stats for external reporting.public void recordHistory(NetworkStatsHistory input, long start, long end)
NetworkStatsHistory
into this history, copying only
buckets that atomically occur in the inclusive time range. Doesn't
interpolate across partial buckets.@Deprecated public void removeBucketsBefore(long cutoff)
public NetworkStatsHistory.Entry getValues(long start, long end, NetworkStatsHistory.Entry recycle)
public NetworkStatsHistory.Entry getValues(long start, long end, long now, NetworkStatsHistory.Entry recycle)
@Deprecated public void generateRandom(long start, long end, long bytes)
@Deprecated public void generateRandom(long start, long end, long rxBytes, long rxPackets, long txBytes, long txPackets, long operations, Random r)
public static long randomLong(Random r, long start, long end)
public void dump(com.android.internal.util.IndentingPrintWriter pw, boolean fullHistory)
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
public int estimateResizeBuckets(long newBucketDuration)