Merge "Dump connmetrics in protobuf format"
This commit is contained in:
@@ -623,6 +623,7 @@ gensrcs {
|
||||
"&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
|
||||
|
||||
srcs: [
|
||||
":ipconnectivity-proto-src",
|
||||
"core/proto/**/*.proto",
|
||||
"libs/incident/**/*.proto",
|
||||
],
|
||||
@@ -737,6 +738,7 @@ java_library {
|
||||
java_library_host {
|
||||
name: "platformprotos",
|
||||
srcs: [
|
||||
":ipconnectivity-proto-src",
|
||||
"cmds/am/proto/instrumentation_data.proto",
|
||||
"cmds/statsd/src/**/*.proto",
|
||||
"core/proto/**/*.proto",
|
||||
@@ -765,6 +767,7 @@ java_library {
|
||||
],
|
||||
sdk_version: "9",
|
||||
srcs: [
|
||||
":ipconnectivity-proto-src",
|
||||
"core/proto/**/*.proto",
|
||||
"libs/incident/proto/android/os/**/*.proto",
|
||||
],
|
||||
@@ -779,6 +782,7 @@ java_library {
|
||||
},
|
||||
|
||||
srcs: [
|
||||
":ipconnectivity-proto-src",
|
||||
"core/proto/**/*.proto",
|
||||
"libs/incident/proto/android/os/**/*.proto",
|
||||
],
|
||||
@@ -809,6 +813,7 @@ cc_defaults {
|
||||
],
|
||||
|
||||
srcs: [
|
||||
":ipconnectivity-proto-src",
|
||||
"core/proto/**/*.proto",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ import "frameworks/base/core/proto/android/util/event_log_tags.proto";
|
||||
import "frameworks/base/core/proto/android/util/log.proto";
|
||||
import "frameworks/base/core/proto/android/privacy.proto";
|
||||
import "frameworks/base/core/proto/android/section.proto";
|
||||
import "frameworks/base/proto/src/ipconnectivity.proto";
|
||||
|
||||
package android.os;
|
||||
|
||||
@@ -480,6 +481,11 @@ message IncidentProto {
|
||||
(section).args = "cpuinfo --proto"
|
||||
];
|
||||
|
||||
optional .clearcut.connectivity.IpConnectivityLog ip_connectivity_metrics = 3049 [
|
||||
(section).type = SECTION_DUMPSYS,
|
||||
(section).args = "connmetrics --proto"
|
||||
];
|
||||
|
||||
// Reserved for OEMs.
|
||||
extensions 50000 to 100000;
|
||||
}
|
||||
|
||||
@@ -32,3 +32,8 @@ filegroup {
|
||||
name: "system-messages-proto-src",
|
||||
srcs: ["src/system_messages.proto"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "ipconnectivity-proto-src",
|
||||
srcs: ["src/ipconnectivity.proto"],
|
||||
}
|
||||
|
||||
@@ -81,9 +81,12 @@ public class DefaultNetworkMetrics {
|
||||
printEvent(localTimeMs, pw, mCurrentDefaultNetwork);
|
||||
}
|
||||
|
||||
public synchronized void listEventsAsProto(PrintWriter pw) {
|
||||
/**
|
||||
* Convert events in the ring buffer to protos and add to the given list
|
||||
*/
|
||||
public synchronized void listEventsAsProto(List<IpConnectivityEvent> out) {
|
||||
for (DefaultNetworkEvent ev : mEventsLog.toArray()) {
|
||||
pw.print(IpConnectivityEventBuilder.toProto(ev));
|
||||
out.add(IpConnectivityEventBuilder.toProto(ev));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@ import com.android.server.SystemService;
|
||||
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityEvent;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -239,18 +241,37 @@ final public class IpConnectivityMetrics extends SystemService {
|
||||
mDefaultNetworkMetrics.listEvents(pw);
|
||||
}
|
||||
|
||||
private List<IpConnectivityEvent> listEventsAsProtos() {
|
||||
final List<IpConnectivityEvent> events = IpConnectivityEventBuilder.toProto(getEvents());
|
||||
if (mNetdListener != null) {
|
||||
mNetdListener.listAsProtos(events);
|
||||
}
|
||||
mDefaultNetworkMetrics.listEventsAsProto(events);
|
||||
return events;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the content of the rolling event buffer in text proto format.
|
||||
*/
|
||||
private void cmdListAsProto(PrintWriter pw) {
|
||||
final List<ConnectivityMetricsEvent> events = getEvents();
|
||||
for (IpConnectivityEvent ev : IpConnectivityEventBuilder.toProto(events)) {
|
||||
pw.print(ev.toString());
|
||||
private void cmdListAsTextProto(PrintWriter pw) {
|
||||
listEventsAsProtos().forEach(e -> pw.print(e.toString()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the content of the rolling event buffer in proto wire format to the given OutputStream.
|
||||
*/
|
||||
private void cmdListAsBinaryProto(OutputStream out) {
|
||||
final int dropped;
|
||||
synchronized (mLock) {
|
||||
dropped = mDropped;
|
||||
}
|
||||
if (mNetdListener != null) {
|
||||
mNetdListener.listAsProtos(pw);
|
||||
try {
|
||||
byte[] data = IpConnectivityEventBuilder.serialize(dropped, listEventsAsProtos());
|
||||
out.write(data);
|
||||
out.flush();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "could not serialize events", e);
|
||||
}
|
||||
mDefaultNetworkMetrics.listEventsAsProto(pw);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -267,6 +288,9 @@ final public class IpConnectivityMetrics extends SystemService {
|
||||
static final String CMD_FLUSH = "flush";
|
||||
// Dump the rolling buffer of metrics event in human readable proto text format.
|
||||
static final String CMD_PROTO = "proto";
|
||||
// Dump the rolling buffer of metrics event in proto wire format. See usage() of
|
||||
// frameworks/native/cmds/dumpsys/dumpsys.cpp for details.
|
||||
static final String CMD_PROTO_BIN = "--proto";
|
||||
// Dump the rolling buffer of metrics event and pretty print events using a human readable
|
||||
// format. Also print network dns/connect statistics and default network event time series.
|
||||
static final String CMD_LIST = "list";
|
||||
@@ -291,7 +315,10 @@ final public class IpConnectivityMetrics extends SystemService {
|
||||
cmdFlush(pw);
|
||||
return;
|
||||
case CMD_PROTO:
|
||||
cmdListAsProto(pw);
|
||||
cmdListAsTextProto(pw);
|
||||
return;
|
||||
case CMD_PROTO_BIN:
|
||||
cmdListAsBinaryProto(new FileOutputStream(fd));
|
||||
return;
|
||||
case CMD_LIST:
|
||||
default:
|
||||
|
||||
@@ -366,15 +366,18 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void listAsProtos(PrintWriter pw) {
|
||||
/**
|
||||
* Convert events in the buffer to protos and add to the given list
|
||||
*/
|
||||
public synchronized void listAsProtos(List<IpConnectivityEvent> out) {
|
||||
for (int i = 0; i < mNetworkMetrics.size(); i++) {
|
||||
pw.print(IpConnectivityEventBuilder.toProto(mNetworkMetrics.valueAt(i).connectMetrics));
|
||||
out.add(IpConnectivityEventBuilder.toProto(mNetworkMetrics.valueAt(i).connectMetrics));
|
||||
}
|
||||
for (int i = 0; i < mNetworkMetrics.size(); i++) {
|
||||
pw.print(IpConnectivityEventBuilder.toProto(mNetworkMetrics.valueAt(i).dnsMetrics));
|
||||
out.add(IpConnectivityEventBuilder.toProto(mNetworkMetrics.valueAt(i).dnsMetrics));
|
||||
}
|
||||
for (int i = 0; i < mWakeupStats.size(); i++) {
|
||||
pw.print(IpConnectivityEventBuilder.toProto(mWakeupStats.valueAt(i)));
|
||||
out.add(IpConnectivityEventBuilder.toProto(mWakeupStats.valueAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user