Loading core/java/android/net/NetworkIdentity.java +19 −0 Original line number Diff line number Diff line Loading @@ -24,8 +24,10 @@ import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.service.NetworkIdentityProto; import android.telephony.TelephonyManager; import android.util.Slog; import android.util.proto.ProtoOutputStream; import java.util.Objects; Loading Loading @@ -110,6 +112,23 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> { return builder.append("}").toString(); } public void writeToProto(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); proto.write(NetworkIdentityProto.TYPE, mType); // Not dumping mSubType, subtypes are no longer supported. if (mSubscriberId != null) { proto.write(NetworkIdentityProto.SUBSCRIBER_ID, scrubSubscriberId(mSubscriberId)); } proto.write(NetworkIdentityProto.NETWORK_ID, mNetworkId); proto.write(NetworkIdentityProto.ROAMING, mRoaming); proto.write(NetworkIdentityProto.METERED, mMetered); proto.end(start); } public int getType() { return mType; } Loading core/java/android/net/NetworkStatsHistory.java +30 −0 Original line number Diff line number Diff line Loading @@ -31,7 +31,10 @@ import static com.android.internal.util.ArrayUtils.total; import android.os.Parcel; import android.os.Parcelable; import android.service.NetworkStatsHistoryBucketProto; import android.service.NetworkStatsHistoryProto; import android.util.MathUtils; import android.util.proto.ProtoOutputStream; import com.android.internal.util.IndentingPrintWriter; Loading Loading @@ -628,6 +631,33 @@ public class NetworkStatsHistory implements Parcelable { } } public void writeToProto(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); proto.write(NetworkStatsHistoryProto.BUCKET_DURATION_MS, bucketDuration); for (int i = 0; i < bucketCount; i++) { final long startBucket = proto.start(NetworkStatsHistoryProto.BUCKETS); proto.write(NetworkStatsHistoryBucketProto.BUCKET_START_MS, bucketStart[i]); writeToProto(proto, NetworkStatsHistoryBucketProto.RX_BYTES, rxBytes, i); writeToProto(proto, NetworkStatsHistoryBucketProto.RX_PACKETS, rxPackets, i); writeToProto(proto, NetworkStatsHistoryBucketProto.TX_BYTES, txBytes, i); writeToProto(proto, NetworkStatsHistoryBucketProto.TX_PACKETS, txPackets, i); writeToProto(proto, NetworkStatsHistoryBucketProto.OPERATIONS, operations, i); proto.end(startBucket); } proto.end(start); } private static void writeToProto(ProtoOutputStream proto, long tag, long[] array, int index) { if (array != null) { proto.write(tag, array[index]); } } @Override public String toString() { final CharArrayWriter writer = new CharArrayWriter(); Loading core/proto/android/os/incident.proto +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ option java_outer_classname = "IncidentProtoMetadata"; import "frameworks/base/libs/incident/proto/android/privacy.proto"; import "frameworks/base/core/proto/android/service/fingerprint.proto"; import "frameworks/base/core/proto/android/service/netstats.proto"; package android.os; Loading Loading @@ -49,4 +50,5 @@ message IncidentProto { // System Services android.service.fingerprint.FingerprintServiceDumpProto fingerprint = 3000; android.service.NetworkStatsServiceDumpProto netstats = 3001; } core/proto/android/service/netstats.proto 0 → 100644 +117 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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. */ syntax = "proto3"; package android.service; option java_multiple_files = true; option java_outer_classname = "NetworkStatsServiceProto"; // Represents dumpsys from NetworkStatsService (netstats). message NetworkStatsServiceDumpProto { repeated NetworkInterfaceProto active_interfaces = 1; repeated NetworkInterfaceProto active_uid_interfaces = 2; NetworkStatsRecorderProto dev_stats = 3; NetworkStatsRecorderProto xt_stats = 4; NetworkStatsRecorderProto uid_stats = 5; NetworkStatsRecorderProto uid_tag_stats = 6; } // Corresponds to NetworkStatsService.mActiveIfaces/mActiveUidIfaces. message NetworkInterfaceProto { string interface = 1; NetworkIdentitySetProto identities = 2; } // Corresponds to NetworkIdentitySet. message NetworkIdentitySetProto { repeated NetworkIdentityProto identities = 1; } // Corresponds to NetworkIdentity. message NetworkIdentityProto { // Constats from ConnectivityManager.TYPE_*. int32 type = 1; string subscriber_id = 2; string network_id = 3; bool roaming = 4; bool metered = 5; } // Corresponds to NetworkStatsRecorder. message NetworkStatsRecorderProto { int64 pending_total_bytes = 1; NetworkStatsCollectionProto complete_history = 2; } // Corresponds to NetworkStatsCollection. message NetworkStatsCollectionProto { repeated NetworkStatsCollectionStatsProto stats = 1; } // Corresponds to NetworkStatsCollection.mStats. message NetworkStatsCollectionStatsProto { NetworkStatsCollectionKeyProto key = 1; NetworkStatsHistoryProto history = 2; } // Corresponds to NetworkStatsCollection.Key. message NetworkStatsCollectionKeyProto { NetworkIdentitySetProto identity = 1; int32 uid = 2; int32 set = 3; int32 tag = 4; } // Corresponds to NetworkStatsHistory. message NetworkStatsHistoryProto { // Duration for this bucket in milliseconds. int64 bucket_duration_ms = 1; repeated NetworkStatsHistoryBucketProto buckets = 2; } // Corresponds to each bucket in NetworkStatsHistory. message NetworkStatsHistoryBucketProto { // Bucket start time in milliseconds since epoch. int64 bucket_start_ms = 1; int64 rx_bytes = 2; int64 rx_packets = 3; int64 tx_bytes = 4; int64 tx_packets = 5; int64 operations = 6; } services/core/java/com/android/server/net/NetworkIdentitySet.java +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.server.net; import android.net.NetworkIdentity; import android.service.NetworkIdentitySetProto; import android.util.proto.ProtoOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; Loading Loading @@ -143,4 +145,14 @@ public class NetworkIdentitySet extends HashSet<NetworkIdentity> implements final NetworkIdentity anotherIdent = another.iterator().next(); return ident.compareTo(anotherIdent); } public void writeToProto(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); for (NetworkIdentity ident : this) { ident.writeToProto(proto, NetworkIdentitySetProto.IDENTITIES); } proto.end(start); } } Loading
core/java/android/net/NetworkIdentity.java +19 −0 Original line number Diff line number Diff line Loading @@ -24,8 +24,10 @@ import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.service.NetworkIdentityProto; import android.telephony.TelephonyManager; import android.util.Slog; import android.util.proto.ProtoOutputStream; import java.util.Objects; Loading Loading @@ -110,6 +112,23 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> { return builder.append("}").toString(); } public void writeToProto(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); proto.write(NetworkIdentityProto.TYPE, mType); // Not dumping mSubType, subtypes are no longer supported. if (mSubscriberId != null) { proto.write(NetworkIdentityProto.SUBSCRIBER_ID, scrubSubscriberId(mSubscriberId)); } proto.write(NetworkIdentityProto.NETWORK_ID, mNetworkId); proto.write(NetworkIdentityProto.ROAMING, mRoaming); proto.write(NetworkIdentityProto.METERED, mMetered); proto.end(start); } public int getType() { return mType; } Loading
core/java/android/net/NetworkStatsHistory.java +30 −0 Original line number Diff line number Diff line Loading @@ -31,7 +31,10 @@ import static com.android.internal.util.ArrayUtils.total; import android.os.Parcel; import android.os.Parcelable; import android.service.NetworkStatsHistoryBucketProto; import android.service.NetworkStatsHistoryProto; import android.util.MathUtils; import android.util.proto.ProtoOutputStream; import com.android.internal.util.IndentingPrintWriter; Loading Loading @@ -628,6 +631,33 @@ public class NetworkStatsHistory implements Parcelable { } } public void writeToProto(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); proto.write(NetworkStatsHistoryProto.BUCKET_DURATION_MS, bucketDuration); for (int i = 0; i < bucketCount; i++) { final long startBucket = proto.start(NetworkStatsHistoryProto.BUCKETS); proto.write(NetworkStatsHistoryBucketProto.BUCKET_START_MS, bucketStart[i]); writeToProto(proto, NetworkStatsHistoryBucketProto.RX_BYTES, rxBytes, i); writeToProto(proto, NetworkStatsHistoryBucketProto.RX_PACKETS, rxPackets, i); writeToProto(proto, NetworkStatsHistoryBucketProto.TX_BYTES, txBytes, i); writeToProto(proto, NetworkStatsHistoryBucketProto.TX_PACKETS, txPackets, i); writeToProto(proto, NetworkStatsHistoryBucketProto.OPERATIONS, operations, i); proto.end(startBucket); } proto.end(start); } private static void writeToProto(ProtoOutputStream proto, long tag, long[] array, int index) { if (array != null) { proto.write(tag, array[index]); } } @Override public String toString() { final CharArrayWriter writer = new CharArrayWriter(); Loading
core/proto/android/os/incident.proto +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ option java_outer_classname = "IncidentProtoMetadata"; import "frameworks/base/libs/incident/proto/android/privacy.proto"; import "frameworks/base/core/proto/android/service/fingerprint.proto"; import "frameworks/base/core/proto/android/service/netstats.proto"; package android.os; Loading Loading @@ -49,4 +50,5 @@ message IncidentProto { // System Services android.service.fingerprint.FingerprintServiceDumpProto fingerprint = 3000; android.service.NetworkStatsServiceDumpProto netstats = 3001; }
core/proto/android/service/netstats.proto 0 → 100644 +117 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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. */ syntax = "proto3"; package android.service; option java_multiple_files = true; option java_outer_classname = "NetworkStatsServiceProto"; // Represents dumpsys from NetworkStatsService (netstats). message NetworkStatsServiceDumpProto { repeated NetworkInterfaceProto active_interfaces = 1; repeated NetworkInterfaceProto active_uid_interfaces = 2; NetworkStatsRecorderProto dev_stats = 3; NetworkStatsRecorderProto xt_stats = 4; NetworkStatsRecorderProto uid_stats = 5; NetworkStatsRecorderProto uid_tag_stats = 6; } // Corresponds to NetworkStatsService.mActiveIfaces/mActiveUidIfaces. message NetworkInterfaceProto { string interface = 1; NetworkIdentitySetProto identities = 2; } // Corresponds to NetworkIdentitySet. message NetworkIdentitySetProto { repeated NetworkIdentityProto identities = 1; } // Corresponds to NetworkIdentity. message NetworkIdentityProto { // Constats from ConnectivityManager.TYPE_*. int32 type = 1; string subscriber_id = 2; string network_id = 3; bool roaming = 4; bool metered = 5; } // Corresponds to NetworkStatsRecorder. message NetworkStatsRecorderProto { int64 pending_total_bytes = 1; NetworkStatsCollectionProto complete_history = 2; } // Corresponds to NetworkStatsCollection. message NetworkStatsCollectionProto { repeated NetworkStatsCollectionStatsProto stats = 1; } // Corresponds to NetworkStatsCollection.mStats. message NetworkStatsCollectionStatsProto { NetworkStatsCollectionKeyProto key = 1; NetworkStatsHistoryProto history = 2; } // Corresponds to NetworkStatsCollection.Key. message NetworkStatsCollectionKeyProto { NetworkIdentitySetProto identity = 1; int32 uid = 2; int32 set = 3; int32 tag = 4; } // Corresponds to NetworkStatsHistory. message NetworkStatsHistoryProto { // Duration for this bucket in milliseconds. int64 bucket_duration_ms = 1; repeated NetworkStatsHistoryBucketProto buckets = 2; } // Corresponds to each bucket in NetworkStatsHistory. message NetworkStatsHistoryBucketProto { // Bucket start time in milliseconds since epoch. int64 bucket_start_ms = 1; int64 rx_bytes = 2; int64 rx_packets = 3; int64 tx_bytes = 4; int64 tx_packets = 5; int64 operations = 6; }
services/core/java/com/android/server/net/NetworkIdentitySet.java +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.server.net; import android.net.NetworkIdentity; import android.service.NetworkIdentitySetProto; import android.util.proto.ProtoOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; Loading Loading @@ -143,4 +145,14 @@ public class NetworkIdentitySet extends HashSet<NetworkIdentity> implements final NetworkIdentity anotherIdent = another.iterator().next(); return ident.compareTo(anotherIdent); } public void writeToProto(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); for (NetworkIdentity ident : this) { ident.writeToProto(proto, NetworkIdentitySetProto.IDENTITIES); } proto.end(start); } }