Fix proto invalid write type

While dumpProtoLocked is called, InvalidProtocolBufferException
occurred because types are mismatched between platform side and
module side.

netstats.proto was moved into connectivity module, both the
platform(incident.proto) and the module uses protoc-gen-javastream
to generate the Java classes from it. It should be fine since
platform includes the source of the proto, and jarjar the generated
classess in the module to avoid conflict with platform.

Bug: 218566849
Test: adb shell incident 3001
      adb shell dumpsys netstats --proto
      atest CtsIncidentHostTestCases:IncidentdTest#testIncidentReportDumpAuto
Change-Id: I4654350a59dc1ca1a925785ad37f34aa7b481235
Merged-In: I4654350a59dc1ca1a925785ad37f34aa7b481235
This commit is contained in:
Aaron Huang
2022-02-14 21:26:44 +08:00
parent fbb8986a58
commit cf97f22cdc
6 changed files with 31 additions and 31 deletions

View File

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

View File

@@ -2127,15 +2127,15 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
// TODO Right now it writes all history. Should it limit to the "since-boot" log?
dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_INTERFACES_FIELD_NUMBER,
dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_INTERFACES,
mActiveIfaces);
dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_UID_INTERFACES_FIELD_NUMBER,
dumpInterfaces(proto, NetworkStatsServiceDumpProto.ACTIVE_UID_INTERFACES,
mActiveUidIfaces);
mDevRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.DEV_STATS_FIELD_NUMBER);
mXtRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.XT_STATS_FIELD_NUMBER);
mUidRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.UID_STATS_FIELD_NUMBER);
mDevRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.DEV_STATS);
mXtRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.XT_STATS);
mUidRecorder.dumpDebugLocked(proto, NetworkStatsServiceDumpProto.UID_STATS);
mUidTagRecorder.dumpDebugLocked(proto,
NetworkStatsServiceDumpProto.UID_TAG_STATS_FIELD_NUMBER);
NetworkStatsServiceDumpProto.UID_TAG_STATS);
proto.flush();
}
@@ -2145,8 +2145,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
for (int i = 0; i < ifaces.size(); i++) {
final long start = proto.start(tag);
proto.write(NetworkInterfaceProto.INTERFACE_FIELD_NUMBER, ifaces.keyAt(i));
ifaces.valueAt(i).dumpDebug(proto, NetworkInterfaceProto.IDENTITIES_FIELD_NUMBER);
proto.write(NetworkInterfaceProto.INTERFACE, ifaces.keyAt(i));
ifaces.valueAt(i).dumpDebug(proto, NetworkInterfaceProto.IDENTITIES);
proto.end(start);
}