Snap for 6056566 from fd2fd2a8d0b0af30937a3acd1c6898b388d9d381 to rvc-release

Change-Id: If2936934c5981553a07f622381a9cc75351b380b
This commit is contained in:
android-build-team Robot
2019-12-07 04:07:35 +00:00
7 changed files with 39 additions and 24 deletions

View File

@@ -114,7 +114,7 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
return builder.append("}").toString(); return builder.append("}").toString();
} }
public void writeToProto(ProtoOutputStream proto, long tag) { public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag); final long start = proto.start(tag);
proto.write(NetworkIdentityProto.TYPE, mType); proto.write(NetworkIdentityProto.TYPE, mType);

View File

@@ -684,7 +684,7 @@ public class NetworkStatsHistory implements Parcelable {
} }
} }
public void writeToProto(ProtoOutputStream proto, long tag) { public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag); final long start = proto.start(tag);
proto.write(NetworkStatsHistoryProto.BUCKET_DURATION_MS, bucketDuration); proto.write(NetworkStatsHistoryProto.BUCKET_DURATION_MS, bucketDuration);
@@ -693,11 +693,11 @@ public class NetworkStatsHistory implements Parcelable {
final long startBucket = proto.start(NetworkStatsHistoryProto.BUCKETS); final long startBucket = proto.start(NetworkStatsHistoryProto.BUCKETS);
proto.write(NetworkStatsHistoryBucketProto.BUCKET_START_MS, bucketStart[i]); proto.write(NetworkStatsHistoryBucketProto.BUCKET_START_MS, bucketStart[i]);
writeToProto(proto, NetworkStatsHistoryBucketProto.RX_BYTES, rxBytes, i); dumpDebug(proto, NetworkStatsHistoryBucketProto.RX_BYTES, rxBytes, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.RX_PACKETS, rxPackets, i); dumpDebug(proto, NetworkStatsHistoryBucketProto.RX_PACKETS, rxPackets, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.TX_BYTES, txBytes, i); dumpDebug(proto, NetworkStatsHistoryBucketProto.TX_BYTES, txBytes, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.TX_PACKETS, txPackets, i); dumpDebug(proto, NetworkStatsHistoryBucketProto.TX_PACKETS, txPackets, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.OPERATIONS, operations, i); dumpDebug(proto, NetworkStatsHistoryBucketProto.OPERATIONS, operations, i);
proto.end(startBucket); proto.end(startBucket);
} }
@@ -705,7 +705,7 @@ public class NetworkStatsHistory implements Parcelable {
proto.end(start); proto.end(start);
} }
private static void writeToProto(ProtoOutputStream proto, long tag, long[] array, int index) { private static void dumpDebug(ProtoOutputStream proto, long tag, long[] array, int index) {
if (array != null) { if (array != null) {
proto.write(tag, array[index]); proto.write(tag, array[index]);
} }

View File

@@ -16,6 +16,7 @@
package android.net; package android.net;
import android.annotation.NonNull;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.annotation.TestApi; import android.annotation.TestApi;
@@ -595,8 +596,15 @@ public class TrafficStats {
return total; return total;
} }
/** {@hide} */ /**
public static long getTxPackets(String iface) { * Return the number of packets transmitted on the specified interface since
* device boot. Statistics are measured at the network layer, so both TCP and
* UDP usage are included.
*
* @param iface The name of the interface.
* @return The number of transmitted packets.
*/
public static long getTxPackets(@NonNull String iface) {
try { try {
return getStatsService().getIfaceStats(iface, TYPE_TX_PACKETS); return getStatsService().getIfaceStats(iface, TYPE_TX_PACKETS);
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -604,8 +612,15 @@ public class TrafficStats {
} }
} }
/** {@hide} */ /**
public static long getRxPackets(String iface) { * Return the number of packets received on the specified interface since
* device boot. Statistics are measured at the network layer, so both TCP
* and UDP usage are included.
*
* @param iface The name of the interface.
* @return The number of received packets.
*/
public static long getRxPackets(@NonNull String iface) {
try { try {
return getStatsService().getIfaceStats(iface, TYPE_RX_PACKETS); return getStatsService().getIfaceStats(iface, TYPE_RX_PACKETS);
} catch (RemoteException e) { } catch (RemoteException e) {

View File

@@ -170,11 +170,11 @@ public class NetworkIdentitySet extends HashSet<NetworkIdentity> implements
return ident.compareTo(anotherIdent); return ident.compareTo(anotherIdent);
} }
public void writeToProto(ProtoOutputStream proto, long tag) { public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag); final long start = proto.start(tag);
for (NetworkIdentity ident : this) { for (NetworkIdentity ident : this) {
ident.writeToProto(proto, NetworkIdentitySetProto.IDENTITIES); ident.dumpDebug(proto, NetworkIdentitySetProto.IDENTITIES);
} }
proto.end(start); proto.end(start);

View File

@@ -687,7 +687,7 @@ public class NetworkStatsCollection implements FileRotator.Reader {
} }
} }
public void writeToProto(ProtoOutputStream proto, long tag) { public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag); final long start = proto.start(tag);
for (Key key : getSortedKeys()) { for (Key key : getSortedKeys()) {
@@ -695,7 +695,7 @@ public class NetworkStatsCollection implements FileRotator.Reader {
// Key // Key
final long startKey = proto.start(NetworkStatsCollectionStatsProto.KEY); final long startKey = proto.start(NetworkStatsCollectionStatsProto.KEY);
key.ident.writeToProto(proto, NetworkStatsCollectionKeyProto.IDENTITY); key.ident.dumpDebug(proto, NetworkStatsCollectionKeyProto.IDENTITY);
proto.write(NetworkStatsCollectionKeyProto.UID, key.uid); proto.write(NetworkStatsCollectionKeyProto.UID, key.uid);
proto.write(NetworkStatsCollectionKeyProto.SET, key.set); proto.write(NetworkStatsCollectionKeyProto.SET, key.set);
proto.write(NetworkStatsCollectionKeyProto.TAG, key.tag); proto.write(NetworkStatsCollectionKeyProto.TAG, key.tag);
@@ -703,7 +703,7 @@ public class NetworkStatsCollection implements FileRotator.Reader {
// Value // Value
final NetworkStatsHistory history = mStats.get(key); final NetworkStatsHistory history = mStats.get(key);
history.writeToProto(proto, NetworkStatsCollectionStatsProto.HISTORY); history.dumpDebug(proto, NetworkStatsCollectionStatsProto.HISTORY);
proto.end(startStats); proto.end(startStats);
} }

View File

@@ -470,12 +470,12 @@ public class NetworkStatsRecorder {
} }
} }
public void writeToProtoLocked(ProtoOutputStream proto, long tag) { public void dumpDebugLocked(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag); final long start = proto.start(tag);
if (mPending != null) { if (mPending != null) {
proto.write(NetworkStatsRecorderProto.PENDING_TOTAL_BYTES, mPending.getTotalBytes()); proto.write(NetworkStatsRecorderProto.PENDING_TOTAL_BYTES, mPending.getTotalBytes());
} }
getOrLoadCompleteLocked().writeToProto(proto, NetworkStatsRecorderProto.COMPLETE_HISTORY); getOrLoadCompleteLocked().dumpDebug(proto, NetworkStatsRecorderProto.COMPLETE_HISTORY);
proto.end(start); proto.end(start);
} }

View File

@@ -1609,10 +1609,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_INTERFACES, mActiveIfaces); dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_INTERFACES, mActiveIfaces);
dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_UID_INTERFACES, mActiveUidIfaces); dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_UID_INTERFACES, mActiveUidIfaces);
mDevRecorder.writeToProtoLocked(proto, NetworkStatsServiceDumpProto.DEV_STATS); mDevRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.DEV_STATS);
mXtRecorder.writeToProtoLocked(proto, NetworkStatsServiceDumpProto.XT_STATS); mXtRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.XT_STATS);
mUidRecorder.writeToProtoLocked(proto, NetworkStatsServiceDumpProto.UID_STATS); mUidRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.UID_STATS);
mUidTagRecorder.writeToProtoLocked(proto, NetworkStatsServiceDumpProto.UID_TAG_STATS); mUidTagRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.UID_TAG_STATS);
proto.flush(); proto.flush();
} }
@@ -1623,7 +1623,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
final long start = proto.start(tag); final long start = proto.start(tag);
proto.write(NetworkInterfaceProto.INTERFACE, ifaces.keyAt(i)); proto.write(NetworkInterfaceProto.INTERFACE, ifaces.keyAt(i));
ifaces.valueAt(i).writeToProto(proto, NetworkInterfaceProto.IDENTITIES); ifaces.valueAt(i).dumpDebug(proto, NetworkInterfaceProto.IDENTITIES);
proto.end(start); proto.end(start);
} }